diff options
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r-- | sql/item_subselect.cc | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index bafca8acf0f..f426f14a25f 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -190,15 +190,16 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref) bool Item_subselect::exec() { int res; - MEM_ROOT *old_root= my_pthread_getspecific_ptr(MEM_ROOT*, THR_MALLOC); - if (&thd->mem_root != old_root) - { - my_pthread_setspecific_ptr(THR_MALLOC, &thd->mem_root); - res= engine->exec(); - my_pthread_setspecific_ptr(THR_MALLOC, old_root); - } - else - res= engine->exec(); + MEM_ROOT *old_root= thd->mem_root; + + /* + As this is execution, all objects should be allocated through the main + mem root + */ + thd->mem_root= &thd->main_mem_root; + res= engine->exec(); + thd->mem_root= old_root; + if (engine_changed) { engine_changed= 0; @@ -661,15 +662,10 @@ Item_in_subselect::single_value_transformer(JOIN *join, } SELECT_LEX *select_lex= join->select_lex; - Item_arena *arena= thd->current_arena, backup; - + Item_arena *arena, backup; + arena= thd->change_arena_if_needed(&backup); thd->where= "scalar IN/ALL/ANY subquery"; - if (arena->is_conventional()) - arena= 0; // For easier test - else - thd->set_n_backup_item_arena(arena, &backup); - /* Check that the right part of the subselect contains no more than one column. E.g. in SELECT 1 IN (SELECT * ..) the right part is (SELECT * ...) @@ -928,11 +924,8 @@ Item_in_subselect::row_value_transformer(JOIN *join) } thd->where= "row IN/ALL/ANY subquery"; - Item_arena *arena= thd->current_arena, backup; - if (arena->is_conventional()) - arena= 0; - else - thd->set_n_backup_item_arena(arena, &backup); + Item_arena *arena, backup; + arena= thd->change_arena_if_needed(&backup); if (select_lex->item_list.elements != left_expr->cols()) { |