summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorbell@sanja.is.com.ua <>2005-11-23 00:50:37 +0200
committerbell@sanja.is.com.ua <>2005-11-23 00:50:37 +0200
commit2bcd68973bb3ae278399a69b4642e76368edd31e (patch)
treebc5ba9cedbf44fad4c73c720d01700644e2e032e /mysql-test
parentdebff3e632f039bf3f0fd9bcd05c02218524a537 (diff)
downloadmariadb-git-2bcd68973bb3ae278399a69b4642e76368edd31e.tar.gz
Fix for BUG#13549 "Server crash with nested stored procedures
if inner routine has more local variables than outer one, and one of its last variables was used as argument to NOT operator". THD::spcont was non-0 when we were parsing stored routine/trigger definition during execution of another stored routine. This confused methods of Item_splocal and forced them use wrong runtime context. Fix ensures that we always have THD::spcont equal to zero during routine/trigger body parsing. This also allows to avoid problems with errors which occur during parsing and SQL exception handlers.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/sp.result17
-rw-r--r--mysql-test/r/trigger.result14
-rw-r--r--mysql-test/t/sp.test27
-rw-r--r--mysql-test/t/trigger.test28
4 files changed, 86 insertions, 0 deletions
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 1b8cde6d3db..bb20f77baa9 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -3435,4 +3435,21 @@ Table Create Table
tm1 CREATE TEMPORARY TABLE `tm1` (
`spv1` decimal(6,3) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop procedure bug12589_1|
+drop procedure bug12589_2|
+drop procedure bug12589_3|
+drop procedure if exists bug13549_1|
+drop procedure if exists bug13549_2|
+CREATE PROCEDURE `bug13549_2`()
+begin
+call bug13549_1();
+end|
+CREATE PROCEDURE `bug13549_1`()
+begin
+declare done int default 0;
+set done= not done;
+end|
+CALL bug13549_2()|
+drop procedure bug13549_2|
+drop procedure bug13549_1|
drop table t1,t2;
diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result
index b305691fa18..73f498d4133 100644
--- a/mysql-test/r/trigger.result
+++ b/mysql-test/r/trigger.result
@@ -738,3 +738,17 @@ f1
1
drop trigger t1_bi;
drop tables t1, t2;
+create table t1 (a int);
+drop procedure if exists p2;
+CREATE PROCEDURE `p2`()
+begin
+insert into t1 values (1);
+end//
+create trigger trg before insert on t1 for each row
+begin
+declare done int default 0;
+set done= not done;
+end//
+CALL p2();
+drop procedure p2;
+drop table t1;
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index e16e7456056..8c70bc9f6b1 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -4313,7 +4313,34 @@ call bug12589_1()|
# No warnings here
call bug12589_2()|
call bug12589_3()|
+drop procedure bug12589_1|
+drop procedure bug12589_2|
+drop procedure bug12589_3|
+#
+# BUG#13549 "Server crash with nested stored procedures".
+# Server should not crash when during execution of stored procedure
+# we have to parse trigger/function definition and this new trigger/
+# function has more local variables declared than invoking stored
+# procedure and last of these variables is used in argument of NOT
+# operator.
+#
+--disable_warnings
+drop procedure if exists bug13549_1|
+drop procedure if exists bug13549_2|
+--enable_warnings
+CREATE PROCEDURE `bug13549_2`()
+begin
+ call bug13549_1();
+end|
+CREATE PROCEDURE `bug13549_1`()
+begin
+ declare done int default 0;
+ set done= not done;
+end|
+CALL bug13549_2()|
+drop procedure bug13549_2|
+drop procedure bug13549_1|
#
# BUG#NNNN: New bug synopsis
diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test
index cd79eb82ace..e66f092e695 100644
--- a/mysql-test/t/trigger.test
+++ b/mysql-test/t/trigger.test
@@ -875,3 +875,31 @@ drop function f1;
drop view v1;
drop table t1, t2, t3;
--enable_parsing
+
+#
+# BUG#13549 "Server crash with nested stored procedures".
+# Server should not crash when during execution of stored procedure
+# we have to parse trigger/function definition and this new trigger/
+# function has more local variables declared than invoking stored
+# procedure and last of these variables is used in argument of NOT
+# operator.
+#
+create table t1 (a int);
+--disable_warnings
+drop procedure if exists p2;
+--enable_warnings
+DELIMITER //;
+CREATE PROCEDURE `p2`()
+begin
+ insert into t1 values (1);
+end//
+create trigger trg before insert on t1 for each row
+begin
+ declare done int default 0;
+ set done= not done;
+end//
+DELIMITER ;//
+CALL p2();
+drop procedure p2;
+drop table t1;
+