Drizzled Public API Documentation

ident.h

00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #pragma once
00021 
00022 #include <drizzled/item.h>
00023 
00024 namespace drizzled
00025 {
00026 
00027 class Name_resolution_context;
00028 class TableList;
00029 extern uint32_t lower_case_table_names;
00030 
00031 class Item_ident :public Item
00032 {
00033 protected:
00034   /*
00035     We have to store initial values of db_name, table_name and field_name
00036     to be able to restore them during cleanup() because they can be
00037     updated during fix_fields() to values from Field object and life-time
00038     of those is shorter than life-time of Item_field.
00039   */
00040   const char *orig_db_name;
00041   const char *orig_table_name;
00042   const char *orig_field_name;
00043 
00044 public:
00045   Name_resolution_context *context;
00046   const char *db_name;
00047   const char *table_name;
00048   const char *field_name;
00049   bool alias_name_used; /* true if item was resolved against alias */
00050   /*
00051     Cached value of index for this field in table->field array, used by prep.
00052     stmts for speeding up their re-execution. Holds NO_CACHED_FIELD_INDEX
00053     if index value is not known.
00054   */
00055   uint32_t cached_field_index;
00056   /*
00057     Cached pointer to table which contains this field, used for the same reason
00058     by prep. stmt. too in case then we have not-fully qualified field.
00059     0 - means no cached value.
00060   */
00061   TableList *cached_table;
00062   Select_Lex *depended_from;
00063   Item_ident(Name_resolution_context *context_arg,
00064              const char *db_name_arg, const char *table_name_arg,
00065              const char *field_name_arg);
00066   Item_ident(Session *session, Item_ident *item);
00067   const char *full_name() const;
00068   void cleanup();
00069   bool remove_dependence_processor(unsigned char * arg);
00070   virtual void print(String *str);
00071   virtual bool change_context_processor(unsigned char *cntx)
00072     { context= (Name_resolution_context *)cntx; return false; }
00073   friend bool insert_fields(Session *session, Name_resolution_context *context,
00074                             const char *db_name,
00075                             const char *table_name, List<Item>::iterator *it,
00076                             bool any_privileges);
00077 };
00078 
00079 
00080 class Item_ident_for_show :public Item
00081 {
00082 public:
00083   Field *field;
00084   const char *db_name;
00085   const char *table_name;
00086 
00087   Item_ident_for_show(Field *par_field, const char *db_arg,
00088                       const char *table_name_arg)
00089     :field(par_field), db_name(db_arg), table_name(table_name_arg)
00090   {}
00091 
00092   enum Type type() const { return FIELD_ITEM; }
00093   double val_real();
00094   int64_t val_int();
00095   String *val_str(String *str);
00096   type::Decimal *val_decimal(type::Decimal *dec);
00097   void make_field(SendField *tmp_field);
00098 };
00099 
00100 } /* namespace drizzled */
00101