diff options
Diffstat (limited to 'mysql-test/t/sp.test')
-rw-r--r-- | mysql-test/t/sp.test | 365 |
1 files changed, 143 insertions, 222 deletions
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index e7ee4b134ba..4df49c5f934 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -12,6 +12,7 @@ # Tests that check privilege and security issues go to sp-security.test. # Tests that require multiple connections, except security/privilege tests, # go to sp-thread. +# Tests that uses 'goto' to into sp-goto.test (currently disabled) use test; @@ -585,139 +586,6 @@ delete from t1| drop procedure i| -# The non-standard GOTO, for compatibility -# -# QQQ The "label" syntax is temporary, it will (hopefully) -# change to the more common "L:" syntax soon. -# ---disable_warnings -drop procedure if exists goto1| ---enable_warnings -create procedure goto1() -begin - declare y int; - -label a; - select * from t1; - select count(*) into y from t1; - if y > 2 then - goto b; - end if; - insert into t1 values ("j", y); - goto a; -label b; -end| - -call goto1()| -drop procedure goto1| - -# With dummy handlers, just to test restore of contexts with jumps ---disable_warnings -drop procedure if exists goto2| ---enable_warnings -create procedure goto2(a int) -begin - declare x int default 0; - declare continue handler for sqlstate '42S98' set x = 1; - -label a; - select * from t1; -b: - while x < 2 do - begin - declare continue handler for sqlstate '42S99' set x = 2; - - if a = 0 then - set x = x + 1; - iterate b; - elseif a = 1 then - leave b; - elseif a = 2 then - set a = 1; - goto a; - end if; - end; - end while b; - - select * from t1; -end| - -call goto2(0)| -call goto2(1)| -call goto2(2)| - -drop procedure goto2| -delete from t1| - -# Check label visibility for some more cases. We don't call these. ---disable_warnings -drop procedure if exists goto3| ---enable_warnings -create procedure goto3() -begin - label L1; - begin - end; - goto L1; -end| -drop procedure goto3| - ---disable_warnings -drop procedure if exists goto4| ---enable_warnings -create procedure goto4() -begin - begin - label lab1; - begin - goto lab1; - end; - end; -end| -drop procedure goto4| - ---disable_warnings -drop procedure if exists goto5| ---enable_warnings -create procedure goto5() -begin - begin - begin - goto lab1; - end; - label lab1; - end; -end| -drop procedure goto5| - ---disable_warnings -drop procedure if exists goto6| ---enable_warnings -create procedure goto6() -begin - label L1; - goto L5; - begin - label L2; - goto L1; - goto L5; - begin - label L3; - goto L1; - goto L2; - goto L3; - goto L4; - goto L5; - end; - goto L2; - goto L4; - label L4; - end; - label L5; - goto L1; -end| -drop procedure goto6| - # SELECT with one of more result set sent back to the clinet insert into t1 values ("foo", 3), ("bar", 19)| insert into t2 values ("x", 9, 4.1), ("y", -1, 19.2), ("z", 3, 2.2)| @@ -1415,7 +1283,8 @@ select * from v1| # views and functions ? create function f1() returns int return (select sum(data) from t1) + (select sum(data) from v1)| -# FIXME All these just exceed file limit for me :) +# This queries will crash server because we can't use LEX in +# reenterable fashion yet. Patch disabling recursion will heal this. #select f1()| #select * from v1| #select * from v2| @@ -1460,15 +1329,12 @@ select * from v2| select * from v1| # These should not work as we have too little instances of tables locked --error 1100 -select * from v1, v2| +select * from v1, t1| --error 1100 select f4()| unlock tables| -# TODO We also should test integration with triggers - - # Cleanup drop function f0| drop function f1| @@ -1630,54 +1496,56 @@ show procedure status like '%p%'| # Fibonacci, for recursion test. (Yet Another Numerical series :) - ---disable_warnings -drop table if exists fib| ---enable_warnings -create table fib ( f bigint unsigned not null )| - -# We deliberately do it the awkward way, fetching the last two -# values from the table, in order to exercise various statements -# and table accesses at each turn. ---disable_warnings -drop procedure if exists fib| ---enable_warnings -create procedure fib(n int unsigned) -begin - if n > 1 then - begin - declare x, y bigint unsigned; - declare c cursor for select f from fib order by f desc limit 2; - - open c; - fetch c into y; - fetch c into x; - close c; - insert into fib values (x+y); - call fib(n-1); - end; - end if; -end| - -# Minimum test: recursion of 3 levels - -insert into fib values (0), (1)| - -call fib(3)| - -select * from fib order by f asc| - -delete from fib| - -# Original test: 20 levels (may run into memory limits!) - -insert into fib values (0), (1)| - -call fib(20)| - -select * from fib order by f asc| -drop table fib| -drop procedure fib| +# +# This part of test is disabled until we implement support for +# recursive stored procedures. +#--disable_warnings +#drop table if exists fib| +#--enable_warnings +#create table fib ( f bigint unsigned not null )| +# +## We deliberately do it the awkward way, fetching the last two +## values from the table, in order to exercise various statements +## and table accesses at each turn. +#--disable_warnings +#drop procedure if exists fib| +#--enable_warnings +#create procedure fib(n int unsigned) +#begin +# if n > 1 then +# begin +# declare x, y bigint unsigned; +# declare c cursor for select f from fib order by f desc limit 2; +# +# open c; +# fetch c into y; +# fetch c into x; +# close c; +# insert into fib values (x+y); +# call fib(n-1); +# end; +# end if; +#end| +# +## Minimum test: recursion of 3 levels +# +#insert into fib values (0), (1)| +# +#call fib(3)| +# +#select * from fib order by f asc| +# +#delete from fib| +# +## Original test: 20 levels (may run into memory limits!) +# +#insert into fib values (0), (1)| +# +#call fib(20)| +# +#select * from fib order by f asc| +#drop table fib| +#drop procedure fib| # @@ -3011,24 +2879,26 @@ drop table t3| # # BUG#6022: Stored procedure shutdown problem with self-calling function. # ---disable_warnings -drop function if exists bug6022| ---enable_warnings - ---disable_warnings -drop function if exists bug6022| ---enable_warnings -create function bug6022(x int) returns int -begin - if x < 0 then - return 0; - else - return bug6022(x-1); - end if; -end| - -select bug6022(5)| -drop function bug6022| +# This part of test is disabled until we implement support for +# recursive stored functions. +#--disable_warnings +#drop function if exists bug6022| +#--enable_warnings +# +#--disable_warnings +#drop function if exists bug6022| +#--enable_warnings +#create function bug6022(x int) returns int +#begin +# if x < 0 then +# return 0; +# else +# return bug6022(x-1); +# end if; +#end| +# +#select bug6022(5)| +#drop function bug6022| # # BUG#6029: Stored procedure specific handlers should have priority @@ -3635,22 +3505,6 @@ drop function bug9902| # -# BUG#6898: Stored procedure crash if GOTO statements exist -# ---disable_warnings -drop procedure if exists bug6898| ---enable_warnings -create procedure bug6898() -begin - goto label1; - label label1; - begin end; - goto label1; -end| -drop procedure bug6898| - - -# # BUG#9102: Stored proccedures: function which returns blob causes crash # --disable_warnings @@ -3912,6 +3766,74 @@ drop procedure bug10136| drop table t3| # +# BUG#11529: crash server after use stored procedure +# +--disable_warnings +drop procedure if exists bug11529| +--enable_warnings +create procedure bug11529() +begin + declare c cursor for select id, data from t1 where data in (10,13); + + open c; + begin + declare vid char(16); + declare vdata int; + declare exit handler for not found begin end; + + while true do + fetch c into vid, vdata; + end while; + end; + close c; +end| + +insert into t1 values + ('Name1', 10), + ('Name2', 11), + ('Name3', 12), + ('Name4', 13), + ('Name5', 14)| + +call bug11529()| +call bug11529()| +delete from t1| +drop procedure bug11529| + + +# +# BUG#6063: Stored procedure labels are subject to restrictions (partial) +# BUG#7088: Stored procedures: labels won't work if character set is utf8 +# +--disable_warnings +drop procedure if exists bug6063| +drop procedure if exists bug7088_1| +drop procedure if exists bug7088_2| +--enable_warnings + +create procedure bug6063() + lābel: begin end| +call bug6063()| +# QQ Known bug: this will not show the label correctly. +show create procedure bug6063| + +set character set utf8| +create procedure bug7088_1() + label1: begin end label1| +create procedure bug7088_2() + lƤbel1: begin end| +call bug7088_1()| +call bug7088_2()| +set character set default| +show create procedure bug7088_1| +show create procedure bug7088_2| + +drop procedure bug6063| +drop procedure bug7088_1| +drop procedure bug7088_2| + + +# # BUG#NNNN: New bug synopsis # #--disable_warnings @@ -3921,7 +3843,6 @@ drop table t3| # Add bugs above this line. Use existing tables t1 and t2 when -# practical, or create table t3, t3 etc temporarily (and drop them). +# practical, or create table t3, t4 etc temporarily (and drop them). delimiter ;| drop table t1,t2; - |