diff options
author | unknown <paul@teton.kitebird.com> | 2004-01-20 14:55:48 -0600 |
---|---|---|
committer | unknown <paul@teton.kitebird.com> | 2004-01-20 14:55:48 -0600 |
commit | d61793be16b1dda25b2ff864469f0eec01c20914 (patch) | |
tree | eedac72dd36254f65d48c424cf0a3b20cd8d37af /sql | |
parent | 1136d6353cf6fe3d321639079a39dc37758e3eee (diff) | |
parent | 53d6a088bcbab1777e32777e80a548b46f1140af (diff) | |
download | mariadb-git-d61793be16b1dda25b2ff864469f0eec01c20914.tar.gz |
Merge paul@bk-internal.mysql.com:/home/bk/mysql-4.1
into teton.kitebird.com:/home/paul/mysql-4.1
sql/share/czech/errmsg.txt:
Auto merged
sql/share/danish/errmsg.txt:
Auto merged
sql/share/dutch/errmsg.txt:
Auto merged
sql/share/english/errmsg.txt:
Auto merged
sql/share/estonian/errmsg.txt:
Auto merged
sql/share/french/errmsg.txt:
Auto merged
sql/share/german/errmsg.txt:
Auto merged
sql/share/greek/errmsg.txt:
Auto merged
sql/share/hungarian/errmsg.txt:
Auto merged
sql/share/italian/errmsg.txt:
Auto merged
sql/share/japanese/errmsg.txt:
Auto merged
sql/share/korean/errmsg.txt:
Auto merged
sql/share/norwegian-ny/errmsg.txt:
Auto merged
sql/share/norwegian/errmsg.txt:
Auto merged
sql/share/polish/errmsg.txt:
Auto merged
sql/share/portuguese/errmsg.txt:
Auto merged
sql/share/romanian/errmsg.txt:
Auto merged
sql/share/russian/errmsg.txt:
Auto merged
sql/share/serbian/errmsg.txt:
Auto merged
sql/share/slovak/errmsg.txt:
Auto merged
sql/share/spanish/errmsg.txt:
Auto merged
sql/share/swedish/errmsg.txt:
Auto merged
sql/share/ukrainian/errmsg.txt:
Auto merged
Diffstat (limited to 'sql')
45 files changed, 373 insertions, 218 deletions
diff --git a/sql/item.cc b/sql/item.cc index 37240700c68..09328dfbf07 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -71,18 +71,18 @@ Item::Item(): Used for duplicating lists in processing queries with temporary tables */ -Item::Item(THD *thd, Item &item): - str_value(item.str_value), - name(item.name), - max_length(item.max_length), - marker(item.marker), - decimals(item.decimals), - maybe_null(item.maybe_null), - null_value(item.null_value), - unsigned_flag(item.unsigned_flag), - with_sum_func(item.with_sum_func), - fixed(item.fixed), - collation(item.collation) +Item::Item(THD *thd, Item *item): + str_value(item->str_value), + name(item->name), + max_length(item->max_length), + marker(item->marker), + decimals(item->decimals), + maybe_null(item->maybe_null), + null_value(item->null_value), + unsigned_flag(item->unsigned_flag), + with_sum_func(item->with_sum_func), + fixed(item->fixed), + collation(item->collation) { next= thd->free_list; // Put in free list thd->free_list= this; @@ -110,12 +110,12 @@ Item_ident::Item_ident(const char *db_name_par,const char *table_name_par, } // Constructor used by Item_field & Item_ref (see Item comment) -Item_ident::Item_ident(THD *thd, Item_ident &item): +Item_ident::Item_ident(THD *thd, Item_ident *item): Item(thd, item), - db_name(item.db_name), - table_name(item.table_name), - field_name(item.field_name), - depended_from(item.depended_from) + db_name(item->db_name), + table_name(item->table_name), + field_name(item->field_name), + depended_from(item->depended_from) {} bool Item_ident::remove_dependence_processor(byte * arg) @@ -296,10 +296,10 @@ Item_field::Item_field(Field *f) :Item_ident(NullS,f->table_name,f->field_name) } // Constructor need to process subselect with temporary tables (see Item) -Item_field::Item_field(THD *thd, Item_field &item) +Item_field::Item_field(THD *thd, Item_field *item) :Item_ident(thd, item), - field(item.field), - result_field(item.result_field) + field(item->field), + result_field(item->result_field) { collation.set(DERIVATION_IMPLICIT); } @@ -455,7 +455,7 @@ table_map Item_field::used_tables() const Item *Item_field::get_tmp_table_item(THD *thd) { - Item_field *new_item= new Item_field(thd, *this); + Item_field *new_item= new Item_field(thd, this); if (new_item) new_item->field= new_item->result_field; return new_item; @@ -920,6 +920,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) Item_ref *rf; *ref= rf= new Item_ref(last->ref_pointer_array + counter, + ref, (char *)table_name, (char *)field_name); if (!rf) @@ -936,7 +937,8 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) if (last->having_fix_field) { Item_ref *rf; - *ref= rf= new Item_ref((where->db[0]?where->db:0), + *ref= rf= new Item_ref(ref, *ref, + (where->db[0]?where->db:0), (char *)where->alias, (char *)field_name); if (!rf) @@ -962,6 +964,11 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) return 0; } +void Item_field::cleanup() +{ + Item_ident::cleanup(); + field= result_field= 0; +} void Item::init_make_field(Send_field *tmp_field, enum enum_field_types field_type) @@ -1601,6 +1608,14 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) } +void Item_ref::cleanup() +{ + Item_ident::cleanup(); + if (hook_ptr) + *hook_ptr= orig_item; +} + + void Item_ref::print(String *str) { if (ref && *ref) @@ -2009,7 +2024,8 @@ void Item_cache_row::bring_value() Item_type_holder::Item_type_holder(THD *thd, Item *item) - :Item(thd, *item), item_type(item->result_type()) + :Item(thd, item), item_type(item->result_type()), + orig_type(item_type) { DBUG_ASSERT(item->fixed); diff --git a/sql/item.h b/sql/item.h index e7ccdb7ea12..7b5c506079d 100644 --- a/sql/item.h +++ b/sql/item.h @@ -124,8 +124,8 @@ public: top AND/OR ctructure of WHERE clause to protect it of optimisation changes in prepared statements */ - Item(THD *thd, Item &item); - virtual ~Item() { name=0; cleanup(); } /*lint -e1509 */ + Item(THD *thd, Item *item); + virtual ~Item() { name=0; } /*lint -e1509 */ void set_name(const char *str,uint length, CHARSET_INFO *cs); void init_make_field(Send_field *tmp_field,enum enum_field_types type); virtual void cleanup() { fixed=0; } @@ -227,6 +227,11 @@ public: /* Used in sql_select.cc:eliminate_not_funcs() */ virtual Item *neg_transformer() { return NULL; } + void delete_self() + { + cleanup(); + delete this; + } }; @@ -240,7 +245,7 @@ public: st_select_lex *depended_from; Item_ident(const char *db_name_par,const char *table_name_par, const char *field_name_par); - Item_ident::Item_ident(THD *thd, Item_ident &item); + Item_ident::Item_ident(THD *thd, Item_ident *item); const char *full_name() const; bool remove_dependence_processor(byte * arg); @@ -259,7 +264,7 @@ public: :Item_ident(db_par,table_name_par,field_name_par),field(0),result_field(0) { collation.set(DERIVATION_IMPLICIT); } // Constructor need to process subselect with temporary tables (see Item) - Item_field(THD *thd, Item_field &item); + Item_field(THD *thd, Item_field *item); Item_field(Field *field); enum Type type() const { return FIELD_ITEM; } bool eq(const Item *item, bool binary_cmp) const; @@ -290,6 +295,7 @@ public: bool get_time(TIME *ltime); bool is_null() { return field->is_null(); } Item *get_tmp_table_item(THD *thd); + void cleanup(); friend class Item_default_value; friend class Item_insert_value; }; @@ -498,7 +504,6 @@ public: set_name(name_par,0,cs); decimals=NOT_FIXED_DEC; } - ~Item_string() {} enum Type type() const { return STRING_ITEM; } double val() { @@ -565,7 +570,6 @@ class Item_varbinary :public Item { public: Item_varbinary(const char *str,uint str_length); - ~Item_varbinary() {} enum Type type() const { return VARBIN_ITEM; } double val() { return (double) Item_varbinary::val_int(); } longlong val_int(); @@ -582,8 +586,8 @@ public: Field *result_field; /* Save result here */ Item_result_field() :result_field(0) {} // Constructor used for Item_sum/Item_cond_and/or (see Item comment) - Item_result_field(THD *thd, Item_result_field &item): - Item(thd, item), result_field(item.result_field) + Item_result_field(THD *thd, Item_result_field *item): + Item(thd, item), result_field(item->result_field) {} ~Item_result_field() {} /* Required with gcc 2.95 */ Field *get_tmp_table_field() { return result_field; } @@ -602,20 +606,25 @@ public: class Item_ref :public Item_ident { public: - Field *result_field; /* Save result here */ + Field *result_field; /* Save result here */ Item **ref; - Item_ref(const char *db_par, const char *table_name_par, - const char *field_name_par) - :Item_ident(db_par,table_name_par,field_name_par),ref(0) {} - Item_ref(Item **item, const char *table_name_par, const char *field_name_par) - :Item_ident(NullS,table_name_par,field_name_par),ref(item) {} + Item **hook_ptr; /* These two to restore */ + Item *orig_item; /* things in 'cleanup()' */ + Item_ref(Item **hook, Item *original,const char *db_par, + const char *table_name_par, const char *field_name_par) + :Item_ident(db_par,table_name_par,field_name_par),ref(0), hook_ptr(hook), + orig_item(original) {} + Item_ref(Item **item, Item **hook, + const char *table_name_par, const char *field_name_par) + :Item_ident(NullS,table_name_par,field_name_par), + ref(item), hook_ptr(hook), orig_item(hook ? *hook:0) {} // Constructor need to process subselect with temporary tables (see Item) - Item_ref(THD *thd, Item_ref &item) - :Item_ident(thd, item), ref(item.ref) {} + Item_ref(THD *thd, Item_ref *item, Item **hook) + :Item_ident(thd, item), ref(item->ref), + hook_ptr(hook), orig_item(hook ? *hook : 0) {} enum Type type() const { return REF_ITEM; } bool eq(const Item *item, bool binary_cmp) const { return ref && (*ref)->eq(item, binary_cmp); } - ~Item_ref() { if (ref && (*ref) && (*ref) != this) delete *ref; } double val() { double tmp=(*ref)->val_result(); @@ -660,6 +669,7 @@ public: } Item *real_item() { return *ref; } void print(String *str); + void cleanup(); }; class Item_in_subselect; @@ -670,7 +680,7 @@ protected: public: Item_ref_null_helper(Item_in_subselect* master, Item **item, const char *table_name_par, const char *field_name_par): - Item_ref(item, table_name_par, field_name_par), owner(master) {} + Item_ref(item, NULL, table_name_par, field_name_par), owner(master) {} double val(); longlong val_int(); String* val_str(String* s); @@ -734,7 +744,6 @@ public: name=item->name; cached_field_type= item->field_type(); } - ~Item_copy_string() { delete item; } enum Type type() const { return COPY_STR_ITEM; } enum Item_result result_type () const { return STRING_RESULT; } enum_field_types field_type() const { return cached_field_type; } @@ -984,6 +993,11 @@ public: bool check_cols(uint c); bool null_inside(); void bring_value(); + void cleanup() + { + Item_cache::cleanup(); + values= 0; + } }; @@ -994,6 +1008,7 @@ class Item_type_holder: public Item { protected: Item_result item_type; + Item_result orig_type; Field *field_example; public: Item_type_holder(THD*, Item*); @@ -1005,6 +1020,11 @@ public: String *val_str(String*); bool join_types(THD *thd, Item *); Field *example() { return field_example; } + void cleanup() + { + Item::cleanup(); + item_type= orig_type; + } }; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index a79ef21e97a..0b9c7f8d92a 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -496,7 +496,6 @@ longlong Item_func_eq::val_int() return value == 0 ? 1 : 0; } - /* Same as Item_func_eq, but NULL = NULL */ void Item_func_equal::fix_length_and_dec() @@ -1652,10 +1651,10 @@ longlong Item_func_bit_and::val_int() return (longlong) (arg1 & arg2); } -Item_cond::Item_cond(THD *thd, Item_cond &item) +Item_cond::Item_cond(THD *thd, Item_cond *item) :Item_bool_func(thd, item), - abort_on_null(item.abort_on_null), - and_tables_cache(item.and_tables_cache) + abort_on_null(item->abort_on_null), + and_tables_cache(item->and_tables_cache) { /* here should be following text: @@ -1754,7 +1753,7 @@ void Item_cond::split_sum_func(Item **ref_pointer_array, List<Item> &fields) uint el= fields.elements; fields.push_front(item); ref_pointer_array[el]= item; - li.replace(new Item_ref(ref_pointer_array + el, 0, item->name)); + li.replace(new Item_ref(ref_pointer_array + el, li.ref(), 0, item->name)); } item->update_used_tables(); used_tables_cache|=item->used_tables(); diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 541bc47557d..3ad3b928c01 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -82,7 +82,7 @@ public: Item_bool_func() :Item_int_func() {} Item_bool_func(Item *a) :Item_int_func(a) {} Item_bool_func(Item *a,Item *b) :Item_int_func(a,b) {} - Item_bool_func(THD *thd, Item_bool_func &item) :Item_int_func(thd, item) {} + Item_bool_func(THD *thd, Item_bool_func *item) :Item_int_func(thd, item) {} void fix_length_and_dec() { decimals=0; max_length=1; } }; @@ -197,11 +197,19 @@ public: class Item_bool_rowready_func2 :public Item_bool_func2 { + Item *orig_a, *orig_b; /* propagate_const can change parameters */ public: - Item_bool_rowready_func2(Item *a,Item *b) :Item_bool_func2(a,b) + Item_bool_rowready_func2(Item *a,Item *b) :Item_bool_func2(a,b), + orig_a(a), orig_b(b) { allowed_arg_cols= a->cols(); } + void cleanup() + { + Item_bool_func2::cleanup(); + tmp_arg[0]= orig_a; + tmp_arg[1]= orig_b; + } }; class Item_func_not :public Item_bool_func @@ -705,10 +713,6 @@ class Item_func_in :public Item_int_func } longlong val_int(); void fix_length_and_dec(); - ~Item_func_in() - { - cleanup(); /* This is not called by Item::~Item() */ - } void cleanup() { delete array; @@ -885,10 +889,9 @@ public: list.push_back(i1); list.push_back(i2); } - Item_cond(THD *thd, Item_cond &item); + Item_cond(THD *thd, Item_cond *item); Item_cond(List<Item> &nlist) :Item_bool_func(), list(nlist), abort_on_null(0) {} - ~Item_cond() { list.delete_elements(); } bool add(Item *item) { return list.push_back(item); } bool fix_fields(THD *, struct st_table_list *, Item **ref); @@ -911,7 +914,7 @@ class Item_cond_and :public Item_cond public: Item_cond_and() :Item_cond() {} Item_cond_and(Item *i1,Item *i2) :Item_cond(i1,i2) {} - Item_cond_and(THD *thd, Item_cond_and &item) :Item_cond(thd, item) {} + Item_cond_and(THD *thd, Item_cond_and *item) :Item_cond(thd, item) {} Item_cond_and(List<Item> &list): Item_cond(list) {} enum Functype functype() const { return COND_AND_FUNC; } longlong val_int(); @@ -919,7 +922,7 @@ public: Item* copy_andor_structure(THD *thd) { Item_cond_and *item; - if((item= new Item_cond_and(thd, *this))) + if((item= new Item_cond_and(thd, this))) item->copy_andor_arguments(thd, this); return item; } @@ -931,7 +934,7 @@ class Item_cond_or :public Item_cond public: Item_cond_or() :Item_cond() {} Item_cond_or(Item *i1,Item *i2) :Item_cond(i1,i2) {} - Item_cond_or(THD *thd, Item_cond_or &item) :Item_cond(thd, item) {} + Item_cond_or(THD *thd, Item_cond_or *item) :Item_cond(thd, item) {} Item_cond_or(List<Item> &list): Item_cond(list) {} enum Functype functype() const { return COND_OR_FUNC; } longlong val_int(); @@ -940,7 +943,7 @@ public: Item* copy_andor_structure(THD *thd) { Item_cond_or *item; - if((item= new Item_cond_or(thd, *this))) + if((item= new Item_cond_or(thd, this))) item->copy_andor_arguments(thd, this); return item; } diff --git a/sql/item_func.cc b/sql/item_func.cc index 802b6dbb8d6..4c3db4b3373 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -130,13 +130,13 @@ Item_func::Item_func(List<Item> &list) set_arguments(list); } -Item_func::Item_func(THD *thd, Item_func &item) +Item_func::Item_func(THD *thd, Item_func *item) :Item_result_field(thd, item), - allowed_arg_cols(item.allowed_arg_cols), - arg_count(item.arg_count), - used_tables_cache(item.used_tables_cache), - not_null_tables_cache(item.not_null_tables_cache), - const_item_cache(item.const_item_cache) + allowed_arg_cols(item->allowed_arg_cols), + arg_count(item->arg_count), + used_tables_cache(item->used_tables_cache), + not_null_tables_cache(item->not_null_tables_cache), + const_item_cache(item->const_item_cache) { if (arg_count) { @@ -147,7 +147,7 @@ Item_func::Item_func(THD *thd, Item_func &item) if (!(args=(Item**) thd->alloc(sizeof(Item*)*arg_count))) return; } - memcpy((char*) args, (char*) item.args, sizeof(Item*)*arg_count); + memcpy((char*) args, (char*) item->args, sizeof(Item*)*arg_count); } } @@ -252,7 +252,7 @@ void Item_func::split_sum_func(Item **ref_pointer_array, List<Item> &fields) uint el= fields.elements; fields.push_front(item); ref_pointer_array[el]= item; - *arg= new Item_ref(ref_pointer_array + el, 0, item->name); + *arg= new Item_ref(ref_pointer_array + el, arg, 0, item->name); } } } diff --git a/sql/item_func.h b/sql/item_func.h index 33a4357d26c..be20a9b4fc7 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -106,8 +106,7 @@ public: } Item_func(List<Item> &list); // Constructor used for Item_cond_and/or (see Item comment) - Item_func(THD *thd, Item_func &item); - ~Item_func() {} /* Nothing to do; Items are freed automaticly */ + Item_func(THD *thd, Item_func *item); bool fix_fields(THD *,struct st_table_list *, Item **ref); table_map used_tables() const; table_map not_null_tables() const; @@ -200,7 +199,7 @@ public: Item_int_func(Item *a,Item *b) :Item_func(a,b) { max_length=21; } Item_int_func(Item *a,Item *b,Item *c) :Item_func(a,b,c) { max_length=21; } Item_int_func(List<Item> &list) :Item_func(list) { max_length=21; } - Item_int_func(THD *thd, Item_int_func &item) :Item_func(thd, item) {} + Item_int_func(THD *thd, Item_int_func *item) :Item_func(thd, item) {} double val() { return (double) val_int(); } String *val_str(String*str); enum Item_result result_type () const { return INT_RESULT; } @@ -755,7 +754,6 @@ public: Item_udf_func(udf_func *udf_arg) :Item_func(), udf(udf_arg) {} Item_udf_func(udf_func *udf_arg, List<Item> &list) :Item_func(list), udf(udf_arg) {} - ~Item_udf_func() {} const char *func_name() const { return udf.name(); } bool fix_fields(THD *thd, struct st_table_list *tables, Item **ref) { @@ -776,7 +774,6 @@ class Item_func_udf_float :public Item_udf_func Item_func_udf_float(udf_func *udf_arg) :Item_udf_func(udf_arg) {} Item_func_udf_float(udf_func *udf_arg, List<Item> &list) :Item_udf_func(udf_arg,list) {} - ~Item_func_udf_float() {} longlong val_int() { return (longlong) Item_func_udf_float::val(); } double val(); String *val_str(String *str); @@ -790,7 +787,6 @@ public: Item_func_udf_int(udf_func *udf_arg) :Item_udf_func(udf_arg) {} Item_func_udf_int(udf_func *udf_arg, List<Item> &list) :Item_udf_func(udf_arg,list) {} - ~Item_func_udf_int() {} longlong val_int(); double val() { return (double) Item_func_udf_int::val_int(); } String *val_str(String *str); @@ -805,7 +801,6 @@ public: Item_func_udf_str(udf_func *udf_arg) :Item_udf_func(udf_arg) {} Item_func_udf_str(udf_func *udf_arg, List<Item> &list) :Item_udf_func(udf_arg,list) {} - ~Item_func_udf_str() {} String *val_str(String *); double val() { @@ -830,7 +825,6 @@ class Item_func_udf_float :public Item_real_func public: Item_func_udf_float(udf_func *udf_arg) :Item_real_func() {} Item_func_udf_float(udf_func *udf_arg, List<Item> &list) :Item_real_func(list) {} - ~Item_func_udf_float() {} double val() { return 0.0; } }; @@ -840,7 +834,6 @@ class Item_func_udf_int :public Item_int_func public: Item_func_udf_int(udf_func *udf_arg) :Item_int_func() {} Item_func_udf_int(udf_func *udf_arg, List<Item> &list) :Item_int_func(list) {} - ~Item_func_udf_int() {} longlong val_int() { return 0; } }; @@ -850,7 +843,6 @@ class Item_func_udf_str :public Item_func public: Item_func_udf_str(udf_func *udf_arg) :Item_func() {} Item_func_udf_str(udf_func *udf_arg, List<Item> &list) :Item_func(list) {} - ~Item_func_udf_str() {} String *val_str(String *) { null_value=1; return 0; } double val() { null_value=1; return 0.0; } longlong val_int() { null_value=1; return 0; } @@ -997,7 +989,7 @@ public: Item_func_match(List<Item> &a, uint b): Item_real_func(a), key(0), flags(b), join_key(0), ft_handler(0), table(0), master(0), concat(0) { } - ~Item_func_match() + void cleanup() { if (!master && ft_handler) { diff --git a/sql/item_row.cc b/sql/item_row.cc index 89b38c8a753..7f847bd1d4e 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -91,7 +91,7 @@ void Item_row::split_sum_func(Item **ref_pointer_array, List<Item> &fields) uint el= fields.elements; fields.push_front(*arg); ref_pointer_array[el]= *arg; - *arg= new Item_ref(ref_pointer_array + el, 0, (*arg)->name); + *arg= new Item_ref(ref_pointer_array + el, arg, 0, (*arg)->name); } } } diff --git a/sql/item_row.h b/sql/item_row.h index a09bd1a2c31..f87b4f66e80 100644 --- a/sql/item_row.h +++ b/sql/item_row.h @@ -34,12 +34,6 @@ public: with_null(0) {} - ~Item_row() - { - if (array_holder && items) - sql_element_free(items); - } - enum Type type() const { return ROW_ITEM; }; void illegal_method_call(const char *); bool is_null() { return null_value; } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 4507b2598a3..badc134ae1d 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -616,7 +616,8 @@ void Item_func_concat_ws::split_sum_func(Item **ref_pointer_array, uint el= fields.elements; fields.push_front(separator); ref_pointer_array[el]= separator; - separator= new Item_ref(ref_pointer_array + el, 0, separator->name); + separator= new Item_ref(ref_pointer_array + el, + &separator, 0, separator->name); } Item_str_func::split_sum_func(ref_pointer_array, fields); } @@ -1710,7 +1711,7 @@ void Item_func_make_set::split_sum_func(Item **ref_pointer_array, uint el= fields.elements; fields.push_front(item); ref_pointer_array[el]= item; - item= new Item_ref(ref_pointer_array + el, 0, item->name); + item= new Item_ref(ref_pointer_array + el, &item, 0, item->name); } Item_str_func::split_sum_func(ref_pointer_array, fields); } diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 40b00cdd488..fd0afb19726 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -95,7 +95,6 @@ class Item_func_concat_ws :public Item_str_func public: Item_func_concat_ws(Item *a,List<Item> &list) :Item_str_func(list),separator(a) {} - ~Item_func_concat_ws() { delete separator; } String *val_str(String *); void fix_length_and_dec(); void update_used_tables(); @@ -409,7 +408,6 @@ class Item_func_make_set :public Item_str_func public: Item_func_make_set(Item *a,List<Item> &list) :Item_str_func(list),item(a) {} - ~Item_func_make_set() { delete item; } String *val_str(String *str); bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref) { diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index ee034e4c559..518b712ad18 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -63,6 +63,11 @@ void Item_subselect::init(st_select_lex *select_lex, DBUG_VOID_RETURN; } +void Item_subselect::cleanup() +{ + Item_result_field::cleanup(); + engine->cleanup(); +} Item_subselect::~Item_subselect() { @@ -639,7 +644,8 @@ Item_in_subselect::single_value_transformer(JOIN *join, As far as Item_ref_in_optimizer do not substitude itself on fix_fields we can use same item for all selects. */ - expr= new Item_ref((Item**)optimizer->get_cache(), + expr= new Item_ref((Item**)optimizer->get_cache(), + NULL, (char *)"<no matter>", (char *)in_left_expr_name); @@ -789,7 +795,8 @@ Item_in_subselect::row_value_transformer(JOIN *join) (char *) "<list ref>"); func= eq_creator.create(new Item_ref((*optimizer->get_cache())-> - addr(i), + addr(i), + NULL, (char *)"<no matter>", (char *)in_left_expr_name), func); @@ -887,6 +894,12 @@ subselect_single_select_engine(st_select_lex *select, this->select_lex= select_lex; } +void subselect_single_select_engine::cleanup() +{ + prepared= 0; + optimized= 0; + executed= 0; +} subselect_union_engine::subselect_union_engine(st_select_lex_unit *u, select_subselect *result_arg, diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 8444dc7bf66..dc3d07540da 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -69,6 +69,7 @@ public: select_subselect *result); ~Item_subselect(); + void cleanup(); virtual void reset() { null_value= 1; @@ -199,6 +200,13 @@ public: {} + void cleanup() + { + Item_exists_subselect::cleanup(); + abort_on_null= 0; + transformed= 0; + upper_not= 0; + } subs_type substype() { return IN_SUBS; } void reset() { @@ -261,6 +269,7 @@ public: maybe_null= 0; } virtual ~subselect_engine() {}; // to satisfy compiler + virtual void cleanup() {} // set_thd should be called before prepare() void set_thd(THD *thd_arg) { thd= thd_arg; } @@ -290,6 +299,7 @@ public: subselect_single_select_engine(st_select_lex *select, select_subselect *result, Item_subselect *item); + void cleanup(); int prepare(); void fix_length_and_dec(Item_cache** row); int exec(); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index f187650515a..e01f9db3463 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -42,17 +42,17 @@ Item_sum::Item_sum(List<Item> &list) } // Constructor used in processing select with temporary tebles -Item_sum::Item_sum(THD *thd, Item_sum &item): - Item_result_field(thd, item), quick_group(item.quick_group) +Item_sum::Item_sum(THD *thd, Item_sum *item): + Item_result_field(thd, item), quick_group(item->quick_group) { - arg_count= item.arg_count; + arg_count= item->arg_count; if (arg_count <= 2) args=tmp_args; else if (!(args=(Item**) sql_alloc(sizeof(Item*)*arg_count))) return; for (uint i= 0; i < arg_count; i++) - args[i]= item.args[i]; + args[i]= item->args[i]; } void Item_sum::mark_as_sum_func() @@ -240,7 +240,7 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) Item *Item_sum_sum::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_sum(thd, *this); + return new (&thd->mem_root) Item_sum_sum(thd, this); } @@ -267,7 +267,7 @@ double Item_sum_sum::val() Item *Item_sum_count::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_count(thd, *this); + return new (&thd->mem_root) Item_sum_count(thd, this); } @@ -301,7 +301,7 @@ longlong Item_sum_count::val_int() Item *Item_sum_avg::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_avg(thd, *this); + return new (&thd->mem_root) Item_sum_avg(thd, this); } @@ -346,7 +346,7 @@ double Item_sum_std::val() Item *Item_sum_std::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_std(thd, *this); + return new (&thd->mem_root) Item_sum_std(thd, this); } @@ -356,7 +356,7 @@ Item *Item_sum_std::copy_or_same(THD* thd) Item *Item_sum_variance::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_variance(thd, *this); + return new (&thd->mem_root) Item_sum_variance(thd, this); } @@ -497,7 +497,7 @@ Item_sum_hybrid::val_str(String *str) Item *Item_sum_min::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_min(thd, *this); + return new (&thd->mem_root) Item_sum_min(thd, this); } @@ -550,7 +550,7 @@ bool Item_sum_min::add() Item *Item_sum_max::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_max(thd, *this); + return new (&thd->mem_root) Item_sum_max(thd, this); } @@ -616,7 +616,7 @@ void Item_sum_bit::clear() Item *Item_sum_or::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_or(thd, *this); + return new (&thd->mem_root) Item_sum_or(thd, this); } @@ -630,7 +630,7 @@ bool Item_sum_or::add() Item *Item_sum_xor::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_xor(thd, *this); + return new (&thd->mem_root) Item_sum_xor(thd, this); } @@ -644,7 +644,7 @@ bool Item_sum_xor::add() Item *Item_sum_and::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_and(thd, *this); + return new (&thd->mem_root) Item_sum_and(thd, this); } @@ -1082,8 +1082,9 @@ int dump_leaf(byte* key, uint32 count __attribute__((unused)), } -Item_sum_count_distinct::~Item_sum_count_distinct() +void Item_sum_count_distinct::cleanup() { + Item_sum_int::cleanup(); /* Free table and tree if they belong to this item (if item have not pointer to original item from which was made copy => it own its objects ) @@ -1095,6 +1096,8 @@ Item_sum_count_distinct::~Item_sum_count_distinct() delete tmp_table_param; if (use_tree) delete_tree(tree); + table= 0; + use_tree= 0; } } @@ -1279,7 +1282,7 @@ int Item_sum_count_distinct::tree_to_myisam() Item *Item_sum_count_distinct::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_count_distinct(thd, *this); + return new (&thd->mem_root) Item_sum_count_distinct(thd, this); } @@ -1379,7 +1382,7 @@ bool Item_udf_sum::add() Item *Item_sum_udf_float::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_udf_float(thd, *this); + return new (&thd->mem_root) Item_sum_udf_float(thd, this); } double Item_sum_udf_float::val() @@ -1402,7 +1405,7 @@ String *Item_sum_udf_float::val_str(String *str) Item *Item_sum_udf_int::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_udf_int(thd, *this); + return new (&thd->mem_root) Item_sum_udf_int(thd, this); } @@ -1438,7 +1441,7 @@ void Item_sum_udf_str::fix_length_and_dec() Item *Item_sum_udf_str::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_sum_udf_str(thd, *this); + return new (&thd->mem_root) Item_sum_udf_str(thd, this); } @@ -1661,6 +1664,23 @@ Item_func_group_concat::Item_func_group_concat(bool is_distinct, } +void Item_func_group_concat::cleanup() +{ + /* + Free table and tree if they belong to this item (if item have not pointer + to original item from which was made copy => it own its objects ) + */ + if (!original) + { + THD *thd= current_thd; + if (table) + free_tmp_table(thd, table); + delete tmp_table_param; + if (tree_mode) + delete_tree(tree); + } +} + Item_func_group_concat::~Item_func_group_concat() { /* @@ -1676,18 +1696,13 @@ Item_func_group_concat::~Item_func_group_concat() sprintf(warn_buff, ER(ER_CUT_VALUE_GROUP_CONCAT), count_cut_values); warning->set_msg(thd, warn_buff); } - if (table) - free_tmp_table(thd, table); - delete tmp_table_param; - if (tree_mode) - delete_tree(tree); } } Item *Item_func_group_concat::copy_or_same(THD* thd) { - return new (&thd->mem_root) Item_func_group_concat(thd, *this); + return new (&thd->mem_root) Item_func_group_concat(thd, this); } diff --git a/sql/item_sum.h b/sql/item_sum.h index 8065218df97..dc84e4d4ab7 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -57,8 +57,12 @@ public: } Item_sum(List<Item> &list); //Copy constructor, need to perform subselects with temporary tables - Item_sum(THD *thd, Item_sum &item); - ~Item_sum() { result_field=0; } + Item_sum(THD *thd, Item_sum *item); + void cleanup() + { + Item_result_field::cleanup(); + result_field=0; + } enum Type type() const { return SUM_FUNC_ITEM; } virtual enum Sumfunctype sum_func () const=0; @@ -106,7 +110,7 @@ public: Item_sum_num(Item *item_par) :Item_sum(item_par) {} Item_sum_num(Item *a, Item* b) :Item_sum(a,b) {} Item_sum_num(List<Item> &list) :Item_sum(list) {} - Item_sum_num(THD *thd, Item_sum_num &item) :Item_sum(thd, item) {} + Item_sum_num(THD *thd, Item_sum_num *item) :Item_sum(thd, item) {} bool fix_fields(THD *, TABLE_LIST *, Item **); longlong val_int() { return (longlong) val(); } /* Real as default */ String *val_str(String*str); @@ -119,7 +123,7 @@ class Item_sum_int :public Item_sum_num public: Item_sum_int(Item *item_par) :Item_sum_num(item_par) {} Item_sum_int(List<Item> &list) :Item_sum_num(list) {} - Item_sum_int(THD *thd, Item_sum_int &item) :Item_sum_num(thd, item) {} + Item_sum_int(THD *thd, Item_sum_int *item) :Item_sum_num(thd, item) {} double val() { return (double) val_int(); } String *val_str(String*str); enum Item_result result_type () const { return INT_RESULT; } @@ -135,8 +139,8 @@ class Item_sum_sum :public Item_sum_num public: Item_sum_sum(Item *item_par) :Item_sum_num(item_par),sum(0.0) {} - Item_sum_sum(THD *thd, Item_sum_sum &item) - :Item_sum_num(thd, item), sum(item.sum) {} + Item_sum_sum(THD *thd, Item_sum_sum *item) + :Item_sum_num(thd, item), sum(item->sum) {} enum Sumfunctype sum_func () const {return SUM_FUNC;} void clear(); bool add(); @@ -158,9 +162,9 @@ class Item_sum_count :public Item_sum_int Item_sum_count(Item *item_par) :Item_sum_int(item_par),count(0),used_table_cache(~(table_map) 0) {} - Item_sum_count(THD *thd, Item_sum_count &item) - :Item_sum_int(thd, item), count(item.count), - used_table_cache(item.used_table_cache) + Item_sum_count(THD *thd, Item_sum_count *item) + :Item_sum_int(thd, item), count(item->count), + used_table_cache(item->used_table_cache) {} table_map used_tables() const { return used_table_cache; } bool const_item() const { return !used_table_cache; } @@ -226,16 +230,16 @@ class Item_sum_count_distinct :public Item_sum_int tmp_table_param(0), tree(&tree_base), original(0), use_tree(0), always_null(0) { quick_group= 0; } - Item_sum_count_distinct(THD *thd, Item_sum_count_distinct &item) - :Item_sum_int(thd, item), table(item.table), - used_table_cache(item.used_table_cache), - field_lengths(item.field_lengths), tmp_table_param(item.tmp_table_param), - tree(item.tree), original(&item), key_length(item.key_length), - max_elements_in_tree(item.max_elements_in_tree), - rec_offset(item.rec_offset), use_tree(item.use_tree), - always_null(item.always_null) + Item_sum_count_distinct(THD *thd, Item_sum_count_distinct *item) + :Item_sum_int(thd, item), table(item->table), + used_table_cache(item->used_table_cache), + field_lengths(item->field_lengths), tmp_table_param(item->tmp_table_param), + tree(item->tree), original(item), key_length(item->key_length), + max_elements_in_tree(item->max_elements_in_tree), + rec_offset(item->rec_offset), use_tree(item->use_tree), + always_null(item->always_null) {} - ~Item_sum_count_distinct(); + void cleanup(); table_map used_tables() const { return used_table_cache; } enum Sumfunctype sum_func () const { return COUNT_DISTINCT_FUNC; } @@ -281,8 +285,8 @@ class Item_sum_avg :public Item_sum_num public: Item_sum_avg(Item *item_par) :Item_sum_num(item_par),count(0) {} - Item_sum_avg(THD *thd, Item_sum_avg &item) - :Item_sum_num(thd, item), sum(item.sum), count(item.count) {} + Item_sum_avg(THD *thd, Item_sum_avg *item) + :Item_sum_num(thd, item), sum(item->sum), count(item->count) {} enum Sumfunctype sum_func () const {return AVG_FUNC;} void clear(); bool add(); @@ -333,9 +337,9 @@ class Item_sum_variance : public Item_sum_num public: Item_sum_variance(Item *item_par) :Item_sum_num(item_par),count(0) {} - Item_sum_variance(THD *thd, Item_sum_variance &item): - Item_sum_num(thd, item), sum(item.sum), sum_sqr(item.sum_sqr), - count(item.count) {} + Item_sum_variance(THD *thd, Item_sum_variance *item): + Item_sum_num(thd, item), sum(item->sum), sum_sqr(item->sum_sqr), + count(item->count) {} enum Sumfunctype sum_func () const { return VARIANCE_FUNC; } void clear(); bool add(); @@ -366,7 +370,7 @@ class Item_sum_std :public Item_sum_variance { public: Item_sum_std(Item *item_par) :Item_sum_variance(item_par) {} - Item_sum_std(THD *thd, Item_sum_std &item) + Item_sum_std(THD *thd, Item_sum_std *item) :Item_sum_variance(thd, item) {} enum Sumfunctype sum_func () const { return STD_FUNC; } @@ -397,11 +401,11 @@ class Item_sum_hybrid :public Item_sum used_table_cache(~(table_map) 0), cmp_charset(&my_charset_bin) {} - Item_sum_hybrid(THD *thd, Item_sum_hybrid &item): - Item_sum(thd, item), value(item.value), tmp_value(item.tmp_value), - sum(item.sum), sum_int(item.sum_int), hybrid_type(item.hybrid_type), - hybrid_field_type(item.hybrid_field_type),cmp_sign(item.cmp_sign), - used_table_cache(item.used_table_cache), cmp_charset(item.cmp_charset) {} + Item_sum_hybrid(THD *thd, Item_sum_hybrid *item): + Item_sum(thd, item), value(item->value), tmp_value(item->tmp_value), + sum(item->sum), sum_int(item->sum_int), hybrid_type(item->hybrid_type), + hybrid_field_type(item->hybrid_field_type),cmp_sign(item->cmp_sign), + used_table_cache(item->used_table_cache), cmp_charset(item->cmp_charset) {} bool fix_fields(THD *, TABLE_LIST *, Item **); table_map used_tables() const { return used_table_cache; } bool const_item() const { return !used_table_cache; } @@ -432,7 +436,7 @@ class Item_sum_min :public Item_sum_hybrid { public: Item_sum_min(Item *item_par) :Item_sum_hybrid(item_par,1) {} - Item_sum_min(THD *thd, Item_sum_min &item) :Item_sum_hybrid(thd, item) {} + Item_sum_min(THD *thd, Item_sum_min *item) :Item_sum_hybrid(thd, item) {} enum Sumfunctype sum_func () const {return MIN_FUNC;} bool add(); @@ -445,7 +449,7 @@ class Item_sum_max :public Item_sum_hybrid { public: Item_sum_max(Item *item_par) :Item_sum_hybrid(item_par,-1) {} - Item_sum_max(THD *thd, Item_sum_max &item) :Item_sum_hybrid(thd, item) {} + Item_sum_max(THD *thd, Item_sum_max *item) :Item_sum_hybrid(thd, item) {} enum Sumfunctype sum_func () const {return MAX_FUNC;} bool add(); @@ -462,8 +466,8 @@ protected: public: Item_sum_bit(Item *item_par,ulonglong reset_arg) :Item_sum_int(item_par),reset_bits(reset_arg),bits(reset_arg) {} - Item_sum_bit(THD *thd, Item_sum_bit &item): - Item_sum_int(thd, item), reset_bits(item.reset_bits), bits(item.bits) {} + Item_sum_bit(THD *thd, Item_sum_bit *item): + Item_sum_int(thd, item), reset_bits(item->reset_bits), bits(item->bits) {} enum Sumfunctype sum_func () const {return SUM_BIT_FUNC;} void clear(); longlong val_int(); @@ -478,7 +482,7 @@ class Item_sum_or :public Item_sum_bit { public: Item_sum_or(Item *item_par) :Item_sum_bit(item_par,LL(0)) {} - Item_sum_or(THD *thd, Item_sum_or &item) :Item_sum_bit(thd, item) {} + Item_sum_or(THD *thd, Item_sum_or *item) :Item_sum_bit(thd, item) {} bool add(); const char *func_name() const { return "bit_or"; } Item *copy_or_same(THD* thd); @@ -489,7 +493,7 @@ class Item_sum_and :public Item_sum_bit { public: Item_sum_and(Item *item_par) :Item_sum_bit(item_par, ULONGLONG_MAX) {} - Item_sum_and(THD *thd, Item_sum_and &item) :Item_sum_bit(thd, item) {} + Item_sum_and(THD *thd, Item_sum_and *item) :Item_sum_bit(thd, item) {} bool add(); const char *func_name() const { return "bit_and"; } Item *copy_or_same(THD* thd); @@ -499,7 +503,7 @@ class Item_sum_xor :public Item_sum_bit { public: Item_sum_xor(Item *item_par) :Item_sum_bit(item_par,LL(0)) {} - Item_sum_xor(THD *thd, Item_sum_xor &item) :Item_sum_bit(thd, item) {} + Item_sum_xor(THD *thd, Item_sum_xor *item) :Item_sum_bit(thd, item) {} bool add(); const char *func_name() const { return "bit_xor"; } Item *copy_or_same(THD* thd); @@ -521,9 +525,8 @@ public: Item_udf_sum( udf_func *udf_arg, List<Item> &list ) :Item_sum( list ), udf(udf_arg) { quick_group=0;} - Item_udf_sum(THD *thd, Item_udf_sum &item) - :Item_sum(thd, item), udf(item.udf) {} - ~Item_udf_sum() {} + Item_udf_sum(THD *thd, Item_udf_sum *item) + :Item_sum(thd, item), udf(item->udf) {} const char *func_name() const { return udf.name(); } bool fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) { @@ -546,9 +549,8 @@ class Item_sum_udf_float :public Item_udf_sum Item_sum_udf_float(udf_func *udf_arg) :Item_udf_sum(udf_arg) {} Item_sum_udf_float(udf_func *udf_arg, List<Item> &list) :Item_udf_sum(udf_arg,list) {} - Item_sum_udf_float(THD *thd, Item_sum_udf_float &item) + Item_sum_udf_float(THD *thd, Item_sum_udf_float *item) :Item_udf_sum(thd, item) {} - ~Item_sum_udf_float() {} longlong val_int() { return (longlong) Item_sum_udf_float::val(); } double val(); String *val_str(String*str); @@ -563,9 +565,8 @@ public: Item_sum_udf_int(udf_func *udf_arg) :Item_udf_sum(udf_arg) {} Item_sum_udf_int(udf_func *udf_arg, List<Item> &list) :Item_udf_sum(udf_arg,list) {} - Item_sum_udf_int(THD *thd, Item_sum_udf_int &item) + Item_sum_udf_int(THD *thd, Item_sum_udf_int *item) :Item_udf_sum(thd, item) {} - ~Item_sum_udf_int() {} longlong val_int(); double val() { return (double) Item_sum_udf_int::val_int(); } String *val_str(String*str); @@ -581,9 +582,8 @@ public: Item_sum_udf_str(udf_func *udf_arg) :Item_udf_sum(udf_arg) {} Item_sum_udf_str(udf_func *udf_arg, List<Item> &list) :Item_udf_sum(udf_arg,list) {} - Item_sum_udf_str(THD *thd, Item_sum_udf_str &item) + Item_sum_udf_str(THD *thd, Item_sum_udf_str *item) :Item_udf_sum(thd, item) {} - ~Item_sum_udf_str() {} String *val_str(String *); double val() { @@ -610,9 +610,8 @@ class Item_sum_udf_float :public Item_sum_num public: Item_sum_udf_float(udf_func *udf_arg) :Item_sum_num() {} Item_sum_udf_float(udf_func *udf_arg, List<Item> &list) :Item_sum_num() {} - Item_sum_udf_float(THD *thd, Item_sum_udf_float &item) + Item_sum_udf_float(THD *thd, Item_sum_udf_float *item) :Item_sum_num(thd, item) {} - ~Item_sum_udf_float() {} enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } double val() { return 0.0; } void clear() {} @@ -626,9 +625,8 @@ class Item_sum_udf_int :public Item_sum_num public: Item_sum_udf_int(udf_func *udf_arg) :Item_sum_num() {} Item_sum_udf_int(udf_func *udf_arg, List<Item> &list) :Item_sum_num() {} - Item_sum_udf_int(THD *thd, Item_sum_udf_int &item) + Item_sum_udf_int(THD *thd, Item_sum_udf_int *item) :Item_sum_num(thd, item) {} - ~Item_sum_udf_int() {} enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } longlong val_int() { return 0; } double val() { return 0; } @@ -643,9 +641,8 @@ class Item_sum_udf_str :public Item_sum_num public: Item_sum_udf_str(udf_func *udf_arg) :Item_sum_num() {} Item_sum_udf_str(udf_func *udf_arg, List<Item> &list) :Item_sum_num() {} - Item_sum_udf_str(THD *thd, Item_sum_udf_str &item) + Item_sum_udf_str(THD *thd, Item_sum_udf_str *item) :Item_sum_num(thd, item) {} - ~Item_sum_udf_str() {} String *val_str(String *) { null_value=1; return 0; } double val() { null_value=1; return 0.0; } longlong val_int() { null_value=1; return 0; } @@ -707,33 +704,35 @@ class Item_func_group_concat : public Item_sum Item_func_group_concat(bool is_distinct,List<Item> *is_select, SQL_LIST *is_order,String *is_separator); - Item_func_group_concat(THD *thd, Item_func_group_concat &item) + Item_func_group_concat(THD *thd, Item_func_group_concat *item) :Item_sum(thd, item),item_thd(thd), - tmp_table_param(item.tmp_table_param), - max_elements_in_tree(item.max_elements_in_tree), - warning(item.warning), - warning_available(item.warning_available), - key_length(item.key_length), - rec_offset(item.rec_offset), - tree_mode(item.tree_mode), - distinct(item.distinct), - warning_for_row(item.warning_for_row), - separator(item.separator), - tree(item.tree), - table(item.table), - order(item.order), - tables_list(item.tables_list), - group_concat_max_len(item.group_concat_max_len), - show_elements(item.show_elements), - arg_count_order(item.arg_count_order), - arg_count_field(item.arg_count_field), - arg_show_fields(item.arg_show_fields), - count_cut_values(item.count_cut_values), - original(&item) + tmp_table_param(item->tmp_table_param), + max_elements_in_tree(item->max_elements_in_tree), + warning(item->warning), + warning_available(item->warning_available), + key_length(item->key_length), + rec_offset(item->rec_offset), + tree_mode(item->tree_mode), + distinct(item->distinct), + warning_for_row(item->warning_for_row), + separator(item->separator), + tree(item->tree), + table(item->table), + order(item->order), + tables_list(item->tables_list), + group_concat_max_len(item->group_concat_max_len), + show_elements(item->show_elements), + arg_count_order(item->arg_count_order), + arg_count_field(item->arg_count_field), + arg_show_fields(item->arg_show_fields), + count_cut_values(item->count_cut_values), + original(item) { - quick_group= item.quick_group; + quick_group= item->quick_group; }; ~Item_func_group_concat(); + void cleanup(); + enum Sumfunctype sum_func () const {return GROUP_CONCAT_FUNC;} const char *func_name() const { return "group_concat"; } enum Type type() const { return SUM_FUNC_ITEM; } diff --git a/sql/item_uniq.h b/sql/item_uniq.h index 5c6f6eefb6b..47f967b52c6 100644 --- a/sql/item_uniq.h +++ b/sql/item_uniq.h @@ -38,7 +38,7 @@ class Item_sum_unique_users :public Item_sum_num public: Item_sum_unique_users(Item *name_arg,int start,int end,Item *item_arg) :Item_sum_num(item_arg) {} - Item_sum_unique_users(THD *thd, Item_sum_unique_users &item) + Item_sum_unique_users(THD *thd, Item_sum_unique_users *item) :Item_sum_num(thd, item) {} double val() { return 0.0; } enum Sumfunctype sum_func () const {return UNIQUE_USERS_FUNC;} @@ -53,7 +53,7 @@ public: } Item *copy_or_same(THD* thd) { - return new Item_sum_unique_users(thd, *this); + return new Item_sum_unique_users(thd, this); } void print(String *str) { str->append("0.0", 3); } }; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 4da5381abf1..d8b65ec81b9 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -760,6 +760,11 @@ uint find_type(TYPELIB *lib, const char *find, uint length, bool part_match); uint check_word(TYPELIB *lib, const char *val, const char *end, const char **end_of_word); +/* sql_parse.cc */ +void free_items(Item *item); +void cleanup_items(Item *item); + + /* External variables */ diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index 8ba25da16ce..330acbff9bd 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -299,3 +299,4 @@ character-set=latin2 "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 0d727addb93..239ed619115 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -293,3 +293,4 @@ character-set=latin1 "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index d3ea3dbfc1c..14569ef7197 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -301,3 +301,4 @@ character-set=latin1 "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index 46e08204cce..a7e0d6f5104 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -290,3 +290,4 @@ character-set=latin1 "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index ba0166dde1e..d3a1d312779 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -295,3 +295,4 @@ character-set=latin7 "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index 8eddb177615..ab9095c14a3 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -290,3 +290,4 @@ character-set=latin1 "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index f9c29d5e77d..1bde525ea41 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -302,3 +302,4 @@ character-set=latin1 "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index 6e5d7020afc..580a67f4dcf 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -290,3 +290,4 @@ character-set=greek "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index 65183f51855..f5054f1a409 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -292,3 +292,4 @@ character-set=latin2 "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index 1b29631fd7a..7697701fc51 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -290,3 +290,4 @@ character-set=latin1 "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index 870843606c4..751e1b908a0 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -292,3 +292,4 @@ character-set=ujis "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index 0b8c7d4fcdf..6b04660f4f5 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -290,3 +290,4 @@ character-set=euckr "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index d7997adbeb8..9aa0253c884 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -292,3 +292,4 @@ character-set=latin1 "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index 2ceb230048d..f8934912049 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -292,3 +292,4 @@ character-set=latin1 "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index 0572567e116..feac0e0714d 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -294,3 +294,4 @@ character-set=latin2 "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index 2cbb6716332..72841711f64 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -291,3 +291,4 @@ character-set=latin1 "MySQL foi inicializado em modo --skip-name-resolve. Você necesita reincializá-lo sem esta opção para este grant funcionar", "Motor de tabela desconhecido '%s'", "'%s' é desatualizado. Use '%s' em seu lugar.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 853df2f8e9a..c0f9225ec6b 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -294,3 +294,4 @@ character-set=latin2 "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index 4f0672bec34..937c5d59da3 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -292,3 +292,4 @@ character-set=koi8r "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"ôÁÂÌÉÃÁ %-.100s × %s ÎÅ ÍÏÖÅÔ ÉÚÍÅÎÑÔÓÑ.", diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index db3f356afcf..47b8dd41064 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -285,3 +285,4 @@ character-set=cp1250 "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index 1b0f828a52e..2679666ebd6 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -298,3 +298,4 @@ character-set=latin2 "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index fe0775a5f34..29e0299bc84 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -292,3 +292,4 @@ character-set=latin1 "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 6ede739c4f9..7835841fcd2 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -290,3 +290,4 @@ character-set=latin1 "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"The target table %-.100s of the %s is not updatable.", diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index 7f81be6586c..5e9b44439ba 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -295,3 +295,4 @@ character-set=koi8u "MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", "Unknown table engine '%s'", "'%s' is deprecated. Use '%s' instead.", +"ôÁÂÌÉÃÑ %-.100s Õ %s ÎÅ ÍÏÖÅ ÏÎÏ×ÌÀ×ÁÔÉÓØ.", diff --git a/sql/sql_class.h b/sql/sql_class.h index 5390e8a4ac4..7971137d848 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -624,6 +624,19 @@ public: and are still in use by this thread */ TABLE *open_tables,*temporary_tables, *handler_tables, *derived_tables; + /* + During a MySQL session, one can lock tables in two modes: automatic + or manual. In automatic mode all necessary tables are locked just before + statement execution, and all acquired locks are stored in 'lock' + member. Unlocking takes place automatically as well, when the + statement ends. + Manual mode comes into play when a user issues a 'LOCK TABLES' + statement. In this mode the user can only use the locked tables. + Trying to use any other tables will give an error. The locked tables are + stored in 'locked_tables' member. Manual locking is described in + the 'LOCK_TABLES' chapter of the MySQL manual. + See also lock_tables() for details. + */ MYSQL_LOCK *lock; /* Current locks */ MYSQL_LOCK *locked_tables; /* Tables locked with LOCK */ /* diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index de75ed301e5..cbf091069d6 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1109,7 +1109,7 @@ end: void free_items(Item *item) { for (; item ; item=item->next) - delete item; + item->delete_self(); } /* This works because items are allocated with sql_alloc() */ @@ -2665,15 +2665,29 @@ mysql_execute_command(THD *thd) table_count++; /* All tables in aux_tables must be found in FROM PART */ TABLE_LIST *walk; - for (walk=(TABLE_LIST*) tables ; walk ; walk=walk->next) + for (walk= (TABLE_LIST*) tables; walk; walk= walk->next) { - if (!strcmp(auxi->real_name,walk->real_name) && - !strcmp(walk->db,auxi->db)) + if (!strcmp(auxi->real_name, walk->alias) && + !strcmp(walk->db, auxi->db)) break; } if (!walk) { - net_printf(thd,ER_NONUNIQ_TABLE,auxi->real_name); + if (lex->derived_tables) + { + // are we trying to delete derived table? + for (walk= (TABLE_LIST*) tables; walk; walk= walk->next) + { + if (!strcmp(auxi->real_name,walk->alias) && + walk->derived) + { + net_printf(thd, ER_NON_UPDATABLE_TABLE, + auxi->real_name, "DELETE"); + goto error; + } + } + } + net_printf(thd, ER_NONUNIQ_TABLE, auxi->real_name); goto error; } walk->lock_type= auxi->lock_type; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 0a565c00ba7..de0d0c8aca8 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -756,7 +756,8 @@ static bool mysql_test_select_fields(Prepared_statement *stmt, JOIN *join= new JOIN(thd, fields, select_options, result); thd->used_tables= 0; // Updated by setup_fields - if (join->prepare(&select_lex->ref_pointer_array, tables, + if (join->prepare(&select_lex->ref_pointer_array, + (TABLE_LIST*)select_lex->get_table_list(), wild_num, conds, og_num, order, group, having, proc, select_lex, unit)) DBUG_RETURN(1); @@ -925,6 +926,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length) sl->prep_where= sl->where; } + cleanup_items(thd->free_list); stmt->set_statement(thd); thd->set_statement(&thd->stmt_backup); @@ -975,14 +977,10 @@ void mysql_stmt_execute(THD *thd, char *packet) DBUG_VOID_RETURN; } - /* - XXX: while thd->query_id is incremented for each command, stmt->query_id - holds query_id of prepare stage. Keeping old query_id seems to be more - natural, but differs from the way prepared statements work in 4.1: - */ - /* stmt->query_id= thd->query_id; */ + stmt->query_id= thd->query_id; thd->stmt_backup.set_statement(thd); thd->set_statement(stmt); + thd->free_list= 0; /* To make sure that all runtime data is stored in its own memory root and @@ -1006,6 +1004,11 @@ void mysql_stmt_execute(THD *thd, char *packet) if (sl->prep_where) sl->where= sl->prep_where->copy_andor_structure(thd); DBUG_ASSERT(sl->join == 0); + ORDER *order; + for (order=(ORDER *)sl->group_list.first ; order ; order=order->next) + order->item= (Item **)(order+1); + for (order=(ORDER *)sl->order_list.first ; order ; order=order->next) + order->item= (Item **)(order+1); } /* @@ -1042,6 +1045,8 @@ void mysql_stmt_execute(THD *thd, char *packet) if (!(specialflag & SPECIAL_NO_PRIOR)) my_pthread_setprio(pthread_self(), WAIT_PRIOR); + free_items(thd->free_list); + cleanup_items(stmt->free_list); free_root(&thd->mem_root, MYF(0)); thd->set_statement(&thd->stmt_backup); DBUG_VOID_RETURN; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 5c632e686db..e4f7214ad00 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8283,7 +8283,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, if (pos->type() == Item::FIELD_ITEM) { Item_field *item; - if (!(item= new Item_field(thd, *((Item_field*) pos)))) + if (!(item= new Item_field(thd, ((Item_field*) pos)))) goto err; pos= item; if (item->field->flags & BLOB_FLAG) diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 9fc8d482bfa..8ee00f2bca6 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -434,13 +434,36 @@ int mysql_multi_update(THD *thd, fix_tables_pointers(thd->lex->all_selects_list); select_lex->select_limit= HA_POS_ERROR; + + table_map item_tables= 0, derived_tables= 0; + if (thd->lex->derived_tables) + { + // Assign table map values to check updatability of derived tables + uint tablenr=0; + for (TABLE_LIST *table_list= (TABLE_LIST*) select_lex->table_list.first; + table_list; + table_list= table_list->next, tablenr++) + { + table_list->table->map= (table_map) 1 << tablenr; + } + } if (setup_fields(thd, 0, table_list, *fields, 1, 0, 0)) DBUG_RETURN(-1); + if (thd->lex->derived_tables) + { + // Find tables used in items + List_iterator_fast<Item> it(*fields); + Item *item; + while ((item= it++)) + { + item_tables|= item->used_tables(); + } + } /* Count tables and setup timestamp handling */ - for (tl= select_lex->get_table_list() ; tl ; tl=tl->next) + for (tl= select_lex->get_table_list() ; tl ; tl= tl->next) { TABLE *table= tl->table; if (table->timestamp_field) @@ -450,6 +473,18 @@ int mysql_multi_update(THD *thd, if (table->timestamp_field->query_id != thd->query_id) table->time_stamp= table->timestamp_field->offset() +1; } + if (tl->derived) + derived_tables|= table->map; + } + if (thd->lex->derived_tables && (item_tables & derived_tables)) + { + // find derived table which cause error + for (tl= select_lex->get_table_list() ; tl ; tl= tl->next) + { + if (tl->derived && (item_tables & tl->table->map)) + my_printf_error(ER_NON_UPDATABLE_TABLE, ER(ER_NON_UPDATABLE_TABLE), + MYF(0), tl->alias, "UPDATE"); + } } if (!(result=new multi_update(thd, table_list, fields, values, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index ab95ba312d8..5ab53a1b934 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3155,13 +3155,6 @@ join_table: | '(' SELECT_SYM select_derived ')' opt_table_alias { LEX *lex=Lex; - if (lex->sql_command == SQLCOM_UPDATE && - &lex->select_lex == lex->current_select->outer_select()) - { - send_error(lex->thd, ER_SYNTAX_ERROR); - YYABORT; - } - SELECT_LEX_UNIT *unit= lex->current_select->master_unit(); lex->current_select= unit->outer_select(); if (!($$= lex->current_select-> @@ -3838,6 +3831,13 @@ update: Select->set_lock_for_tables($3); if (lex->select_lex.table_list.elements > 1) lex->sql_command= SQLCOM_UPDATE_MULTI; + else if (lex->select_lex.get_table_list()->derived) + { + /* it is single table update and it is update of derived table */ + net_printf(lex->thd, ER_NON_UPDATABLE_TABLE, + lex->select_lex.get_table_list()->alias, "UPDATE"); + YYABORT; + } } ; @@ -4486,7 +4486,7 @@ simple_ident: $$= (sel->parsing_place != SELECT_LEX_NODE::IN_HAVING || sel->get_in_sum_expr() > 0) ? (Item*) new Item_field(NullS,NullS,$1.str) : - (Item*) new Item_ref(NullS,NullS,$1.str); + (Item*) new Item_ref(0,0, NullS,NullS,$1.str); } | ident '.' ident { @@ -4502,7 +4502,7 @@ simple_ident: $$= (sel->parsing_place != SELECT_LEX_NODE::IN_HAVING || sel->get_in_sum_expr() > 0) ? (Item*) new Item_field(NullS,$1.str,$3.str) : - (Item*) new Item_ref(NullS,$1.str,$3.str); + (Item*) new Item_ref(0,0,NullS,$1.str,$3.str); } | '.' ident '.' ident { @@ -4518,7 +4518,7 @@ simple_ident: $$= (sel->parsing_place != SELECT_LEX_NODE::IN_HAVING || sel->get_in_sum_expr() > 0) ? (Item*) new Item_field(NullS,$2.str,$4.str) : - (Item*) new Item_ref(NullS,$2.str,$4.str); + (Item*) new Item_ref(0,0,NullS,$2.str,$4.str); } | ident '.' ident '.' ident { @@ -4536,8 +4536,8 @@ simple_ident: (Item*) new Item_field((YYTHD->client_capabilities & CLIENT_NO_SCHEMA ? NullS : $1.str), $3.str, $5.str) : - (Item*) new Item_ref((YYTHD->client_capabilities & - CLIENT_NO_SCHEMA ? NullS : $1.str), + (Item*) new Item_ref(0,0,(YYTHD->client_capabilities & + CLIENT_NO_SCHEMA ? NullS : $1.str), $3.str, $5.str); }; |