Skip to content

Commit

Permalink
Remove not used mem_root argument from build_clone(), get_copy() and …
Browse files Browse the repository at this point in the history
…get_item_copy()

TODO:
- Make get_thd_memroot() inline
  - To do this, we need to reduce dependence of include files, especially
    so that sql_class.h is not depending in item.h
  • Loading branch information
montywi committed Nov 23, 2017
1 parent e44107c commit 166056f
Show file tree
Hide file tree
Showing 22 changed files with 851 additions and 849 deletions.
38 changes: 19 additions & 19 deletions sql/item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ inline void set_max_sum_func_level(THD *thd, SELECT_LEX *select)
select->nest_level - 1);
}


MEM_ROOT *get_thd_memroot(THD *thd)
{
return thd->mem_root;
}

/*****************************************************************************
** Item functions
*****************************************************************************/
Expand Down Expand Up @@ -2700,15 +2706,15 @@ bool Type_std_attributes::agg_item_set_converter(const DTCollation &coll,
0 if an error occured
*/

Item* Item_func_or_sum::build_clone(THD *thd, MEM_ROOT *mem_root)
Item* Item_func_or_sum::build_clone(THD *thd)
{
Item_func_or_sum *copy= (Item_func_or_sum *) get_copy(thd, mem_root);
Item_func_or_sum *copy= (Item_func_or_sum *) get_copy(thd);
if (!copy)
return 0;
if (arg_count > 2)
{
copy->args=
(Item**) alloc_root(mem_root, sizeof(Item*) * arg_count);
(Item**) alloc_root(thd->mem_root, sizeof(Item*) * arg_count);
if (!copy->args)
return 0;
}
Expand All @@ -2718,7 +2724,7 @@ Item* Item_func_or_sum::build_clone(THD *thd, MEM_ROOT *mem_root)

for (uint i= 0; i < arg_count; i++)
{
Item *arg_clone= args[i]->build_clone(thd, mem_root);
Item *arg_clone= args[i]->build_clone(thd);
if (!arg_clone)
return 0;
copy->args[i]= arg_clone;
Expand All @@ -2743,19 +2749,13 @@ Item* Item_func_or_sum::build_clone(THD *thd, MEM_ROOT *mem_root)
0 if an error occured
*/

Item* Item_ref::build_clone(THD *thd, MEM_ROOT *mem_root)
Item* Item_ref::build_clone(THD *thd)
{
Item_ref *copy= (Item_ref *) get_copy(thd, mem_root);
if (!copy)
return 0;
copy->ref=
(Item**) alloc_root(mem_root, sizeof(Item*));
if (!copy->ref)
return 0;
Item *item_clone= (* ref)->build_clone(thd, mem_root);
if (!item_clone)
Item_ref *copy= (Item_ref *) get_copy(thd);
if (!copy ||
!(copy->ref= (Item**) alloc_root(thd->mem_root, sizeof(Item*))) ||
!(*copy->ref= (* ref)->build_clone(thd)))
return 0;
*copy->ref= item_clone;
return copy;
}

Expand Down Expand Up @@ -7342,7 +7342,7 @@ Item *Item_field::derived_field_transformer_for_where(THD *thd, uchar *arg)
st_select_lex *sel= (st_select_lex *)arg;
Item *producing_item= find_producing_item(this, sel);
if (producing_item)
return producing_item->build_clone(thd, thd->mem_root);
return producing_item->build_clone(thd);
return this;
}

Expand All @@ -7354,7 +7354,7 @@ Item *Item_direct_view_ref::derived_field_transformer_for_where(THD *thd,
st_select_lex *sel= (st_select_lex *)arg;
Item *producing_item= find_producing_item(this, sel);
DBUG_ASSERT (producing_item != NULL);
return producing_item->build_clone(thd, thd->mem_root);
return producing_item->build_clone(thd);
}
return this;
}
Expand Down Expand Up @@ -7400,7 +7400,7 @@ Item *Item_field::derived_grouping_field_transformer_for_where(THD *thd,
st_select_lex *sel= (st_select_lex *)arg;
Grouping_tmp_field *gr_field= find_matching_grouping_field(this, sel);
if (gr_field)
return gr_field->producing_item->build_clone(thd, thd->mem_root);
return gr_field->producing_item->build_clone(thd);
return this;
}

Expand All @@ -7413,7 +7413,7 @@ Item_direct_view_ref::derived_grouping_field_transformer_for_where(THD *thd,
return this;
st_select_lex *sel= (st_select_lex *)arg;
Grouping_tmp_field *gr_field= find_matching_grouping_field(this, sel);
return gr_field->producing_item->build_clone(thd, thd->mem_root);
return gr_field->producing_item->build_clone(thd);
}

void Item_field::print(String *str, enum_query_type query_type)
Expand Down
Loading

0 comments on commit 166056f

Please sign in to comment.