mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-5.0
into sanja.is.com.ua:/home/bell/mysql/bk/work-bug3-5.0 sql/item.cc: Auto merged sql/mysql_priv.h: Auto merged sql/sql_base.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_view.cc: Auto merged sql/table.cc: Auto merged
This commit is contained in:
commit
196862dfd9
20 changed files with 128 additions and 137 deletions
|
@ -1296,7 +1296,7 @@ bool agg_item_charsets(DTCollation &coll, const char *fname,
|
|||
In case we're in statement prepare, create conversion item
|
||||
in its memory: it will be reused on each execute.
|
||||
*/
|
||||
arena= thd->change_arena_if_needed(&backup);
|
||||
arena= thd->activate_stmt_arena_if_needed(&backup);
|
||||
|
||||
for (arg= args, last= args + nargs; arg < last; arg++)
|
||||
{
|
||||
|
@ -1342,7 +1342,7 @@ bool agg_item_charsets(DTCollation &coll, const char *fname,
|
|||
conv->fix_fields(thd, arg);
|
||||
}
|
||||
if (arena)
|
||||
thd->restore_backup_item_arena(arena, &backup);
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -1385,7 +1385,7 @@ Item_field::Item_field(THD *thd, Name_resolution_context *context_arg,
|
|||
structure can go away and pop up again between subsequent executions
|
||||
of a prepared statement).
|
||||
*/
|
||||
if (thd->current_arena->is_stmt_prepare_or_first_sp_execute())
|
||||
if (thd->stmt_arena->is_stmt_prepare_or_first_sp_execute())
|
||||
{
|
||||
if (db_name)
|
||||
orig_db_name= thd->strdup(db_name);
|
||||
|
|
|
@ -671,7 +671,7 @@ bool Item_in_optimizer::fix_left(THD *thd, Item **ref)
|
|||
If it is preparation PS only then we do not know values of parameters =>
|
||||
cant't get there values and do not need that values.
|
||||
*/
|
||||
if (!thd->current_arena->is_stmt_prepare())
|
||||
if (!thd->stmt_arena->is_stmt_prepare())
|
||||
cache->store(args[0]);
|
||||
if (cache->cols() == 1)
|
||||
{
|
||||
|
|
|
@ -1875,7 +1875,7 @@ bool Item_func_rand::fix_fields(THD *thd,Item **ref)
|
|||
if (arg_count)
|
||||
{ // Only use argument once in query
|
||||
/*
|
||||
Allocate rand structure once: we must use thd->current_arena
|
||||
Allocate rand structure once: we must use thd->stmt_arena
|
||||
to create rand in proper mem_root if it's a prepared statement or
|
||||
stored procedure.
|
||||
|
||||
|
@ -1883,7 +1883,7 @@ bool Item_func_rand::fix_fields(THD *thd,Item **ref)
|
|||
as it will be replicated in the query as such.
|
||||
*/
|
||||
if (!rand && !(rand= (struct rand_struct*)
|
||||
thd->current_arena->alloc(sizeof(*rand))))
|
||||
thd->stmt_arena->alloc(sizeof(*rand))))
|
||||
return TRUE;
|
||||
/*
|
||||
PARAM_ITEM is returned if we're in statement prepare and consequently
|
||||
|
|
|
@ -333,7 +333,7 @@ Item_singlerow_subselect::select_transformer(JOIN *join)
|
|||
return RES_OK;
|
||||
|
||||
SELECT_LEX *select_lex= join->select_lex;
|
||||
Query_arena *arena= thd->current_arena;
|
||||
Query_arena *arena= thd->stmt_arena;
|
||||
|
||||
if (!select_lex->master_unit()->first_select()->next_select() &&
|
||||
!select_lex->table_list.elements &&
|
||||
|
@ -1287,10 +1287,10 @@ Item_in_subselect::select_in_like_transformer(JOIN *join, Comp_creator *func)
|
|||
*/
|
||||
if (!optimizer)
|
||||
{
|
||||
arena= thd->change_arena_if_needed(&backup);
|
||||
arena= thd->activate_stmt_arena_if_needed(&backup);
|
||||
result= (!(optimizer= new Item_in_optimizer(left_expr, this)));
|
||||
if (arena)
|
||||
thd->restore_backup_item_arena(arena, &backup);
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
if (result)
|
||||
goto err;
|
||||
}
|
||||
|
@ -1306,7 +1306,7 @@ Item_in_subselect::select_in_like_transformer(JOIN *join, Comp_creator *func)
|
|||
goto err;
|
||||
|
||||
transformed= 1;
|
||||
arena= thd->change_arena_if_needed(&backup);
|
||||
arena= thd->activate_stmt_arena_if_needed(&backup);
|
||||
/*
|
||||
Both transformers call fix_fields() only for Items created inside them,
|
||||
and all that items do not make permanent changes in current item arena
|
||||
|
@ -1322,14 +1322,14 @@ Item_in_subselect::select_in_like_transformer(JOIN *join, Comp_creator *func)
|
|||
if (func != &eq_creator)
|
||||
{
|
||||
if (arena)
|
||||
thd->restore_backup_item_arena(arena, &backup);
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
my_error(ER_OPERAND_COLUMNS, MYF(0), 1);
|
||||
DBUG_RETURN(RES_ERROR);
|
||||
}
|
||||
res= row_value_transformer(join);
|
||||
}
|
||||
if (arena)
|
||||
thd->restore_backup_item_arena(arena, &backup);
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
err:
|
||||
thd->where= save_where;
|
||||
DBUG_RETURN(res);
|
||||
|
|
|
@ -26,7 +26,6 @@ class JOIN;
|
|||
class select_subselect;
|
||||
class subselect_engine;
|
||||
class Item_bool_func2;
|
||||
class Item_arena;
|
||||
|
||||
/* base class for subselects */
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
|
||||
#include <my_tree.h>
|
||||
|
||||
class Item_arena;
|
||||
|
||||
class Item_sum :public Item_result_field
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -408,7 +408,6 @@ enum enum_parsing_place
|
|||
|
||||
struct st_table;
|
||||
class THD;
|
||||
class Item_arena;
|
||||
|
||||
/* Struct to handle simple linked lists */
|
||||
|
||||
|
|
|
@ -1338,7 +1338,7 @@ static void sp_update_stmt_used_routines(THD *thd, LEX *lex, HASH *src)
|
|||
for (uint i=0 ; i < src->records ; i++)
|
||||
{
|
||||
Sroutine_hash_entry *rt= (Sroutine_hash_entry *)hash_element(src, i);
|
||||
(void)add_used_routine(lex, thd->current_arena, &rt->key);
|
||||
(void)add_used_routine(lex, thd->stmt_arena, &rt->key);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1485,7 +1485,7 @@ void
|
|||
sp_cache_routines_and_add_tables_for_triggers(THD *thd, LEX *lex,
|
||||
Table_triggers_list *triggers)
|
||||
{
|
||||
if (add_used_routine(lex, thd->current_arena, &triggers->sroutines_key))
|
||||
if (add_used_routine(lex, thd->stmt_arena, &triggers->sroutines_key))
|
||||
{
|
||||
Sroutine_hash_entry **last_cached_routine_ptr=
|
||||
(Sroutine_hash_entry **)lex->sroutines_list.next;
|
||||
|
|
|
@ -131,12 +131,12 @@ sp_prepare_func_item(THD* thd, Item **it_addr)
|
|||
do \
|
||||
{ \
|
||||
if (condition) \
|
||||
thd->set_n_backup_item_arena(thd->spcont->callers_arena, \
|
||||
backup_arena); \
|
||||
thd->set_n_backup_active_arena(thd->spcont->callers_arena, \
|
||||
backup_arena); \
|
||||
new_command; \
|
||||
if (condition) \
|
||||
thd->restore_backup_item_arena(thd->spcont->callers_arena, \
|
||||
&backup_current_arena); \
|
||||
thd->restore_active_arena(thd->spcont->callers_arena, \
|
||||
backup_arena); \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
|
@ -167,7 +167,7 @@ sp_eval_func_item(THD *thd, Item **it_addr, enum enum_field_types type,
|
|||
DBUG_ENTER("sp_eval_func_item");
|
||||
Item *it= sp_prepare_func_item(thd, it_addr);
|
||||
uint rsize;
|
||||
Query_arena backup_current_arena;
|
||||
Query_arena backup_arena;
|
||||
DBUG_PRINT("info", ("type: %d", type));
|
||||
|
||||
if (!it)
|
||||
|
@ -187,7 +187,7 @@ sp_eval_func_item(THD *thd, Item **it_addr, enum enum_field_types type,
|
|||
}
|
||||
DBUG_PRINT("info", ("INT_RESULT: %d", i));
|
||||
CREATE_ON_CALLERS_ARENA(it= new(reuse, &rsize) Item_int(i),
|
||||
use_callers_arena, &backup_current_arena);
|
||||
use_callers_arena, &backup_arena);
|
||||
break;
|
||||
}
|
||||
case REAL_RESULT:
|
||||
|
@ -210,7 +210,7 @@ sp_eval_func_item(THD *thd, Item **it_addr, enum enum_field_types type,
|
|||
max_length= it->max_length;
|
||||
DBUG_PRINT("info", ("REAL_RESULT: %g", d));
|
||||
CREATE_ON_CALLERS_ARENA(it= new(reuse, &rsize) Item_float(d),
|
||||
use_callers_arena, &backup_current_arena);
|
||||
use_callers_arena, &backup_arena);
|
||||
it->decimals= decimals;
|
||||
it->max_length= max_length;
|
||||
break;
|
||||
|
@ -221,7 +221,7 @@ sp_eval_func_item(THD *thd, Item **it_addr, enum enum_field_types type,
|
|||
if (it->null_value)
|
||||
goto return_null_item;
|
||||
CREATE_ON_CALLERS_ARENA(it= new(reuse, &rsize) Item_decimal(val),
|
||||
use_callers_arena, &backup_current_arena);
|
||||
use_callers_arena, &backup_arena);
|
||||
#ifndef DBUG_OFF
|
||||
{
|
||||
char dbug_buff[DECIMAL_MAX_STR_LENGTH+1];
|
||||
|
@ -246,7 +246,7 @@ sp_eval_func_item(THD *thd, Item **it_addr, enum enum_field_types type,
|
|||
s->length(), s->c_ptr_quick()));
|
||||
CHARSET_INFO *itcs= it->collation.collation;
|
||||
CREATE_ON_CALLERS_ARENA(it= new(reuse, &rsize) Item_string(itcs),
|
||||
use_callers_arena, &backup_current_arena);
|
||||
use_callers_arena, &backup_arena);
|
||||
/*
|
||||
We have to use special constructor and allocate string
|
||||
on system heap here. This is because usual Item_string
|
||||
|
@ -276,7 +276,7 @@ sp_eval_func_item(THD *thd, Item **it_addr, enum enum_field_types type,
|
|||
|
||||
return_null_item:
|
||||
CREATE_ON_CALLERS_ARENA(it= new(reuse, &rsize) Item_null(),
|
||||
use_callers_arena, &backup_current_arena);
|
||||
use_callers_arena, &backup_arena);
|
||||
it->rsize= rsize;
|
||||
|
||||
DBUG_RETURN(it);
|
||||
|
@ -765,7 +765,7 @@ int sp_head::execute(THD *thd)
|
|||
/* per-instruction arena */
|
||||
MEM_ROOT execute_mem_root;
|
||||
Query_arena execute_arena(&execute_mem_root, INITIALIZED_FOR_SP),
|
||||
execute_backup_arena;
|
||||
backup_arena;
|
||||
query_id_t old_query_id;
|
||||
TABLE *old_derived_tables;
|
||||
LEX *old_lex;
|
||||
|
@ -812,7 +812,7 @@ int sp_head::execute(THD *thd)
|
|||
if ((ctx= thd->spcont))
|
||||
ctx->clear_handler();
|
||||
thd->query_error= 0;
|
||||
old_arena= thd->current_arena;
|
||||
old_arena= thd->stmt_arena;
|
||||
|
||||
/*
|
||||
We have to save/restore this info when we are changing call level to
|
||||
|
@ -848,13 +848,13 @@ int sp_head::execute(THD *thd)
|
|||
Switch to per-instruction arena here. We can do it since we cleanup
|
||||
arena after every instruction.
|
||||
*/
|
||||
thd->set_n_backup_item_arena(&execute_arena, &execute_backup_arena);
|
||||
thd->set_n_backup_active_arena(&execute_arena, &backup_arena);
|
||||
|
||||
/*
|
||||
Save callers arena in order to store instruction results and out
|
||||
parameters in it later during sp_eval_func_item()
|
||||
*/
|
||||
thd->spcont->callers_arena= &execute_backup_arena;
|
||||
thd->spcont->callers_arena= &backup_arena;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -869,12 +869,12 @@ int sp_head::execute(THD *thd)
|
|||
if (!thd->in_sub_stmt)
|
||||
thd->set_time(); // Make current_time() et al work
|
||||
/*
|
||||
We have to set thd->current_arena before executing the instruction
|
||||
We have to set thd->stmt_arena before executing the instruction
|
||||
to store in the instruction free_list all new items, created
|
||||
during the first execution (for example expanding of '*' or the
|
||||
items made during other permanent subquery transformations).
|
||||
*/
|
||||
thd->current_arena= i;
|
||||
thd->stmt_arena= i;
|
||||
ret= i->execute(thd, &ip);
|
||||
|
||||
/*
|
||||
|
@ -907,9 +907,9 @@ int sp_head::execute(THD *thd)
|
|||
case SP_HANDLER_NONE:
|
||||
break;
|
||||
case SP_HANDLER_CONTINUE:
|
||||
thd->restore_backup_item_arena(&execute_arena, &execute_backup_arena);
|
||||
thd->restore_active_arena(&execute_arena, &backup_arena);
|
||||
ctx->save_variables(hf);
|
||||
thd->set_n_backup_item_arena(&execute_arena, &execute_backup_arena);
|
||||
thd->set_n_backup_active_arena(&execute_arena, &backup_arena);
|
||||
ctx->push_hstack(ip);
|
||||
// Fall through
|
||||
default:
|
||||
|
@ -924,7 +924,7 @@ int sp_head::execute(THD *thd)
|
|||
}
|
||||
} while (ret == 0 && !thd->killed);
|
||||
|
||||
thd->restore_backup_item_arena(&execute_arena, &execute_backup_arena);
|
||||
thd->restore_active_arena(&execute_arena, &backup_arena);
|
||||
|
||||
|
||||
/* Restore all saved */
|
||||
|
@ -939,7 +939,7 @@ int sp_head::execute(THD *thd)
|
|||
thd->derived_tables= old_derived_tables;
|
||||
thd->variables.sql_mode= save_sql_mode;
|
||||
|
||||
thd->current_arena= old_arena;
|
||||
thd->stmt_arena= old_arena;
|
||||
state= EXECUTED;
|
||||
|
||||
done:
|
||||
|
@ -1532,7 +1532,7 @@ sp_head::restore_thd_mem_root(THD *thd)
|
|||
{
|
||||
DBUG_ENTER("sp_head::restore_thd_mem_root");
|
||||
Item *flist= free_list; // The old list
|
||||
set_item_arena(thd); // Get new free_list and mem_root
|
||||
set_query_arena(thd); // Get new free_list and mem_root
|
||||
state= INITIALIZED_FOR_SP;
|
||||
|
||||
DBUG_PRINT("info", ("mem_root 0x%lx returned from thd mem root 0x%lx",
|
||||
|
@ -2359,20 +2359,18 @@ sp_instr_hreturn::opt_mark(sp_head *sp)
|
|||
int
|
||||
sp_instr_cpush::execute(THD *thd, uint *nextp)
|
||||
{
|
||||
Query_arena backup_current_arena;
|
||||
Query_arena backup_arena;
|
||||
DBUG_ENTER("sp_instr_cpush::execute");
|
||||
|
||||
/*
|
||||
We should create cursors in the callers arena, as
|
||||
it could be (and usually is) used in several instructions.
|
||||
*/
|
||||
thd->set_n_backup_item_arena(thd->spcont->callers_arena,
|
||||
&backup_current_arena);
|
||||
thd->set_n_backup_active_arena(thd->spcont->callers_arena, &backup_arena);
|
||||
|
||||
thd->spcont->push_cursor(&m_lex_keeper, this);
|
||||
|
||||
thd->restore_backup_item_arena(thd->spcont->callers_arena,
|
||||
&backup_current_arena);
|
||||
thd->restore_active_arena(thd->spcont->callers_arena, &backup_arena);
|
||||
|
||||
*nextp= m_ip+1;
|
||||
|
||||
|
@ -2439,19 +2437,19 @@ sp_instr_copen::execute(THD *thd, uint *nextp)
|
|||
}
|
||||
else
|
||||
{
|
||||
Query_arena *old_arena= thd->current_arena;
|
||||
Query_arena *old_arena= thd->stmt_arena;
|
||||
|
||||
/*
|
||||
Get the Query_arena from the cpush instruction, which contains
|
||||
the free_list of the query, so new items (if any) are stored in
|
||||
the right free_list, and we can cleanup after each open.
|
||||
*/
|
||||
thd->current_arena= c->get_instr();
|
||||
thd->stmt_arena= c->get_instr();
|
||||
res= lex_keeper->reset_lex_and_exec_core(thd, nextp, FALSE, this);
|
||||
/* Cleanup the query's items */
|
||||
if (thd->current_arena->free_list)
|
||||
cleanup_items(thd->current_arena->free_list);
|
||||
thd->current_arena= old_arena;
|
||||
if (thd->stmt_arena->free_list)
|
||||
cleanup_items(thd->stmt_arena->free_list);
|
||||
thd->stmt_arena= old_arena;
|
||||
/*
|
||||
Work around the fact that errors in selects are not returned properly
|
||||
(but instead converted into a warning), so if a condition handler
|
||||
|
@ -2526,18 +2524,16 @@ sp_instr_cfetch::execute(THD *thd, uint *nextp)
|
|||
{
|
||||
sp_cursor *c= thd->spcont->get_cursor(m_cursor);
|
||||
int res;
|
||||
Query_arena backup_current_arena;
|
||||
Query_arena backup_arena;
|
||||
DBUG_ENTER("sp_instr_cfetch::execute");
|
||||
|
||||
if (! c)
|
||||
res= -1;
|
||||
else
|
||||
{
|
||||
thd->set_n_backup_item_arena(thd->spcont->callers_arena,
|
||||
&backup_current_arena);
|
||||
thd->set_n_backup_active_arena(thd->spcont->callers_arena, &backup_arena);
|
||||
res= c->fetch(thd, &m_varlist);
|
||||
thd->restore_backup_item_arena(thd->spcont->callers_arena,
|
||||
&backup_current_arena);
|
||||
thd->restore_active_arena(thd->spcont->callers_arena, &backup_arena);
|
||||
}
|
||||
|
||||
*nextp= m_ip+1;
|
||||
|
@ -2790,7 +2786,7 @@ sp_head::add_used_tables_to_table_list(THD *thd,
|
|||
/*
|
||||
Use persistent arena for table list allocation to be PS friendly.
|
||||
*/
|
||||
arena= thd->change_arena_if_needed(&backup);
|
||||
arena= thd->activate_stmt_arena_if_needed(&backup);
|
||||
|
||||
for (i=0 ; i < m_sptabs.records ; i++)
|
||||
{
|
||||
|
@ -2835,7 +2831,7 @@ sp_head::add_used_tables_to_table_list(THD *thd,
|
|||
}
|
||||
|
||||
if (arena)
|
||||
thd->restore_backup_item_arena(arena, &backup);
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
|
||||
DBUG_RETURN(result);
|
||||
}
|
||||
|
|
|
@ -3476,7 +3476,7 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
|
|||
table_ref_1->alias, table_ref_2->alias));
|
||||
|
||||
*found_using_fields= 0;
|
||||
arena= thd->change_arena_if_needed(&backup);
|
||||
arena= thd->activate_stmt_arena_if_needed(&backup);
|
||||
|
||||
/*
|
||||
TABLE_LIST::join_columns could be allocated by the previous call to
|
||||
|
@ -3639,7 +3639,7 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
|
|||
|
||||
err:
|
||||
if (arena)
|
||||
thd->restore_backup_item_arena(arena, &backup);
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
DBUG_RETURN(result);
|
||||
}
|
||||
|
||||
|
@ -3697,7 +3697,7 @@ store_natural_using_join_columns(THD *thd, TABLE_LIST *natural_using_join,
|
|||
|
||||
DBUG_ASSERT(!natural_using_join->join_columns);
|
||||
|
||||
arena= thd->change_arena_if_needed(&backup);
|
||||
arena= thd->activate_stmt_arena_if_needed(&backup);
|
||||
|
||||
if (!(non_join_columns= new List<Natural_join_column>) ||
|
||||
!(natural_using_join->join_columns= new List<Natural_join_column>))
|
||||
|
@ -3782,7 +3782,7 @@ store_natural_using_join_columns(THD *thd, TABLE_LIST *natural_using_join,
|
|||
|
||||
err:
|
||||
if (arena)
|
||||
thd->restore_backup_item_arena(arena, &backup);
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
DBUG_RETURN(result);
|
||||
}
|
||||
|
||||
|
@ -3827,7 +3827,7 @@ store_top_level_join_columns(THD *thd, TABLE_LIST *table_ref,
|
|||
|
||||
DBUG_ENTER("store_top_level_join_columns");
|
||||
|
||||
arena= thd->change_arena_if_needed(&backup);
|
||||
arena= thd->activate_stmt_arena_if_needed(&backup);
|
||||
|
||||
/* Call the procedure recursively for each nested table reference. */
|
||||
if (table_ref->nested_join)
|
||||
|
@ -3940,7 +3940,7 @@ store_top_level_join_columns(THD *thd, TABLE_LIST *table_ref,
|
|||
|
||||
err:
|
||||
if (arena)
|
||||
thd->restore_backup_item_arena(arena, &backup);
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
DBUG_RETURN(result);
|
||||
}
|
||||
|
||||
|
@ -4039,7 +4039,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
|
|||
Don't use arena if we are not in prepared statements or stored procedures
|
||||
For PS/SP we have to use arena to remember the changes
|
||||
*/
|
||||
arena= thd->change_arena_if_needed(&backup);
|
||||
arena= thd->activate_stmt_arena_if_needed(&backup);
|
||||
|
||||
while (wild_num && (item= it++))
|
||||
{
|
||||
|
@ -4067,7 +4067,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
|
|||
any_privileges))
|
||||
{
|
||||
if (arena)
|
||||
thd->restore_backup_item_arena(arena, &backup);
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
if (sum_func_list)
|
||||
|
@ -4089,7 +4089,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
|
|||
select_lex->with_wild= 0;
|
||||
select_lex->item_list= fields;
|
||||
|
||||
thd->restore_backup_item_arena(arena, &backup);
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
@ -4265,15 +4265,15 @@ bool setup_tables(THD *thd, Name_resolution_context *context,
|
|||
if (table_list->ancestor)
|
||||
{
|
||||
DBUG_ASSERT(table_list->view);
|
||||
Query_arena *arena= thd->current_arena, backup;
|
||||
Query_arena *arena= thd->stmt_arena, backup;
|
||||
bool res;
|
||||
if (arena->is_conventional())
|
||||
arena= 0; // For easier test
|
||||
else
|
||||
thd->set_n_backup_item_arena(arena, &backup);
|
||||
thd->set_n_backup_active_arena(arena, &backup);
|
||||
res= table_list->setup_ancestor(thd);
|
||||
if (arena)
|
||||
thd->restore_backup_item_arena(arena, &backup);
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
if (res)
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
@ -4354,7 +4354,7 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
|
|||
bool found;
|
||||
char name_buff[NAME_LEN+1];
|
||||
DBUG_ENTER("insert_fields");
|
||||
DBUG_PRINT("arena", ("current arena: 0x%lx", (ulong)thd->current_arena));
|
||||
DBUG_PRINT("arena", ("stmt arena: 0x%lx", (ulong)thd->stmt_arena));
|
||||
|
||||
if (db_name && lower_case_table_names)
|
||||
{
|
||||
|
@ -4560,7 +4560,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
|
|||
COND **conds)
|
||||
{
|
||||
SELECT_LEX *select_lex= thd->lex->current_select;
|
||||
Query_arena *arena= thd->current_arena, backup;
|
||||
Query_arena *arena= thd->stmt_arena, backup;
|
||||
TABLE_LIST *table= NULL; // For HP compilers
|
||||
/*
|
||||
it_is_update set to TRUE when tables of primary SELECT_LEX (SELECT_LEX
|
||||
|
@ -4634,7 +4634,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
|
|||
}
|
||||
}
|
||||
|
||||
if (!thd->current_arena->is_conventional())
|
||||
if (!thd->stmt_arena->is_conventional())
|
||||
{
|
||||
/*
|
||||
We are in prepared statement preparation code => we should store
|
||||
|
@ -4649,7 +4649,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
|
|||
|
||||
err:
|
||||
if (arena)
|
||||
thd->restore_backup_item_arena(arena, &backup);
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
err_no_arena:
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ THD::THD()
|
|||
in_lock_tables(0), bootstrap(0), derived_tables_processing(FALSE),
|
||||
spcont(NULL)
|
||||
{
|
||||
current_arena= this;
|
||||
stmt_arena= this;
|
||||
host= user= priv_user= db= ip= 0;
|
||||
catalog= (char*)"std"; // the only catalog we have for now
|
||||
host_or_ip= "connecting host";
|
||||
|
@ -794,7 +794,7 @@ struct Item_change_record: public ilink
|
|||
/*
|
||||
Register an item tree tree transformation, performed by the query
|
||||
optimizer. We need a pointer to runtime_memroot because it may be !=
|
||||
thd->mem_root (due to possible set_n_backup_item_arena called for thd).
|
||||
thd->mem_root (due to possible set_n_backup_active_arena called for thd).
|
||||
*/
|
||||
|
||||
void THD::nocheck_register_item_tree_change(Item **place, Item *old_value,
|
||||
|
@ -1602,13 +1602,13 @@ void THD::end_statement()
|
|||
}
|
||||
|
||||
|
||||
void Query_arena::set_n_backup_item_arena(Query_arena *set, Query_arena *backup)
|
||||
void THD::set_n_backup_active_arena(Query_arena *set, Query_arena *backup)
|
||||
{
|
||||
DBUG_ENTER("Query_arena::set_n_backup_item_arena");
|
||||
DBUG_ENTER("THD::set_n_backup_active_arena");
|
||||
DBUG_ASSERT(backup->is_backup_arena == FALSE);
|
||||
|
||||
backup->set_item_arena(this);
|
||||
set_item_arena(set);
|
||||
backup->set_query_arena(this);
|
||||
set_query_arena(set);
|
||||
#ifndef DBUG_OFF
|
||||
backup->is_backup_arena= TRUE;
|
||||
#endif
|
||||
|
@ -1616,19 +1616,19 @@ void Query_arena::set_n_backup_item_arena(Query_arena *set, Query_arena *backup)
|
|||
}
|
||||
|
||||
|
||||
void Query_arena::restore_backup_item_arena(Query_arena *set, Query_arena *backup)
|
||||
void THD::restore_active_arena(Query_arena *set, Query_arena *backup)
|
||||
{
|
||||
DBUG_ENTER("Query_arena::restore_backup_item_arena");
|
||||
DBUG_ENTER("THD::restore_active_arena");
|
||||
DBUG_ASSERT(backup->is_backup_arena);
|
||||
set->set_item_arena(this);
|
||||
set_item_arena(backup);
|
||||
set->set_query_arena(this);
|
||||
set_query_arena(backup);
|
||||
#ifndef DBUG_OFF
|
||||
backup->is_backup_arena= FALSE;
|
||||
#endif
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
void Query_arena::set_item_arena(Query_arena *set)
|
||||
void Query_arena::set_query_arena(Query_arena *set)
|
||||
{
|
||||
mem_root= set->mem_root;
|
||||
free_list= set->free_list;
|
||||
|
|
|
@ -733,9 +733,7 @@ public:
|
|||
return ptr;
|
||||
}
|
||||
|
||||
void set_n_backup_item_arena(Query_arena *set, Query_arena *backup);
|
||||
void restore_backup_item_arena(Query_arena *set, Query_arena *backup);
|
||||
void set_item_arena(Query_arena *set);
|
||||
void set_query_arena(Query_arena *set);
|
||||
|
||||
void free_items();
|
||||
};
|
||||
|
@ -1230,16 +1228,16 @@ public:
|
|||
/*
|
||||
A permanent memory area of the statement. For conventional
|
||||
execution, the parsed tree and execution runtime reside in the same
|
||||
memory root. In this case current_arena points to THD. In case of
|
||||
memory root. In this case stmt_arena points to THD. In case of
|
||||
a prepared statement or a stored procedure statement, thd->mem_root
|
||||
conventionally points to runtime memory, and thd->current_arena
|
||||
conventionally points to runtime memory, and thd->stmt_arena
|
||||
points to the memory of the PS/SP, where the parsed tree of the
|
||||
statement resides. Whenever you need to perform a permanent
|
||||
transformation of a parsed tree, you should allocate new memory in
|
||||
current_arena, to allow correct re-execution of PS/SP.
|
||||
Note: in the parser, current_arena == thd, even for PS/SP.
|
||||
stmt_arena, to allow correct re-execution of PS/SP.
|
||||
Note: in the parser, stmt_arena == thd, even for PS/SP.
|
||||
*/
|
||||
Query_arena *current_arena;
|
||||
Query_arena *stmt_arena;
|
||||
/*
|
||||
next_insert_id is set on SET INSERT_ID= #. This is used as the next
|
||||
generated auto_increment value in handler.cc
|
||||
|
@ -1467,7 +1465,7 @@ public:
|
|||
}
|
||||
inline bool fill_derived_tables()
|
||||
{
|
||||
return !current_arena->is_stmt_prepare() && !lex->only_view_structure();
|
||||
return !stmt_arena->is_stmt_prepare() && !lex->only_view_structure();
|
||||
}
|
||||
inline gptr trans_alloc(unsigned int size)
|
||||
{
|
||||
|
@ -1506,17 +1504,16 @@ public:
|
|||
inline CHARSET_INFO *charset() { return variables.character_set_client; }
|
||||
void update_charset();
|
||||
|
||||
inline Query_arena *change_arena_if_needed(Query_arena *backup)
|
||||
inline Query_arena *activate_stmt_arena_if_needed(Query_arena *backup)
|
||||
{
|
||||
/*
|
||||
use new arena if we are in a prepared statements and we have not
|
||||
already changed to use this arena.
|
||||
Use the persistent arena if we are in a prepared statement or a stored
|
||||
procedure statement and we have not already changed to use this arena.
|
||||
*/
|
||||
if (!current_arena->is_conventional() &&
|
||||
mem_root != current_arena->mem_root)
|
||||
if (!stmt_arena->is_conventional() && mem_root != stmt_arena->mem_root)
|
||||
{
|
||||
set_n_backup_item_arena(current_arena, backup);
|
||||
return current_arena;
|
||||
set_n_backup_active_arena(stmt_arena, backup);
|
||||
return stmt_arena;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1524,7 +1521,7 @@ public:
|
|||
void change_item_tree(Item **place, Item *new_value)
|
||||
{
|
||||
/* TODO: check for OOM condition here */
|
||||
if (!current_arena->is_conventional())
|
||||
if (!stmt_arena->is_conventional())
|
||||
nocheck_register_item_tree_change(place, *place, mem_root);
|
||||
*place= new_value;
|
||||
}
|
||||
|
@ -1556,11 +1553,13 @@ public:
|
|||
}
|
||||
void set_status_var_init();
|
||||
bool is_context_analysis_only()
|
||||
{ return current_arena->is_stmt_prepare() || lex->view_prepare_mode; }
|
||||
{ return stmt_arena->is_stmt_prepare() || lex->view_prepare_mode; }
|
||||
void reset_n_backup_open_tables_state(Open_tables_state *backup);
|
||||
void restore_backup_open_tables_state(Open_tables_state *backup);
|
||||
void reset_sub_statement_state(Sub_statement_state *backup, uint new_state);
|
||||
void restore_sub_statement_state(Sub_statement_state *backup);
|
||||
void set_n_backup_active_arena(Query_arena *set, Query_arena *backup);
|
||||
void restore_active_arena(Query_arena *set, Query_arena *backup);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1504,7 +1504,7 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
|
|||
We have to create array in prepared statement memory if it is
|
||||
prepared statement
|
||||
*/
|
||||
Query_arena *arena= thd->current_arena;
|
||||
Query_arena *arena= thd->stmt_arena;
|
||||
return (ref_pointer_array=
|
||||
(Item **)arena->alloc(sizeof(Item*) *
|
||||
(item_list.elements +
|
||||
|
@ -1826,7 +1826,7 @@ void st_select_lex_unit::set_limit(SELECT_LEX *sl)
|
|||
{
|
||||
ha_rows select_limit_val;
|
||||
|
||||
DBUG_ASSERT(! thd->current_arena->is_stmt_prepare());
|
||||
DBUG_ASSERT(! thd->stmt_arena->is_stmt_prepare());
|
||||
select_limit_val= (ha_rows)(sl->select_limit ? sl->select_limit->val_uint() :
|
||||
HA_POS_ERROR);
|
||||
offset_limit_cnt= (ha_rows)(sl->offset_limit ? sl->offset_limit->val_uint() :
|
||||
|
@ -2038,7 +2038,7 @@ void st_lex::cleanup_after_one_table_open()
|
|||
|
||||
void st_select_lex::fix_prepare_information(THD *thd, Item **conds)
|
||||
{
|
||||
if (!thd->current_arena->is_conventional() && first_execution)
|
||||
if (!thd->stmt_arena->is_conventional() && first_execution)
|
||||
{
|
||||
first_execution= 0;
|
||||
if (*conds)
|
||||
|
|
|
@ -5279,7 +5279,7 @@ mysql_new_select(LEX *lex, bool move_down)
|
|||
it's a constant one. The flag is switched off in the end of
|
||||
mysql_stmt_prepare.
|
||||
*/
|
||||
if (thd->current_arena->is_stmt_prepare())
|
||||
if (thd->stmt_arena->is_stmt_prepare())
|
||||
select_lex->uncacheable|= UNCACHEABLE_PREPARE;
|
||||
if (move_down)
|
||||
{
|
||||
|
@ -6085,7 +6085,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
|||
ptr->db= empty_c_string;
|
||||
ptr->db_length= 0;
|
||||
}
|
||||
if (thd->current_arena->is_stmt_prepare_or_first_sp_execute())
|
||||
if (thd->stmt_arena->is_stmt_prepare_or_first_sp_execute())
|
||||
ptr->db= thd->strdup(ptr->db);
|
||||
|
||||
ptr->alias= alias_str;
|
||||
|
@ -7305,7 +7305,7 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables,
|
|||
against the opened tables to ensure we don't use a table that is part
|
||||
of the view (which can only be done after the table has been opened).
|
||||
*/
|
||||
if (thd->current_arena->is_stmt_prepare_or_first_sp_execute())
|
||||
if (thd->stmt_arena->is_stmt_prepare_or_first_sp_execute())
|
||||
{
|
||||
/*
|
||||
For temporary tables we don't have to check if the created table exists
|
||||
|
|
|
@ -1767,12 +1767,12 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
|
|||
both of backup_statement() and backup_item_area() here.
|
||||
*/
|
||||
thd->set_n_backup_statement(stmt, &stmt_backup);
|
||||
thd->set_n_backup_item_arena(stmt, &stmt_backup);
|
||||
thd->set_n_backup_active_arena(stmt, &stmt_backup);
|
||||
|
||||
if (alloc_query(thd, packet, packet_length))
|
||||
{
|
||||
thd->restore_backup_statement(stmt, &stmt_backup);
|
||||
thd->restore_backup_item_arena(stmt, &stmt_backup);
|
||||
thd->restore_active_arena(stmt, &stmt_backup);
|
||||
/* Statement map deletes statement on erase */
|
||||
thd->stmt_map.erase(stmt);
|
||||
DBUG_RETURN(TRUE);
|
||||
|
@ -1780,7 +1780,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
|
|||
|
||||
mysql_log.write(thd, thd->command, "[%lu] %s", stmt->id, packet);
|
||||
|
||||
thd->current_arena= stmt;
|
||||
thd->stmt_arena= stmt;
|
||||
mysql_init_query(thd, (uchar *) thd->query, thd->query_length);
|
||||
/* Reset warnings from previous command */
|
||||
mysql_reset_errors(thd, 0);
|
||||
|
@ -1800,7 +1800,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
|
|||
transformation can be reused on execute, we set again thd->mem_root from
|
||||
stmt->mem_root (see setup_wild for one place where we do that).
|
||||
*/
|
||||
thd->restore_backup_item_arena(stmt, &stmt_backup);
|
||||
thd->restore_active_arena(stmt, &stmt_backup);
|
||||
|
||||
if (!error)
|
||||
error= check_prepared_statement(stmt, test(name));
|
||||
|
@ -1817,7 +1817,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
|
|||
close_thread_tables(thd);
|
||||
cleanup_stmt_and_thd_after_use(stmt, thd);
|
||||
thd->restore_backup_statement(stmt, &stmt_backup);
|
||||
thd->current_arena= thd;
|
||||
thd->stmt_arena= thd;
|
||||
|
||||
if (error)
|
||||
{
|
||||
|
@ -2063,7 +2063,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
|
|||
goto set_params_data_err;
|
||||
#endif
|
||||
thd->set_n_backup_statement(stmt, &stmt_backup);
|
||||
thd->current_arena= stmt;
|
||||
thd->stmt_arena= stmt;
|
||||
reinit_stmt_before_use(thd, stmt->lex);
|
||||
/* From now cursors assume that thd->mem_root is clean */
|
||||
if (expanded_query.length() &&
|
||||
|
@ -2110,7 +2110,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
|
|||
|
||||
thd->set_statement(&stmt_backup);
|
||||
thd->lock_id= &thd->main_lock_id;
|
||||
thd->current_arena= thd;
|
||||
thd->stmt_arena= thd;
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
set_params_data_err:
|
||||
|
@ -2205,7 +2205,7 @@ static void execute_stmt(THD *thd, Prepared_statement *stmt,
|
|||
transformations of the query tree (i.e. negations elimination).
|
||||
This should be done permanently on the parse tree of this statement.
|
||||
*/
|
||||
thd->current_arena= stmt;
|
||||
thd->stmt_arena= stmt;
|
||||
|
||||
if (!(specialflag & SPECIAL_NO_PRIOR))
|
||||
my_pthread_setprio(pthread_self(),QUERY_PRIOR);
|
||||
|
@ -2224,7 +2224,7 @@ static void execute_stmt(THD *thd, Prepared_statement *stmt,
|
|||
close_thread_tables(thd); // to close derived tables
|
||||
cleanup_stmt_and_thd_after_use(stmt, thd);
|
||||
reset_stmt_params(stmt);
|
||||
thd->current_arena= thd;
|
||||
thd->stmt_arena= thd;
|
||||
|
||||
if (stmt->state == Query_arena::PREPARED)
|
||||
stmt->state= Query_arena::EXECUTED;
|
||||
|
@ -2263,7 +2263,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length)
|
|||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
thd->current_arena= stmt;
|
||||
thd->stmt_arena= stmt;
|
||||
thd->set_n_backup_statement(stmt, &stmt_backup);
|
||||
|
||||
if (!(specialflag & SPECIAL_NO_PRIOR))
|
||||
|
@ -2291,7 +2291,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length)
|
|||
}
|
||||
|
||||
thd->restore_backup_statement(stmt, &stmt_backup);
|
||||
thd->current_arena= thd;
|
||||
thd->stmt_arena= thd;
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
|
|
@ -581,11 +581,11 @@ JOIN::optimize()
|
|||
MEMROOT for prepared statements and stored procedures.
|
||||
*/
|
||||
|
||||
Query_arena *arena= thd->current_arena, backup;
|
||||
Query_arena *arena= thd->stmt_arena, backup;
|
||||
if (arena->is_conventional())
|
||||
arena= 0; // For easier test
|
||||
else
|
||||
thd->set_n_backup_item_arena(arena, &backup);
|
||||
thd->set_n_backup_active_arena(arena, &backup);
|
||||
|
||||
sel->first_cond_optimization= 0;
|
||||
|
||||
|
@ -595,7 +595,7 @@ JOIN::optimize()
|
|||
sel->prep_where= conds ? conds->copy_andor_structure(thd) : 0;
|
||||
|
||||
if (arena)
|
||||
thd->restore_backup_item_arena(arena, &backup);
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
}
|
||||
|
||||
conds= optimize_cond(this, conds, join_list, &cond_value);
|
||||
|
@ -1744,7 +1744,7 @@ Cursor::init_from_thd(THD *thd)
|
|||
things that are already allocated in thd->mem_root for Cursor::fetch()
|
||||
*/
|
||||
main_mem_root= *thd->mem_root;
|
||||
state= thd->current_arena->state;
|
||||
state= thd->stmt_arena->state;
|
||||
/* Allocate new memory root for thd */
|
||||
init_sql_alloc(thd->mem_root,
|
||||
thd->variables.query_alloc_block_size,
|
||||
|
@ -1871,7 +1871,7 @@ Cursor::fetch(ulong num_rows)
|
|||
thd->query_id= query_id;
|
||||
thd->change_list= change_list;
|
||||
/* save references to memory, allocated during fetch */
|
||||
thd->set_n_backup_item_arena(this, &backup_arena);
|
||||
thd->set_n_backup_active_arena(this, &backup_arena);
|
||||
|
||||
for (info= ht_info; info->read_view ; info++)
|
||||
(info->ht->set_cursor_read_view)(info->read_view);
|
||||
|
@ -1890,7 +1890,7 @@ Cursor::fetch(ulong num_rows)
|
|||
ha_release_temporary_latches(thd);
|
||||
#endif
|
||||
/* Grab free_list here to correctly free it in close */
|
||||
thd->restore_backup_item_arena(this, &backup_arena);
|
||||
thd->restore_active_arena(this, &backup_arena);
|
||||
|
||||
for (info= ht_info; info->read_view; info++)
|
||||
(info->ht->set_cursor_read_view)(0);
|
||||
|
|
|
@ -3610,7 +3610,7 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
|
|||
}
|
||||
List_iterator_fast<Item> it(sel->item_list);
|
||||
if (!(transl=
|
||||
(Field_translator*)(thd->current_arena->
|
||||
(Field_translator*)(thd->stmt_arena->
|
||||
alloc(sel->item_list.elements *
|
||||
sizeof(Field_translator)))))
|
||||
{
|
||||
|
|
|
@ -287,7 +287,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
|
|||
all collations together for UNION.
|
||||
*/
|
||||
List_iterator_fast<Item> tp(types);
|
||||
Query_arena *arena= thd->current_arena;
|
||||
Query_arena *arena= thd->stmt_arena;
|
||||
Item *type;
|
||||
ulonglong create_options;
|
||||
|
||||
|
@ -332,7 +332,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
|
|||
{
|
||||
Field **field;
|
||||
Query_arena *tmp_arena,backup;
|
||||
tmp_arena= thd->change_arena_if_needed(&backup);
|
||||
tmp_arena= thd->activate_stmt_arena_if_needed(&backup);
|
||||
|
||||
for (field= table->field; *field; field++)
|
||||
{
|
||||
|
@ -340,12 +340,12 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
|
|||
if (!item || item_list.push_back(item))
|
||||
{
|
||||
if (tmp_arena)
|
||||
thd->restore_backup_item_arena(tmp_arena, &backup);
|
||||
thd->restore_active_arena(tmp_arena, &backup);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
if (tmp_arena)
|
||||
thd->restore_backup_item_arena(tmp_arena, &backup);
|
||||
thd->restore_active_arena(tmp_arena, &backup);
|
||||
if (arena->is_stmt_prepare_or_first_sp_execute())
|
||||
{
|
||||
/* prepare fake select to initialize it correctly */
|
||||
|
|
|
@ -700,11 +700,11 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
|
|||
For now we assume that tables will not be changed during PS life (it
|
||||
will be TRUE as far as we make new table cache).
|
||||
*/
|
||||
Query_arena *arena= thd->current_arena, backup;
|
||||
Query_arena *arena= thd->stmt_arena, backup;
|
||||
if (arena->is_conventional())
|
||||
arena= 0;
|
||||
else
|
||||
thd->set_n_backup_item_arena(arena, &backup);
|
||||
thd->set_n_backup_active_arena(arena, &backup);
|
||||
|
||||
/* init timestamp */
|
||||
if (!table->timestamp.str)
|
||||
|
@ -995,13 +995,13 @@ ok:
|
|||
|
||||
ok2:
|
||||
if (arena)
|
||||
thd->restore_backup_item_arena(arena, &backup);
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
thd->lex= old_lex;
|
||||
DBUG_RETURN(0);
|
||||
|
||||
err:
|
||||
if (arena)
|
||||
thd->restore_backup_item_arena(arena, &backup);
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
delete table->view;
|
||||
table->view= 0; // now it is not VIEW placeholder
|
||||
thd->lex= old_lex;
|
||||
|
|
|
@ -1780,7 +1780,7 @@ bool st_table_list::setup_ancestor(THD *thd)
|
|||
/* Create view fields translation table */
|
||||
|
||||
if (!(transl=
|
||||
(Field_translator*)(thd->current_arena->
|
||||
(Field_translator*)(thd->stmt_arena->
|
||||
alloc(select->item_list.elements *
|
||||
sizeof(Field_translator)))))
|
||||
{
|
||||
|
@ -1856,8 +1856,8 @@ bool st_table_list::prep_where(THD *thd, Item **conds,
|
|||
if (!no_where_clause && !where_processed)
|
||||
{
|
||||
TABLE_LIST *tbl= this;
|
||||
Query_arena *arena= thd->current_arena, backup;
|
||||
arena= thd->change_arena_if_needed(&backup); // For easier test
|
||||
Query_arena *arena= thd->stmt_arena, backup;
|
||||
arena= thd->activate_stmt_arena_if_needed(&backup); // For easier test
|
||||
|
||||
/* Go up to join tree and try to find left join */
|
||||
for (; tbl; tbl= tbl->embedding)
|
||||
|
@ -1877,7 +1877,7 @@ bool st_table_list::prep_where(THD *thd, Item **conds,
|
|||
if (tbl == 0)
|
||||
*conds= and_conds(*conds, where);
|
||||
if (arena)
|
||||
thd->restore_backup_item_arena(arena, &backup);
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
where_processed= TRUE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue