mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 05:22:25 +01:00
Fixed BUG#14643: Stored Procedure: Continuing after failed var.
initialization crashes server. Make sure variables are initialized to something (like null) when the default initialization fails and a continue handler is in effect.
This commit is contained in:
parent
60a4b4fb16
commit
718f837410
3 changed files with 100 additions and 0 deletions
|
@ -3617,4 +3617,40 @@ count(*)
|
|||
drop table t3, t4|
|
||||
drop procedure bug14210|
|
||||
set @@session.max_heap_table_size=default|
|
||||
drop procedure if exists bug14643_1|
|
||||
drop procedure if exists bug14643_2|
|
||||
create procedure bug14643_1()
|
||||
begin
|
||||
declare continue handler for sqlexception select 'boo' as 'Handler';
|
||||
begin
|
||||
declare v int default x;
|
||||
if v = 1 then
|
||||
select 1;
|
||||
else
|
||||
select 2;
|
||||
end if;
|
||||
end;
|
||||
end|
|
||||
create procedure bug14643_2()
|
||||
begin
|
||||
declare continue handler for sqlexception select 'boo' as 'Handler';
|
||||
case x
|
||||
when 1 then
|
||||
select 1;
|
||||
else
|
||||
select 2;
|
||||
end case;
|
||||
end|
|
||||
call bug14643_1()|
|
||||
Handler
|
||||
boo
|
||||
2
|
||||
2
|
||||
call bug14643_2()|
|
||||
Handler
|
||||
boo
|
||||
2
|
||||
2
|
||||
drop procedure bug14643_1|
|
||||
drop procedure bug14643_2|
|
||||
drop table t1,t2;
|
||||
|
|
|
@ -4541,6 +4541,50 @@ drop table t3, t4|
|
|||
drop procedure bug14210|
|
||||
set @@session.max_heap_table_size=default|
|
||||
|
||||
|
||||
#
|
||||
# BUG#14643: Stored Procedure: Continuing after failed var. initialization
|
||||
# crashes server.
|
||||
#
|
||||
--disable_warnings
|
||||
drop procedure if exists bug14643_1|
|
||||
drop procedure if exists bug14643_2|
|
||||
--enable_warnings
|
||||
|
||||
create procedure bug14643_1()
|
||||
begin
|
||||
declare continue handler for sqlexception select 'boo' as 'Handler';
|
||||
|
||||
begin
|
||||
declare v int default x;
|
||||
|
||||
if v = 1 then
|
||||
select 1;
|
||||
else
|
||||
select 2;
|
||||
end if;
|
||||
end;
|
||||
end|
|
||||
|
||||
create procedure bug14643_2()
|
||||
begin
|
||||
declare continue handler for sqlexception select 'boo' as 'Handler';
|
||||
|
||||
case x
|
||||
when 1 then
|
||||
select 1;
|
||||
else
|
||||
select 2;
|
||||
end case;
|
||||
end|
|
||||
|
||||
call bug14643_1()|
|
||||
call bug14643_2()|
|
||||
|
||||
drop procedure bug14643_1|
|
||||
drop procedure bug14643_2|
|
||||
|
||||
|
||||
#
|
||||
# BUG#NNNN: New bug synopsis
|
||||
#
|
||||
|
|
|
@ -2031,6 +2031,26 @@ sp_instr_set::exec_core(THD *thd, uint *nextp)
|
|||
{
|
||||
int res= thd->spcont->set_item_eval(thd, m_offset, &m_value, m_type);
|
||||
|
||||
if (res < 0 &&
|
||||
thd->spcont->get_item(m_offset) == NULL &&
|
||||
thd->spcont->found_handler_here())
|
||||
{
|
||||
/*
|
||||
Failed to evaluate the value, the variable is still not initialized,
|
||||
and a handler has been found. Set to null so we can continue.
|
||||
*/
|
||||
Item *it= new Item_null();
|
||||
|
||||
if (!it || thd->spcont->set_item_eval(thd, m_offset, &it, m_type) < 0)
|
||||
{ /* If this also failed, we have to abort */
|
||||
sp_rcontext *spcont= thd->spcont;
|
||||
|
||||
thd->spcont= 0; /* Avoid handlers */
|
||||
my_error(ER_OUT_OF_RESOURCES, MYF(0));
|
||||
spcont->clear_handler();
|
||||
thd->spcont= spcont;
|
||||
}
|
||||
}
|
||||
*nextp = m_ip+1;
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue