summaryrefslogtreecommitdiff
path: root/mysql-test/t/sp-code.test
diff options
context:
space:
mode:
authorunknown <thek@adventure.(none)>2007-05-07 10:23:10 +0200
committerunknown <thek@adventure.(none)>2007-05-07 10:23:10 +0200
commit72569cc66d2a1d8edcc3e368213619f7ea855329 (patch)
tree2bff0cc91cb05a081ba21c79a104862facc39de5 /mysql-test/t/sp-code.test
parentc49e378ac4a690220d86c11ef40f2382848c6d30 (diff)
downloadmariadb-git-72569cc66d2a1d8edcc3e368213619f7ea855329.tar.gz
Bug#26977 exception handlers never hreturn
- In some cases, flow control optimization implemented in sp::optimize removes hreturn instructions, causing SQL exception handlers to: * never return * execute wrong logic - This patch overrides default short cut optimization on hreturn instructions to avoid this problem. mysql-test/r/sp-code.result: Added test case mysql-test/t/sp-code.test: Added test case sql/sp_head.cc: Override opt_mark to get correct execution paths without jump short cut optimization. sql/sp_head.h: Added override sp_instr_hreturn::opt_shortcut_jump so that jump short cuts aren't performed on hreturn instructions operating on handlers which are set to CONTINUE after interruption.
Diffstat (limited to 'mysql-test/t/sp-code.test')
-rw-r--r--mysql-test/t/sp-code.test75
1 files changed, 75 insertions, 0 deletions
diff --git a/mysql-test/t/sp-code.test b/mysql-test/t/sp-code.test
index 97bc29fcad2..0f249c95172 100644
--- a/mysql-test/t/sp-code.test
+++ b/mysql-test/t/sp-code.test
@@ -446,4 +446,79 @@ SHOW PROCEDURE CODE p1;
DROP PROCEDURE p1;
+#
+# Bug#26977 exception handlers never hreturn
+#
+--disable_warnings
+drop table if exists t1;
+drop procedure if exists proc_26977_broken;
+drop procedure if exists proc_26977_works;
+--enable_warnings
+
+create table t1(a int unique);
+
+delimiter //;
+
+create procedure proc_26977_broken(v int)
+begin
+ declare i int default 5;
+
+ declare continue handler for sqlexception
+ begin
+ select 'caught something';
+ retry:
+ while i > 0 do
+ begin
+ set i = i - 1;
+ select 'looping', i;
+ end;
+ end while retry;
+ end;
+
+ select 'do something';
+ insert into t1 values (v);
+ select 'do something again';
+ insert into t1 values (v);
+end//
+
+create procedure proc_26977_works(v int)
+begin
+ declare i int default 5;
+
+ declare continue handler for sqlexception
+ begin
+ select 'caught something';
+ retry:
+ while i > 0 do
+ begin
+ set i = i - 1;
+ select 'looping', i;
+ end;
+ end while retry;
+ select 'optimizer: keep hreturn';
+ end;
+
+ select 'do something';
+ insert into t1 values (v);
+ select 'do something again';
+ insert into t1 values (v);
+end//
+delimiter ;//
+
+show procedure code proc_26977_broken;
+
+show procedure code proc_26977_works;
+
+## This caust an error because of jump short cut
+## optimization.
+call proc_26977_broken(1);
+
+## This works
+call proc_26977_works(2);
+
+drop table t1;
+drop procedure proc_26977_broken;
+drop procedure proc_26977_works;
+
+
--echo End of 5.0 tests.