Commit 234c80b6 authored by konstantin@mysql.com's avatar konstantin@mysql.com

Deployment of centralized Item change registry, step 2: Item_ref

doesn't need to have it's own recovery mechanism.
parent b0154e21
......@@ -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)
......
......@@ -237,7 +237,8 @@ class Item {
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 @@ class Item_ref :public Item_ident
}
Item *real_item() { return *ref; }
void print(String *str);
void cleanup();
};
class Item_in_subselect;
......@@ -856,7 +849,7 @@ class Item_ref_null_helper: public Item_ref
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);
......
......@@ -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();
......
......@@ -931,7 +931,7 @@ class Item_cond :public Item_bool_func
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);
......
......@@ -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);
}
}
}
......
......@@ -121,7 +121,7 @@ class Item_func :public Item_result_field
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);
......
......@@ -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);
}
}
}
......
......@@ -57,7 +57,7 @@ class Item_row: public Item
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; }
......
......@@ -635,20 +635,20 @@ String *Item_func_concat_ws::val_str(String *str)
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);
}
......
......@@ -105,7 +105,7 @@ class Item_func_concat_ws :public Item_str_func
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 @@ class Item_func_make_set :public Item_str_func
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"; }
......
......@@ -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);
......
......@@ -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));
......
......@@ -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
......
......@@ -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);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment