Commit 95dcdde1 authored by pem@mysql.comhem.se's avatar pem@mysql.comhem.se

Fixed BUG#3287: Stored procedure handler scope outside of begin/end.

Backpatching overwrote already backpatched instructions, which made it
skip the hpop instruction; possibly not only a problem for handlers,
but this is one known case when it happened.
parent da44d115
...@@ -295,7 +295,7 @@ create function bug1654() ...@@ -295,7 +295,7 @@ create function bug1654()
returns int returns int
return (select sum(t.data) from test.t2 t)| return (select sum(t.data) from test.t2 t)|
ERROR 0A000: Statements like SELECT, INSERT, UPDATE (and others) are not allowed in a FUNCTION ERROR 0A000: Statements like SELECT, INSERT, UPDATE (and others) are not allowed in a FUNCTION
drop table if exists table_1| drop table if exists t3|
create table t3 (column_1_0 int)| create table t3 (column_1_0 int)|
create procedure bug1653() create procedure bug1653()
update t3 set column_1 = 0| update t3 set column_1 = 0|
...@@ -362,4 +362,28 @@ end case| ...@@ -362,4 +362,28 @@ end case|
call bug3287(2)| call bug3287(2)|
ERROR 20000: Case not found for CASE statement ERROR 20000: Case not found for CASE statement
drop procedure bug3287| drop procedure bug3287|
drop table if exists t3|
create table t3 (s1 int, primary key (s1))|
insert into t3 values (5),(6)|
create procedure bug3279(out y int)
begin
declare x int default 0;
begin
declare exit handler for sqlexception set x = x+1;
insert into t3 values (5);
end;
if x < 2 then
set x = x+1;
insert into t3 values (6);
end if;
set y = x;
end|
set @x = 0|
call bug3279(@x)|
ERROR 23000: Duplicate entry '6' for key 1
select @x|
@x
0
drop procedure bug3279|
drop table t3|
drop table t1| drop table t1|
...@@ -400,7 +400,7 @@ return (select sum(t.data) from test.t2 t)| ...@@ -400,7 +400,7 @@ return (select sum(t.data) from test.t2 t)|
# BUG#1653 # BUG#1653
# #
--disable_warnings --disable_warnings
drop table if exists table_1| drop table if exists t3|
--enable_warnings --enable_warnings
create table t3 (column_1_0 int)| create table t3 (column_1_0 int)|
...@@ -500,6 +500,37 @@ end case| ...@@ -500,6 +500,37 @@ end case|
call bug3287(2)| call bug3287(2)|
drop procedure bug3287| drop procedure bug3287|
#
# BUG#3297
#
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 (s1 int, primary key (s1))|
insert into t3 values (5),(6)|
create procedure bug3279(out y int)
begin
declare x int default 0;
begin
declare exit handler for sqlexception set x = x+1;
insert into t3 values (5);
end;
if x < 2 then
set x = x+1;
insert into t3 values (6);
end if;
set y = x;
end|
set @x = 0|
--error 1062
call bug3279(@x)|
select @x|
drop procedure bug3279|
drop table t3|
drop table t1| drop table t1|
delimiter ;| delimiter ;|
...@@ -1144,10 +1144,12 @@ sp_instr_hpush_jump::print(String *str) ...@@ -1144,10 +1144,12 @@ sp_instr_hpush_jump::print(String *str)
{ {
str->reserve(32); str->reserve(32);
str->append("hpush_jump "); str->append("hpush_jump ");
str->qs_append(m_dest);
str->append(" t=");
str->qs_append(m_type); str->qs_append(m_type);
str->append(' '); str->append(" f=");
str->qs_append(m_frame); str->qs_append(m_frame);
str->append(' '); str->append(" h=");
str->qs_append(m_handler); str->qs_append(m_handler);
} }
......
...@@ -351,7 +351,7 @@ class sp_instr_jump : public sp_instr ...@@ -351,7 +351,7 @@ class sp_instr_jump : public sp_instr
public: public:
sp_instr_jump(uint ip) sp_instr_jump(uint ip)
: sp_instr(ip) : sp_instr(ip), m_dest(0)
{} {}
sp_instr_jump(uint ip, uint dest) sp_instr_jump(uint ip, uint dest)
...@@ -368,6 +368,7 @@ public: ...@@ -368,6 +368,7 @@ public:
virtual void virtual void
set_destination(uint dest) set_destination(uint dest)
{ {
if (m_dest == 0) // Don't reset
m_dest= dest; m_dest= dest;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment