~drizzle-trunk/drizzle/development

642.1.11 by Lee
move functions from item.cc/item.h to item directory
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
642.1.11 by Lee
move functions from item.cc/item.h to item directory
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
2154.2.4 by Brian Aker
This fixes 716459
23
#include <drizzled/item/basic_constant.h>
24
#include <drizzled/item/field.h>
25
#include <drizzled/item/ident.h>
26
#include <drizzled/type/decimal.h>
27
#include <drizzled/util/test.h>
642.1.11 by Lee
move functions from item.cc/item.h to item directory
28
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
29
namespace drizzled
30
{
31
642.1.11 by Lee
move functions from item.cc/item.h to item directory
32
class Item_cache: public Item_basic_constant
33
{
34
protected:
35
  Item *example;
36
  table_map used_table_map;
37
  /*
38
    Field that this object will get value from. This is set/used by
39
    index-based subquery engines to detect and remove the equality injected
40
    by IN->EXISTS transformation.
41
    For all other uses of Item_cache, cached_field doesn't matter.
42
  */
43
  Field *cached_field;
44
  enum enum_field_types cached_field_type;
45
public:
46
  Item_cache():
47
    example(0), used_table_map(0), cached_field(0), cached_field_type(DRIZZLE_TYPE_VARCHAR)
48
  {
49
    fixed= 1;
50
    null_value= 1;
51
  }
52
  Item_cache(enum_field_types field_type_arg):
53
    example(0), used_table_map(0), cached_field(0), cached_field_type(field_type_arg)
54
  {
55
    fixed= 1;
56
    null_value= 1;
57
  }
58
59
  void set_used_tables(table_map map) { used_table_map= map; }
60
61
  virtual bool allocate(uint32_t)
62
  { return 0; }
63
  virtual bool setup(Item *item)
64
  {
65
    example= item;
66
    max_length= item->max_length;
67
    decimals= item->decimals;
68
    collation.set(item->collation);
69
    unsigned_flag= item->unsigned_flag;
70
    if (item->type() == FIELD_ITEM)
71
      cached_field= ((Item_field *)item)->field;
72
    return 0;
73
  };
74
  virtual void store(Item *)= 0;
75
  enum Type type() const { return CACHE_ITEM; }
76
  enum_field_types field_type() const { return cached_field_type; }
77
  static Item_cache* get_cache(const Item *item);
78
  table_map used_tables() const { return used_table_map; }
79
  virtual void keep_array() {}
2215.2.1 by Stewart Smith
remove enum_query_type which was effectively unused. It was set to one value once, compared to it once (i.e. always true) and passed around everywhere doing nothing.
80
  virtual void print(String *str);
642.1.11 by Lee
move functions from item.cc/item.h to item directory
81
  bool eq_def(Field *field);
82
  bool eq(const Item *item, bool) const
83
  {
84
    return this == item;
85
  }
1240.8.9 by Dennis Schoen
add basic_const_item() to Item_cache and Item_ref
86
  bool basic_const_item() const
87
  {
88
    return test(example && example->basic_const_item());
89
  }
642.1.11 by Lee
move functions from item.cc/item.h to item directory
90
};
91
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
92
} /* namespace drizzled */
93
642.1.11 by Lee
move functions from item.cc/item.h to item directory
94
#endif /* DRIZZLED_ITEM_CACHE_H */