~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/ident.h

pandora-build v0.100 - Fixes several bugs found by cb1kenobi. Add several thoughts from folks at LCA.

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_IDENT_H
 
21
#define DRIZZLED_ITEM_IDENT_H
 
22
 
 
23
#include "drizzled/item.h"
 
24
 
 
25
extern uint32_t lower_case_table_names;
 
26
 
 
27
class Item_ident :public Item
 
28
{
 
29
protected:
 
30
  /*
 
31
    We have to store initial values of db_name, table_name and field_name
 
32
    to be able to restore them during cleanup() because they can be
 
33
    updated during fix_fields() to values from Field object and life-time
 
34
    of those is shorter than life-time of Item_field.
 
35
  */
 
36
  const char *orig_db_name;
 
37
  const char *orig_table_name;
 
38
  const char *orig_field_name;
 
39
 
 
40
public:
 
41
  Name_resolution_context *context;
 
42
  const char *db_name;
 
43
  const char *table_name;
 
44
  const char *field_name;
 
45
  bool alias_name_used; /* true if item was resolved against alias */
 
46
  /*
 
47
    Cached value of index for this field in table->field array, used by prep.
 
48
    stmts for speeding up their re-execution. Holds NO_CACHED_FIELD_INDEX
 
49
    if index value is not known.
 
50
  */
 
51
  uint32_t cached_field_index;
 
52
  /*
 
53
    Cached pointer to table which contains this field, used for the same reason
 
54
    by prep. stmt. too in case then we have not-fully qualified field.
 
55
    0 - means no cached value.
 
56
  */
 
57
  TableList *cached_table;
 
58
  Select_Lex *depended_from;
 
59
  Item_ident(Name_resolution_context *context_arg,
 
60
             const char *db_name_arg, const char *table_name_arg,
 
61
             const char *field_name_arg);
 
62
  Item_ident(Session *session, Item_ident *item);
 
63
  const char *full_name() const;
 
64
  void cleanup();
 
65
  bool remove_dependence_processor(unsigned char * arg);
 
66
  virtual void print(String *str, enum_query_type query_type);
 
67
  virtual bool change_context_processor(unsigned char *cntx)
 
68
    { context= (Name_resolution_context *)cntx; return false; }
 
69
  friend bool insert_fields(Session *session, Name_resolution_context *context,
 
70
                            const char *db_name,
 
71
                            const char *table_name, List_iterator<Item> *it,
 
72
                            bool any_privileges);
 
73
};
 
74
 
 
75
 
 
76
class Item_ident_for_show :public Item
 
77
{
 
78
public:
 
79
  Field *field;
 
80
  const char *db_name;
 
81
  const char *table_name;
 
82
 
 
83
  Item_ident_for_show(Field *par_field, const char *db_arg,
 
84
                      const char *table_name_arg)
 
85
    :field(par_field), db_name(db_arg), table_name(table_name_arg)
 
86
  {}
 
87
 
 
88
  enum Type type() const { return FIELD_ITEM; }
 
89
  double val_real();
 
90
  int64_t val_int();
 
91
  String *val_str(String *str);
 
92
  my_decimal *val_decimal(my_decimal *dec);
 
93
  void make_field(SendField *tmp_field);
 
94
};
 
95
 
 
96
#endif /* DRIZZLED_ITEM_IDENT_H */