Commit cc037976 authored by unknown's avatar unknown
Browse files

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.
parent d9a008d9
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -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;
+31 −0
Original line number Diff line number Diff line
@@ -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
#
+2 −1
Original line number Diff line number Diff line
@@ -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: