summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/sp.result19
-rw-r--r--mysql-test/t/sp.test31
-rw-r--r--sql/sp_rcontext.cc3
3 files changed, 52 insertions, 1 deletions
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 904cd7d8642..90020573df3 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -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;
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 8235686a74a..32299ad7e0b 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -5284,6 +5284,37 @@ 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
#
#--disable_warnings
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc
index 215de01e657..4818ffbbe31 100644
--- a/sql/sp_rcontext.cc
+++ b/sql/sp_rcontext.cc
@@ -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: