Reset thd->lex->current_select for SP
current_select may point to data from old parser states when calling a stored procedure with CALL The failure happens in Item::Item when testing if we are in having. Fixed by explicitely reseting current_select in do_execute_sp() and in sp_rcontext::create(). The later is also needed for stored functions().
This commit is contained in:
parent
f67b8273c0
commit
6b7dcefdc8
@ -61,6 +61,7 @@ sp_rcontext *sp_rcontext::create(THD *thd,
|
|||||||
const sp_pcontext *root_parsing_ctx,
|
const sp_pcontext *root_parsing_ctx,
|
||||||
Field *return_value_fld)
|
Field *return_value_fld)
|
||||||
{
|
{
|
||||||
|
SELECT_LEX *save_current_select;
|
||||||
sp_rcontext *ctx= new (thd->mem_root) sp_rcontext(root_parsing_ctx,
|
sp_rcontext *ctx= new (thd->mem_root) sp_rcontext(root_parsing_ctx,
|
||||||
return_value_fld,
|
return_value_fld,
|
||||||
thd->in_sub_stmt);
|
thd->in_sub_stmt);
|
||||||
@ -68,14 +69,19 @@ sp_rcontext *sp_rcontext::create(THD *thd,
|
|||||||
if (!ctx)
|
if (!ctx)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Reset current_select as it's checked in Item_ident::Item_ident */
|
||||||
|
save_current_select= thd->lex->current_select;
|
||||||
|
thd->lex->current_select= 0;
|
||||||
|
|
||||||
if (ctx->alloc_arrays(thd) ||
|
if (ctx->alloc_arrays(thd) ||
|
||||||
ctx->init_var_table(thd) ||
|
ctx->init_var_table(thd) ||
|
||||||
ctx->init_var_items(thd))
|
ctx->init_var_items(thd))
|
||||||
{
|
{
|
||||||
delete ctx;
|
delete ctx;
|
||||||
return NULL;
|
ctx= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
thd->lex->current_select= save_current_select;
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2876,6 +2876,12 @@ static bool do_execute_sp(THD *thd, sp_head *sp)
|
|||||||
ha_rows select_limit= thd->variables.select_limit;
|
ha_rows select_limit= thd->variables.select_limit;
|
||||||
thd->variables.select_limit= HA_POS_ERROR;
|
thd->variables.select_limit= HA_POS_ERROR;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Reset current_select as it may point to random data as a
|
||||||
|
result of previous parsing.
|
||||||
|
*/
|
||||||
|
thd->lex->current_select= NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
We never write CALL statements into binlog:
|
We never write CALL statements into binlog:
|
||||||
- If the mode is non-prelocked, each statement will be logged
|
- If the mode is non-prelocked, each statement will be logged
|
||||||
|
Loading…
x
Reference in New Issue
Block a user