diff options
author | Jon Olav Hauglid <jon.hauglid@oracle.com> | 2012-01-09 11:28:02 +0100 |
---|---|---|
committer | Jon Olav Hauglid <jon.hauglid@oracle.com> | 2012-01-09 11:28:02 +0100 |
commit | 6c1bbb50cb9ee124e762f66004a3daad297e6d6f (patch) | |
tree | 72ca1c71906da75727e51474b01b58c7a6f16892 /mysql-test/r/sp.result | |
parent | 43ea968d456d08e2cd9719608d3b73e2b90963d1 (diff) | |
download | mariadb-git-6c1bbb50cb9ee124e762f66004a3daad297e6d6f.tar.gz |
Backport from mysql-trunk of:
------------------------------------------------------------
revno: 3258
committer: Jon Olav Hauglid <jon.hauglid@oracle.com>
branch nick: mysql-trunk-bug12663165
timestamp: Thu 2011-07-14 10:05:12 +0200
message:
Bug#12663165 SP DEAD CODE REMOVAL DOESN'T UNDERSTAND CONTINUE HANDLERS
When stored routines are loaded, a simple optimizer tries to locate
and remove dead code. The problem was that this dead code removal
did not work correctly with CONTINUE handlers.
If a statement triggers a CONTINUE handler, the following statement
will be executed after the handler statement has completed. This
means that the following statement is not dead code even if the
previous statement unconditionally alters control flow. This fact
was lost on the dead code removal routine, which ended up with
removing instructions that could have been executed. This could
then lead to assertions, crashes and generally bad behavior when
the stored routine was executed.
This patch fixes the problem by marking as live code all stored
routine instructions that are in the same scope as a CONTINUE handler.
Test case added to sp.test.
Diffstat (limited to 'mysql-test/r/sp.result')
-rw-r--r-- | mysql-test/r/sp.result | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index f5ed4fbd901..11d6ff02756 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -7087,6 +7087,26 @@ COUNT(DISTINCT d) 2 DROP FUNCTION f1; DROP TABLE t1, t2; +# +# Bug#12663165 SP DEAD CODE REMOVAL DOESN'T UNDERSTAND CONTINUE HANDLERS +# +DROP FUNCTION IF EXISTS f1; +CREATE FUNCTION f1() RETURNS INT +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION RETURN f1(); +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION RETURN f1(); +RETURN f1(); +END; +END; +RETURN 1; +END $ +SELECT f1(); +f1() +1 +DROP FUNCTION f1; # ------------------------------------------------------------------ # -- End of 5.1 tests # ------------------------------------------------------------------ |