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