diff options
author | unknown <konstantin@mysql.com> | 2004-10-08 19:13:09 +0400 |
---|---|---|
committer | unknown <konstantin@mysql.com> | 2004-10-08 19:13:09 +0400 |
commit | 166d19e9638595cd56cdfb1d65dbebdd64e6013d (patch) | |
tree | 340f7d7161a03919e35c9d1d393b1ee8b23a5fbf /sql | |
parent | c428135ec8550b62a58ac061733c6c31c277a651 (diff) | |
download | mariadb-git-166d19e9638595cd56cdfb1d65dbebdd64e6013d.tar.gz |
Deployment of centralized Item change registry, step 2: Item_ref
doesn't need to have it's own recovery mechanism.
sql/item.cc:
Deployment of centralized Item change registry, step 2: Item_ref
doesn't need to have it's own recovery mechanism, so it was simplified.
sql/item.h:
Deployment of centralized Item change registry, step 2: Item_ref
doesn't need to have it's own recovery mechanism, so it was simplified.
sql/item_cmpfunc.cc:
- Item::split_sum_func now requires THD
- use THD::register_item_tree_change
sql/item_cmpfunc.h:
- Item::split_sum_func now requires THD
sql/item_func.cc:
- Item::split_sum_func now requires THD
- use THD::register_item_tree_change
sql/item_func.h:
- Item::split_sum_func now requires THD
sql/item_row.cc:
- Item::split_sum_func now requires THD
- use THD::register_item_tree_change
sql/item_row.h:
- Item::split_sum_func now requires THD
sql/item_strfunc.cc:
- Item::split_sum_func now requires THD
- use THD::register_item_tree_change to register changes in the item
tree
sql/item_strfunc.h:
- Item::split_sum_func now requires THD
sql/item_subselect.cc:
- use updated Item_ref constructor
sql/sql_base.cc:
- Item::split_sum_func now requires THD
sql/sql_select.cc:
- Item::split_sum_func now requires THD
sql/sql_yacc.yy:
- use updated Item_ref constructor
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.cc | 17 | ||||
-rw-r--r-- | sql/item.h | 27 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 9 | ||||
-rw-r--r-- | sql/item_cmpfunc.h | 2 | ||||
-rw-r--r-- | sql/item_func.cc | 8 | ||||
-rw-r--r-- | sql/item_func.h | 2 | ||||
-rw-r--r-- | sql/item_row.cc | 8 | ||||
-rw-r--r-- | sql/item_row.h | 2 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 19 | ||||
-rw-r--r-- | sql/item_strfunc.h | 4 | ||||
-rw-r--r-- | sql/item_subselect.cc | 5 | ||||
-rw-r--r-- | sql/sql_base.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 2 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 10 |
14 files changed, 51 insertions, 66 deletions
diff --git a/sql/item.cc b/sql/item.cc index 1c4bfbe2c77..564bc72927c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1334,7 +1334,6 @@ 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, - 0, (char *)table_name, (char *)field_name); thd->register_item_tree_change(ref, this, &thd->mem_root); @@ -1357,10 +1356,8 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) { Item_ref *rf; thd->register_item_tree_change(ref, *ref, &thd->mem_root); - *ref= rf= new Item_ref(ref, 0, - (where->db[0]?where->db:0), - (char *)where->alias, - (char *)field_name); + *ref= rf= new Item_ref((where->db[0] ? where->db : 0), + (char*) where->alias, (char*) field_name); if (!rf) return 1; /* @@ -2061,16 +2058,6 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) } -void Item_ref::cleanup() -{ - DBUG_ENTER("Item_ref::cleanup"); - Item_ident::cleanup(); - if (hook_ptr) - *hook_ptr= orig_item; - DBUG_VOID_RETURN; -} - - void Item_ref::print(String *str) { if (ref && *ref) diff --git a/sql/item.h b/sql/item.h index 6a22b57ee8e..589edb88565 100644 --- a/sql/item.h +++ b/sql/item.h @@ -237,7 +237,8 @@ public: virtual void print(String *str_arg) { str_arg->append(full_name()); } void print_item_w_name(String *); virtual void update_used_tables() {} - virtual void split_sum_func(Item **ref_pointer_array, List<Item> &fields) {} + virtual void split_sum_func(THD *thd, Item **ref_pointer_array, + List<Item> &fields) {} virtual bool get_date(TIME *ltime,uint fuzzydate); virtual bool get_time(TIME *ltime); virtual bool get_date_result(TIME *ltime,uint fuzzydate) @@ -781,20 +782,13 @@ class Item_ref :public Item_ident public: Field *result_field; /* Save result here */ Item **ref; - 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 **hook) - :Item_ident(thd, item), ref(item->ref), - hook_ptr(hook), orig_item(hook ? *hook : 0) {} + 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) {} + /* Constructor need to process subselect with temporary tables (see Item) */ + Item_ref(THD *thd, Item_ref *item) :Item_ident(thd, item), ref(item->ref) {} enum Type type() const { return REF_ITEM; } bool eq(const Item *item, bool binary_cmp) const { return ref && (*ref)->eq(item, binary_cmp); } @@ -845,7 +839,6 @@ public: } Item *real_item() { return *ref; } void print(String *str); - void cleanup(); }; class Item_in_subselect; @@ -856,7 +849,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, NULL, table_name_par, field_name_par), owner(master) {} + Item_ref(item, table_name_par, field_name_par), owner(master) {} double val(); longlong val_int(); String* val_str(String* s); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 28a2761c725..d3b73604f7f 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2018,7 +2018,8 @@ bool Item_cond::walk(Item_processor processor, byte *arg) return Item_func::walk(processor, arg); } -void Item_cond::split_sum_func(Item **ref_pointer_array, List<Item> &fields) +void Item_cond::split_sum_func(THD *thd, Item **ref_pointer_array, + List<Item> &fields) { List_iterator<Item> li(list); Item *item; @@ -2027,13 +2028,15 @@ void Item_cond::split_sum_func(Item **ref_pointer_array, List<Item> &fields) while ((item=li++)) { if (item->with_sum_func && item->type() != SUM_FUNC_ITEM) - item->split_sum_func(ref_pointer_array, fields); + item->split_sum_func(thd, ref_pointer_array, fields); else if (item->used_tables() || item->type() == SUM_FUNC_ITEM) { + Item **ref= li.ref(); uint el= fields.elements; fields.push_front(item); ref_pointer_array[el]= item; - li.replace(new Item_ref(ref_pointer_array + el, li.ref(), 0, item->name)); + thd->register_item_tree_change(ref, *ref, &thd->mem_root); + li.replace(new Item_ref(ref_pointer_array + el, 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 ad2b929c19e..3e98684b6ca 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -931,7 +931,7 @@ public: table_map used_tables() const; void update_used_tables(); void print(String *str); - void split_sum_func(Item **ref_pointer_array, List<Item> &fields); + void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields); friend int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds); void top_level_item() { abort_on_null=1; } void copy_andor_arguments(THD *thd, Item_cond *item); diff --git a/sql/item_func.cc b/sql/item_func.cc index c7cd9d26974..2a3633bf02b 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -257,20 +257,22 @@ bool Item_func::walk (Item_processor processor, byte *argument) return (this->*processor)(argument); } -void Item_func::split_sum_func(Item **ref_pointer_array, List<Item> &fields) +void Item_func::split_sum_func(THD *thd, Item **ref_pointer_array, + List<Item> &fields) { Item **arg, **arg_end; for (arg= args, arg_end= args+arg_count; arg != arg_end ; arg++) { Item *item=* arg; if (item->with_sum_func && item->type() != SUM_FUNC_ITEM) - item->split_sum_func(ref_pointer_array, fields); + item->split_sum_func(thd, ref_pointer_array, fields); else if (item->used_tables() || item->type() == SUM_FUNC_ITEM) { uint el= fields.elements; fields.push_front(item); ref_pointer_array[el]= item; - *arg= new Item_ref(ref_pointer_array + el, arg, 0, item->name); + thd->register_item_tree_change(arg, *arg, &thd->mem_root); + *arg= new Item_ref(ref_pointer_array + el, 0, item->name); } } } diff --git a/sql/item_func.h b/sql/item_func.h index 836ed27ee46..4889ca78a77 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -121,7 +121,7 @@ public: void set_arguments(List<Item> &list); inline uint argument_count() const { return arg_count; } inline void remove_arguments() { arg_count=0; } - virtual void split_sum_func(Item **ref_pointer_array, List<Item> &fields); + void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields); void print(String *str); void print_op(String *str); void print_args(String *str, uint from); diff --git a/sql/item_row.cc b/sql/item_row.cc index f6623e80734..b746029947f 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -84,19 +84,21 @@ bool Item_row::fix_fields(THD *thd, TABLE_LIST *tabl, Item **ref) return 0; } -void Item_row::split_sum_func(Item **ref_pointer_array, List<Item> &fields) +void Item_row::split_sum_func(THD *thd, Item **ref_pointer_array, + List<Item> &fields) { Item **arg, **arg_end; for (arg= items, arg_end= items+arg_count; arg != arg_end ; arg++) { if ((*arg)->with_sum_func && (*arg)->type() != SUM_FUNC_ITEM) - (*arg)->split_sum_func(ref_pointer_array, fields); + (*arg)->split_sum_func(thd, ref_pointer_array, fields); else if ((*arg)->used_tables() || (*arg)->type() == SUM_FUNC_ITEM) { uint el= fields.elements; fields.push_front(*arg); ref_pointer_array[el]= *arg; - *arg= new Item_ref(ref_pointer_array + el, arg, 0, (*arg)->name); + thd->register_item_tree_change(arg, *arg, &thd->mem_root); + *arg= new Item_ref(ref_pointer_array + el, 0, (*arg)->name); } } } diff --git a/sql/item_row.h b/sql/item_row.h index f87b4f66e80..39bc4513e1e 100644 --- a/sql/item_row.h +++ b/sql/item_row.h @@ -57,7 +57,7 @@ public: return 0; }; bool fix_fields(THD *thd, TABLE_LIST *tables, Item **ref); - void split_sum_func(Item **ref_pointer_array, List<Item> &fields); + void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields); table_map used_tables() const { return used_tables_cache; }; bool const_item() const { return const_item_cache; }; enum Item_result result_type() const { return ROW_RESULT; } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 78acaafc486..843177a850f 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -635,20 +635,20 @@ null: return 0; } -void Item_func_concat_ws::split_sum_func(Item **ref_pointer_array, +void Item_func_concat_ws::split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields) { if (separator->with_sum_func && separator->type() != SUM_FUNC_ITEM) - separator->split_sum_func(ref_pointer_array, fields); + separator->split_sum_func(thd, ref_pointer_array, fields); else if (separator->used_tables() || separator->type() == SUM_FUNC_ITEM) { uint el= fields.elements; fields.push_front(separator); ref_pointer_array[el]= separator; - separator= new Item_ref(ref_pointer_array + el, - &separator, 0, separator->name); + thd->register_item_tree_change(&separator, separator, &thd->mem_root); + separator= new Item_ref(ref_pointer_array + el, 0, separator->name); } - Item_str_func::split_sum_func(ref_pointer_array, fields); + Item_str_func::split_sum_func(thd, ref_pointer_array, fields); } void Item_func_concat_ws::fix_length_and_dec() @@ -1771,19 +1771,20 @@ String *Item_func_elt::val_str(String *str) } -void Item_func_make_set::split_sum_func(Item **ref_pointer_array, +void Item_func_make_set::split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields) { if (item->with_sum_func && item->type() != SUM_FUNC_ITEM) - item->split_sum_func(ref_pointer_array, fields); + item->split_sum_func(thd, ref_pointer_array, fields); else if (item->used_tables() || item->type() == SUM_FUNC_ITEM) { uint el= fields.elements; fields.push_front(item); ref_pointer_array[el]= item; - item= new Item_ref(ref_pointer_array + el, &item, 0, item->name); + thd->register_item_tree_change(&item, item, &thd->mem_root); + item= new Item_ref(ref_pointer_array + el, 0, item->name); } - Item_str_func::split_sum_func(ref_pointer_array, fields); + Item_str_func::split_sum_func(thd, ref_pointer_array, fields); } diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 08123370bc6..77c1caec9fc 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -105,7 +105,7 @@ public: separator->check_cols(1) || Item_func::fix_fields(thd, tlist, ref)); } - void split_sum_func(Item **ref_pointer_array, List<Item> &fields); + void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields); const char *func_name() const { return "concat_ws"; } bool walk(Item_processor processor, byte *arg) { @@ -418,7 +418,7 @@ public: item->check_cols(1) || Item_func::fix_fields(thd, tlist, ref)); } - void split_sum_func(Item **ref_pointer_array, List<Item> &fields); + void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields); void fix_length_and_dec(); void update_used_tables(); const char *func_name() const { return "make_set"; } diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index bb2bb6319a9..c877b87def6 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -770,7 +770,6 @@ Item_in_subselect::single_value_transformer(JOIN *join, we can use same item for all selects. */ expr= new Item_ref((Item**)optimizer->get_cache(), - NULL, (char *)"<no matter>", (char *)in_left_expr_name); @@ -966,9 +965,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) (char *) "<no matter>", (char *) "<list ref>"); func= - eq_creator.create(new Item_ref((*optimizer->get_cache())-> - addr(i), - NULL, + eq_creator.create(new Item_ref((*optimizer->get_cache())->addr(i), (char *)"<no matter>", (char *)in_left_expr_name), func); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 3c25d01ced0..31b2ab9ea89 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2384,7 +2384,7 @@ int setup_fields(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, *(ref++)= item; if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM && sum_func_list) - item->split_sum_func(ref_pointer_array, *sum_func_list); + item->split_sum_func(thd, ref_pointer_array, *sum_func_list); thd->used_tables|=item->used_tables(); } DBUG_RETURN(test(thd->net.report_error)); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7a389a906c0..0834f0659da 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -292,7 +292,7 @@ JOIN::prepare(Item ***rref_pointer_array, if (having_fix_rc || thd->net.report_error) DBUG_RETURN(-1); /* purecov: inspected */ if (having->with_sum_func) - having->split_sum_func(ref_pointer_array, all_fields); + having->split_sum_func(thd, ref_pointer_array, all_fields); } // Is it subselect diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 7cf24d3972d..48792962eb9 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4879,7 +4879,7 @@ simple_ident: $$= (sel->parsing_place != IN_HAVING || sel->get_in_sum_expr() > 0) ? (Item*) new Item_field(NullS,NullS,$1.str) : - (Item*) new Item_ref(0,0, NullS,NullS,$1.str); + (Item*) new Item_ref(NullS, NullS, $1.str); } | ident '.' ident { @@ -4895,7 +4895,7 @@ simple_ident: $$= (sel->parsing_place != IN_HAVING || sel->get_in_sum_expr() > 0) ? (Item*) new Item_field(NullS,$1.str,$3.str) : - (Item*) new Item_ref(0,0,NullS,$1.str,$3.str); + (Item*) new Item_ref(NullS, $1.str, $3.str); } | '.' ident '.' ident { @@ -4911,7 +4911,7 @@ simple_ident: $$= (sel->parsing_place != IN_HAVING || sel->get_in_sum_expr() > 0) ? (Item*) new Item_field(NullS,$2.str,$4.str) : - (Item*) new Item_ref(0,0,NullS,$2.str,$4.str); + (Item*) new Item_ref(NullS, $2.str, $4.str); } | ident '.' ident '.' ident { @@ -4929,8 +4929,8 @@ simple_ident: (Item*) new Item_field((YYTHD->client_capabilities & CLIENT_NO_SCHEMA ? NullS : $1.str), $3.str, $5.str) : - (Item*) new Item_ref(0,0,(YYTHD->client_capabilities & - CLIENT_NO_SCHEMA ? NullS : $1.str), + (Item*) new Item_ref((YYTHD->client_capabilities & + CLIENT_NO_SCHEMA ? NullS : $1.str), $3.str, $5.str); }; |