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 class Item_ident : public Item
00027 {
00028 protected:
00029   /*
00030     We have to store initial values of db_name, table_name and field_name
00031     to be able to restore them during cleanup() because they can be
00032     updated during fix_fields() to values from Field object and life-time
00033     of those is shorter than life-time of Item_field.
00034   */
00035   const char *orig_db_name;
00036   const char *orig_table_name;
00037   const char *orig_field_name;
00038 
00039 public:
00040   Name_resolution_context *context;
00041   const char *db_name;
00042   const char *table_name;
00043   const char *field_name;
00044   bool alias_name_used; /* true if item was resolved against alias */
00045   /*
00046     Cached value of index for this field in table->field array, used by prep.
00047     stmts for speeding up their re-execution. Holds NO_CACHED_FIELD_INDEX
00048     if index value is not known.
00049   */
00050   uint32_t cached_field_index;
00051   /*
00052     Cached pointer to table which contains this field, used for the same reason
00053     by prep. stmt. too in case then we have not-fully qualified field.
00054     0 - means no cached value.
00055   */
00056   TableList *cached_table;
00057   Select_Lex *depended_from;
00058   Item_ident(Name_resolution_context *context_arg,
00059              const char *db_name_arg, const char *table_name_arg,
00060              const char *field_name_arg);
00061   Item_ident(Session *session, Item_ident *item);
00062   const char *full_name() const;
00063   void cleanup();
00064   bool remove_dependence_processor(unsigned char * arg);
00065   virtual void print(String *str);
00066   virtual bool change_context_processor(unsigned char *cntx)
00067     { context= (Name_resolution_context *)cntx; return false; }
00068   friend bool insert_fields(Session *session, Name_resolution_context *context,
00069                             const char *db_name,
00070                             const char *table_name, List<Item>::iterator *it,
00071                             bool any_privileges);
00072 };
00073 
00074 
00075 class Item_ident_for_show : public Item
00076 {
00077 public:
00078   Field *field;
00079   const char *db_name;
00080   const char *table_name;
00081 
00082   Item_ident_for_show(Field *par_field, const char *db_arg,
00083                       const char *table_name_arg)
00084     :field(par_field), db_name(db_arg), table_name(table_name_arg)
00085   {}
00086 
00087   enum Type type() const { return FIELD_ITEM; }
00088   double val_real();
00089   int64_t val_int();
00090   String *val_str(String *str);
00091   type::Decimal *val_decimal(type::Decimal *dec);
00092   void make_field(SendField *tmp_field);
00093 };
00094 
00095 } /* namespace drizzled */
00096