Drizzled Public API Documentation

insert_value.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/field.h>
00023 
00024 namespace drizzled
00025 {
00026 
00027 /*
00028   Item_insert_value -- an implementation of VALUES() function.
00029   You can use the VALUES(col_name) function in the UPDATE clause
00030   to refer to column values from the INSERT portion of the INSERT
00031   ... UPDATE statement. In other words, VALUES(col_name) in the
00032   UPDATE clause refers to the value of col_name that would be
00033   inserted, had no duplicate-key conflict occurred.
00034   In all other places this function returns NULL.
00035 */
00036 
00037 class Item_insert_value : public Item_field
00038 {
00039 public: 
00040   Item *arg;
00041   Item_insert_value(Name_resolution_context *context_arg, Item *a)
00042     :Item_field(context_arg, (const char *)NULL, (const char *)NULL,
00043                (const char *)NULL),
00044      arg(a) {}
00045   bool eq(const Item *item, bool binary_cmp) const;
00046   bool fix_fields(Session *, Item **);
00047   virtual void print(String *str);
00048   int save_in_field(Field *field_arg, bool no_conversions)
00049   {
00050     return Item_field::save_in_field(field_arg, no_conversions);
00051   }
00052   /*
00053    We use RAND_TABLE_BIT to prevent Item_insert_value from
00054    being treated as a constant and precalculated before execution
00055   */
00056   table_map used_tables() const { return RAND_TABLE_BIT; }
00057 
00058   bool walk(Item_processor processor, bool walk_subquery, unsigned char *args)
00059   {
00060     return arg->walk(processor, walk_subquery, args) ||
00061             (this->*processor)(args);
00062   }
00063 };
00064 
00065 } /* namespace drizzled */
00066