mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
Fixed BUGS#15011: error handler for mysql errno in nested block not activated
For nested sql errno handlers (unlike sqlexception and other), we didn't stop searching when the innermost handler was found - now make sure we do. mysql-test/r/sp.result: Updated result for BUG#15011. mysql-test/t/sp.test: New testcase for BUG#15011. sql/sp_rcontext.cc: Make sure we stop at the innermost sql_errno handler.
This commit is contained in:
@@ -4497,4 +4497,23 @@ drop procedure if exists bug15231_1|
|
||||
drop procedure if exists bug15231_2|
|
||||
drop procedure if exists bug15231_3|
|
||||
drop procedure if exists bug15231_4|
|
||||
drop procedure if exists bug15011|
|
||||
create table t3 (c1 int primary key)|
|
||||
insert into t3 values (1)|
|
||||
create procedure bug15011()
|
||||
deterministic
|
||||
begin
|
||||
declare continue handler for 1062
|
||||
select 'Outer' as 'Handler';
|
||||
begin
|
||||
declare continue handler for 1062
|
||||
select 'Inner' as 'Handler';
|
||||
insert into t3 values (1);
|
||||
end;
|
||||
end|
|
||||
call bug15011()|
|
||||
Handler
|
||||
Inner
|
||||
drop procedure bug15011|
|
||||
drop table t3|
|
||||
drop table t1,t2;
|
||||
|
||||
@@ -5283,6 +5283,37 @@ drop procedure if exists bug15231_3|
|
||||
drop procedure if exists bug15231_4|
|
||||
|
||||
|
||||
#
|
||||
# BUG#15011: error handler in nested block not activated
|
||||
#
|
||||
--disable_warnings
|
||||
drop procedure if exists bug15011|
|
||||
--enable_warnings
|
||||
|
||||
create table t3 (c1 int primary key)|
|
||||
|
||||
insert into t3 values (1)|
|
||||
|
||||
create procedure bug15011()
|
||||
deterministic
|
||||
begin
|
||||
declare continue handler for 1062
|
||||
select 'Outer' as 'Handler';
|
||||
|
||||
begin
|
||||
declare continue handler for 1062
|
||||
select 'Inner' as 'Handler';
|
||||
|
||||
insert into t3 values (1);
|
||||
end;
|
||||
end|
|
||||
|
||||
call bug15011()|
|
||||
|
||||
drop procedure bug15011|
|
||||
drop table t3|
|
||||
|
||||
|
||||
#
|
||||
# BUG#NNNN: New bug synopsis
|
||||
#
|
||||
|
||||
@@ -188,7 +188,8 @@ sp_rcontext::find_handler(uint sql_errno,
|
||||
switch (cond->type)
|
||||
{
|
||||
case sp_cond_type_t::number:
|
||||
if (sql_errno == cond->mysqlerr)
|
||||
if (sql_errno == cond->mysqlerr &&
|
||||
(found < 0 || m_handler[found].cond->type > sp_cond_type_t::number))
|
||||
found= i; // Always the most specific
|
||||
break;
|
||||
case sp_cond_type_t::state:
|
||||
|
||||
Reference in New Issue
Block a user