3427 Alexander Nozdrin 2011-10-11
Review fixes for Bug 13059316 (ASSERTION FAILURE IN SP_RCONTEXT.CC):
- add another test case
- polish comment
- mention the bug number in the test case
modified:
mysql-test/r/sp-error.result
mysql-test/t/sp-error.test
sql/sp_rcontext.cc
3426 Jon Olav Hauglid 2011-10-04
WL#5986: Stored programs: Make condition handlers closer to the standard.
Fix assertion failure if a variable declaration raises a warning
and a warning handler is declared. The assertion was triggered
because the parser thought the handler should be activated, yet
at runtime the handler declaration had not been processed yet.
This patch fixes the assertion by not activating the handler in
such cases (this matches the current 5.5/5.6 behavior).
Test case added to sp-error.test.
modified:
mysql-test/r/sp-error.result
mysql-test/t/sp-error.test
sql/sp_rcontext.cc
=== modified file 'mysql-test/r/sp-error.result'
--- a/mysql-test/r/sp-error.result 2011-10-04 09:07:20 +0000
+++ b/mysql-test/r/sp-error.result 2011-10-11 15:01:02 +0000
@@ -2776,18 +2776,31 @@ DROP PROCEDURE p6;
DROP TABLE t1;
DROP TABLE t2;
+# Bug#13059316: ASSERTION FAILURE IN SP_RCONTEXT.CC
# Check DECLARE statements that raise conditions before handlers
# are declared.
DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
CREATE PROCEDURE p1()
BEGIN
DECLARE var1 INTEGER DEFAULT 'string';
-DECLARE EXIT HANDLER FOR SQLWARNING BEGIN END;
+DECLARE EXIT HANDLER FOR SQLWARNING SELECT 'H1';
END|
-CALL p1();
+CALL p1()|
Warnings:
Warning 1366 Incorrect integer value: 'string' for column 'var1' at row 1
+CREATE PROCEDURE p2()
+BEGIN
+DECLARE EXIT HANDLER FOR SQLWARNING SELECT 'H2';
+CALL p1();
+END|
+
+CALL p2()|
+H2
+H2
+
DROP PROCEDURE p1;
+DROP PROCEDURE p2;
=== modified file 'mysql-test/t/sp-error.test'
--- a/mysql-test/t/sp-error.test 2011-10-04 09:07:20 +0000
+++ b/mysql-test/t/sp-error.test 2011-10-11 15:01:02 +0000
@@ -3718,12 +3718,14 @@ DROP TABLE t1;
DROP TABLE t2;
--echo
+--echo # Bug#13059316: ASSERTION FAILURE IN SP_RCONTEXT.CC
--echo # Check DECLARE statements that raise conditions before handlers
--echo # are declared.
--echo
--disable_warnings
DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
--enable_warnings
delimiter |;
@@ -3731,13 +3733,24 @@ delimiter |;
CREATE PROCEDURE p1()
BEGIN
DECLARE var1 INTEGER DEFAULT 'string';
- DECLARE EXIT HANDLER FOR SQLWARNING BEGIN END;
+ DECLARE EXIT HANDLER FOR SQLWARNING SELECT 'H1';
END|
-delimiter ;|
+--echo
+CALL p1()|
+--echo
+
+CREATE PROCEDURE p2()
+BEGIN
+ DECLARE EXIT HANDLER FOR SQLWARNING SELECT 'H2';
+ CALL p1();
+END|
--echo
-CALL p1();
+CALL p2()|
+
+delimiter ;|
--echo
DROP PROCEDURE p1;
+DROP PROCEDURE p2;
=== modified file 'sql/sp_rcontext.cc'
--- a/sql/sp_rcontext.cc 2011-10-04 09:07:20 +0000
+++ b/sql/sp_rcontext.cc 2011-10-11 15:01:02 +0000
@@ -280,12 +280,20 @@ bool sp_rcontext::handle_sql_condition(T
}
/*
- handler_entry should not be NULL here, as that indicates
+ handler_entry usually should not be NULL here, as that indicates
that the parser context thinks a HANDLER should be activated,
but the runtime context cannot find it.
- However, this can currently happen if a statement that can
- legally be written before DECLARE HANDLER raises a condition.
- E.g. DECLARE var1 INTEGER DEFAULT 'get'.
+
+ However, this can happen (and this is in line with the Standard)
+ if SQL-condition has been raised before DECLARE HANDLER instruction
+ is processed.
+
+ For example:
+ CREATE PROCEDURE p()
+ BEGIN
+ DECLARE v INT DEFAULT 'get'; -- raises SQL-warning here
+ DECLARE EXIT HANDLER ... -- this handler does not catch the warning
+ END
*/
if (!handler_entry)
DBUG_RETURN(false);
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (alexander.nozdrin:3426 to 3427) | Alexander Nozdrin | 12 Oct |