~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/cache.h

  • Committer: Daniel Nichter
  • Date: 2011-10-23 16:01:37 UTC
  • mto: This revision was merged to the branch mainline in revision 2448.
  • Revision ID: daniel@percona.com-20111023160137-7ac3blgz8z4tf8za
Add Administration Getting Started and Logging.  Capitalize SQL clause keywords.

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, Inc.
 
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
#pragma once
 
21
 
 
22
#include <drizzled/item/basic_constant.h>
 
23
#include <drizzled/item/field.h>
 
24
#include <drizzled/item/ident.h>
 
25
#include <drizzled/type/decimal.h>
 
26
#include <drizzled/util/test.h>
 
27
 
 
28
namespace drizzled {
 
29
 
 
30
class Item_cache : public Item_basic_constant
 
31
{
 
32
protected:
 
33
  Item *example;
 
34
  table_map used_table_map;
 
35
  /*
 
36
    Field that this object will get value from. This is set/used by
 
37
    index-based subquery engines to detect and remove the equality injected
 
38
    by IN->EXISTS transformation.
 
39
    For all other uses of Item_cache, cached_field doesn't matter.
 
40
  */
 
41
  Field *cached_field;
 
42
  enum enum_field_types cached_field_type;
 
43
public:
 
44
  Item_cache():
 
45
    example(0), used_table_map(0), cached_field(0), cached_field_type(DRIZZLE_TYPE_VARCHAR)
 
46
  {
 
47
    fixed= 1;
 
48
    null_value= 1;
 
49
  }
 
50
  Item_cache(enum_field_types field_type_arg):
 
51
    example(0), used_table_map(0), cached_field(0), cached_field_type(field_type_arg)
 
52
  {
 
53
    fixed= 1;
 
54
    null_value= 1;
 
55
  }
 
56
 
 
57
  void set_used_tables(table_map map) { used_table_map= map; }
 
58
 
 
59
  virtual void allocate(uint32_t) {};
 
60
  virtual bool setup(Item *item)
 
61
  {
 
62
    example= item;
 
63
    max_length= item->max_length;
 
64
    decimals= item->decimals;
 
65
    collation.set(item->collation);
 
66
    unsigned_flag= item->unsigned_flag;
 
67
    if (item->type() == FIELD_ITEM)
 
68
      cached_field= ((Item_field *)item)->field;
 
69
    return 0;
 
70
  };
 
71
  virtual void store(Item *)= 0;
 
72
  enum Type type() const { return CACHE_ITEM; }
 
73
  enum_field_types field_type() const { return cached_field_type; }
 
74
  static Item_cache* get_cache(const Item *item);
 
75
  table_map used_tables() const { return used_table_map; }
 
76
  virtual void keep_array() {}
 
77
  virtual void print(String *str);
 
78
  bool eq_def(Field *field);
 
79
  bool eq(const Item *item, bool) const
 
80
  {
 
81
    return this == item;
 
82
  }
 
83
  bool basic_const_item() const
 
84
  {
 
85
    return test(example && example->basic_const_item());
 
86
  }
 
87
};
 
88
 
 
89
} /* namespace drizzled */
 
90