~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/cache.h

  • Committer: Monty Taylor
  • Date: 2008-10-09 22:38:27 UTC
  • mto: This revision was merged to the branch mainline in revision 497.
  • Revision ID: monty@inaugust.com-20081009223827-bc9gvpiplsmvpwyq
Moved test() to its own file.
Made a new function to possibly replace int10_to_str.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
#ifndef DRIZZLED_ITEM_CACHE_H
21
 
#define DRIZZLED_ITEM_CACHE_H
22
 
 
23
 
#include "drizzled/item/ident.h"
24
 
#include "drizzled/item/field.h"
25
 
#include "drizzled/item/basic_constant.h"
26
 
#include "drizzled/util/test.h"
27
 
 
28
 
namespace drizzled
29
 
{
30
 
 
31
 
class Item_cache: public Item_basic_constant
32
 
{
33
 
protected:
34
 
  Item *example;
35
 
  table_map used_table_map;
36
 
  /*
37
 
    Field that this object will get value from. This is set/used by
38
 
    index-based subquery engines to detect and remove the equality injected
39
 
    by IN->EXISTS transformation.
40
 
    For all other uses of Item_cache, cached_field doesn't matter.
41
 
  */
42
 
  Field *cached_field;
43
 
  enum enum_field_types cached_field_type;
44
 
public:
45
 
  Item_cache():
46
 
    example(0), used_table_map(0), cached_field(0), cached_field_type(DRIZZLE_TYPE_VARCHAR)
47
 
  {
48
 
    fixed= 1;
49
 
    null_value= 1;
50
 
  }
51
 
  Item_cache(enum_field_types field_type_arg):
52
 
    example(0), used_table_map(0), cached_field(0), cached_field_type(field_type_arg)
53
 
  {
54
 
    fixed= 1;
55
 
    null_value= 1;
56
 
  }
57
 
 
58
 
  void set_used_tables(table_map map) { used_table_map= map; }
59
 
 
60
 
  virtual bool allocate(uint32_t)
61
 
  { return 0; }
62
 
  virtual bool setup(Item *item)
63
 
  {
64
 
    example= item;
65
 
    max_length= item->max_length;
66
 
    decimals= item->decimals;
67
 
    collation.set(item->collation);
68
 
    unsigned_flag= item->unsigned_flag;
69
 
    if (item->type() == FIELD_ITEM)
70
 
      cached_field= ((Item_field *)item)->field;
71
 
    return 0;
72
 
  };
73
 
  virtual void store(Item *)= 0;
74
 
  enum Type type() const { return CACHE_ITEM; }
75
 
  enum_field_types field_type() const { return cached_field_type; }
76
 
  static Item_cache* get_cache(const Item *item);
77
 
  table_map used_tables() const { return used_table_map; }
78
 
  virtual void keep_array() {}
79
 
  virtual void print(String *str, enum_query_type query_type);
80
 
  bool eq_def(Field *field);
81
 
  bool eq(const Item *item, bool) const
82
 
  {
83
 
    return this == item;
84
 
  }
85
 
  bool basic_const_item() const
86
 
  {
87
 
    return test(example && example->basic_const_item());
88
 
  }
89
 
};
90
 
 
91
 
} /* namespace drizzled */
92
 
 
93
 
#endif /* DRIZZLED_ITEM_CACHE_H */