diff options
Diffstat (limited to 'sql/item.h')
-rw-r--r-- | sql/item.h | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/sql/item.h b/sql/item.h index 09882b26724..1881b15f6e5 100644 --- a/sql/item.h +++ b/sql/item.h @@ -37,6 +37,7 @@ public: PROC_ITEM,COND_ITEM, REF_ITEM, FIELD_STD_ITEM, FIELD_VARIANCE_ITEM, CONST_ITEM, SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM}; + enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE }; String str_value; /* used to store value */ @@ -167,9 +168,9 @@ public: bool get_date(TIME *ltime,bool fuzzydate); bool get_time(TIME *ltime); bool is_null() { return field->is_null(); } + friend class Item_default_value; }; - class Item_null :public Item { public: @@ -370,26 +371,6 @@ public: void print(String *str); }; - -/* For INSERT ... VALUES (DEFAULT) */ - -class Item_default :public Item -{ -public: - Item_default() { name= (char*) "DEFAULT"; } - enum Type type() const { return DEFAULT_ITEM; } - int save_in_field(Field *field, bool no_conversions) - { - field->set_default(); - return 0; - } - virtual double val() { return 0.0; } - virtual longlong val_int() { return 0; } - virtual String *val_str(String *str) { return 0; } - bool basic_const_item() const { return 1; } -}; - - /* for show tables */ class Item_datetime :public Item_string @@ -674,6 +655,41 @@ public: bool cmp(void); }; +class Item_default_value : public Item_field +{ +public: + Item *arg; + Item_default_value() : + Item_field((const char *)NULL, (const char *)NULL, (const char *)NULL), arg(NULL) {} + Item_default_value(Item *a) : + Item_field((const char *)NULL, (const char *)NULL, (const char *)NULL), arg(a) {} + enum Type type() const { return DEFAULT_ITEM; } + bool eq(const Item *item, bool binary_cmp) const; + bool fix_fields(THD *, struct st_table_list *, Item **); + bool check_loop(uint id) + { + return Item_field::check_loop(id) || arg->check_loop(id); + } + void set_outer_resolving() { arg->set_outer_resolving(); } + void print(String *str); + virtual bool basic_const_item() const { return true; } + int save_in_field(Field *field, bool no_conversions) + { + if (!arg) + { + field->set_default(); + return 0; + } + return Item_field::save_in_field(field, no_conversions); + } + table_map used_tables() const + { + if (!arg) + return (table_map) 0L; + return Item_field::used_tables(); + } +}; + class Item_cache: public Item { public: |