📄 sp-error.test
字号:
create procedure bug3279(out y int) begin declare x int default 0; begin declare exit handler for sqlexception set x = x+1; insert into t3 values (5); end; if x < 2 then set x = x+1; insert into t3 values (6); end if; set y = x;end|set @x = 0|--error 1062call bug3279(@x)|select @x|drop procedure bug3279|drop table t3|## BUG#3339#--error 1049create procedure nodb.bug3339() begin end|## BUG#2653#create procedure bug2653_1(a int, out b int) set b = aa|create procedure bug2653_2(a int, out b int)begin if aa < 0 then set b = - a; else set b = a; end if;end|--error 1054call bug2653_1(1, @b)|--error 1054call bug2653_2(2, @b)|drop procedure bug2653_1|drop procedure bug2653_2|## BUG#4344#--error 1357create procedure bug4344() drop procedure bug4344|--error 1357create procedure bug4344() drop function bug4344|## BUG#3294: Stored procedure crash if table dropped before use# (Actually, when an error occurs within an error handler.)--disable_warningsdrop procedure if exists bug3294|--enable_warningscreate procedure bug3294()begin declare continue handler for sqlexception drop table t5; drop table t5; drop table t5;end|create table t5 (x int)|--error 1051call bug3294()|drop procedure bug3294|## BUG#876: Stored Procedures: Invalid SQLSTATE is allowed in # a DECLARE ? HANDLER FOR stmt.#--disable_warningsdrop procedure if exists bug8776_1|drop procedure if exists bug8776_2|drop procedure if exists bug8776_3|drop procedure if exists bug8776_4|--enable_warnings--error ER_SP_BAD_SQLSTATEcreate procedure bug8776_1()begin declare continue handler for sqlstate '42S0200test' begin end; begin end;end|--error ER_SP_BAD_SQLSTATEcreate procedure bug8776_2()begin declare continue handler for sqlstate '4200' begin end; begin end;end|--error ER_SP_BAD_SQLSTATEcreate procedure bug8776_3()begin declare continue handler for sqlstate '420000' begin end; begin end;end|--error ER_SP_BAD_SQLSTATEcreate procedure bug8776_4()begin declare continue handler for sqlstate '42x00' begin end; begin end;end|## BUG#6600: Stored procedure crash after repeated calls with check table#--error ER_SP_BADSTATEMENTcreate procedure bug6600() check table t1|# Check these two as well, while we're at it. (Although it isn't really# related to the bug report, but to the fix.)--error ER_SP_BADSTATEMENTcreate procedure bug6600() lock table t1 read|--error ER_SP_BADSTATEMENTcreate procedure bug6600() unlock table t1|## BUG#9566: explicit LOCK TABLE and store procedures result in illegal state## We should not think that mysql.proc table does not exist if we are unable# to open it under LOCK TABLE or in prelocked mode.#--disable_warningsdrop procedure if exists bug9566|--enable_warningscreate procedure bug9566()begin select * from t1;end|lock table t1 read|# This should fail since we forgot to lock mysql.proc for writing# explicitly, and we can't open mysql.proc for _writing_ if there# are locked tables.--error 1100alter procedure bug9566 comment 'Some comment'|unlock tables|# This should succeeddrop procedure bug9566|## BUG#7299: Stored procedures: exception handler catches not-found conditions#--disable_warningsdrop procedure if exists bug7299|--enable_warningscreate procedure bug7299()begin declare v int; declare c cursor for select val from t1; declare exit handler for sqlexception select 'Error!'; open c; fetch c into v;end|delete from t1|--error ER_SP_FETCH_NO_DATAcall bug7299()|drop procedure bug7299|## BUG#9073: Able to declare two handlers for same condition in same scope#--error ER_SP_DUP_HANDLERcreate procedure bug9073()begin declare continue handler for sqlexception select 1; declare continue handler for sqlexception select 2;end|--error ER_SP_DUP_HANDLERcreate procedure bug9073()begin declare condname1 condition for 1234; declare continue handler for condname1 select 1; declare exit handler for condname1 select 2;end|--error ER_SP_DUP_HANDLERcreate procedure bug9073()begin declare condname1 condition for sqlstate '42000'; declare condname2 condition for sqlstate '42000'; declare exit handler for condname1 select 1; declare continue handler for condname2 select 2;end|--error ER_SP_DUP_HANDLERcreate procedure bug9073()begin declare condname1 condition for sqlstate '42000'; declare exit handler for condname1 select 1; declare exit handler for sqlstate '42000' select 2;end|# This should still work.--disable_warningsdrop procedure if exists bug9073|--enable_warningscreate procedure bug9073()begin declare condname1 condition for sqlstate '42000'; declare continue handler for condname1 select 1; begin declare exit handler for sqlstate '42000' select 2; begin declare continue handler for sqlstate '42000' select 3; end; end;end|drop procedure bug9073|## BUG#7047: Stored procedure crash if alter procedure#--error ER_SP_NO_DROP_SPcreate procedure bug7047() alter procedure bug7047|--error ER_SP_NO_DROP_SPcreate function bug7047() returns intbegin alter function bug7047; return 0;end|## BUG#8408: Stored procedure crash if function contains SHOW# BUG#9058: Stored Procedures: Crash if function included SELECT## Some things are caught when parsing--error ER_SP_NO_RETSETcreate function bug8408() returns intbegin select * from t1; return 0;end|--error ER_SP_NO_RETSETcreate function bug8408() returns intbegin show warnings; return 0;end|--error ER_SP_NO_RETSETcreate function bug8408(a int) returns intbegin declare b int; select b; return b;end|--disable_warningsdrop function if exists bug8408_f|drop procedure if exists bug8408_p|--enable_warnings# Some things must be caught at invokation timecreate function bug8408_f() returns intbegin call bug8408_p(); return 0;end|create procedure bug8408_p() select * from t1|call bug8408_p()|--error ER_SP_NO_RETSETselect bug8408_f()|drop procedure bug8408_p|drop function bug8408_f|# But this is okcreate function bug8408() returns intbegin declare n int default 0; select count(*) into n from t1; return n;end|insert into t1 value (2, 2.7), (3, 3.14), (7, 7.0)|select *,bug8408() from t1|drop function bug8408|delete from t1|## BUG#10537: Server crashes while loading data file into table through# procedure.# Disable load until it's PS and SP safe--disable_warningsdrop procedure if exists bug10537|--enable_warnings--error ER_SP_BADSTATEMENTcreate procedure bug10537() load data local infile '/tmp/somefile' into table t1|## BUG#8409: Stored procedure crash if function contains FLUSH#--disable_warningsdrop function if exists bug8409|--enable_warnings--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRGcreate function bug8409() returns intbegin flush tables; return 5;end|## BUG#9529: Stored Procedures: No Warning on truncation of procedure name# during creation.# BUG#17015: Routine name truncation not an error# When we started using utf8 for mysql.proc, this limit appeared# to be higher, but in reality the names were truncated.--error ER_TOO_LONG_IDENTcreate procedure bug9529_901234567890123456789012345678901234567890123456789012345()beginend|--disable_warningsdrop procedure if exists bug17015_0123456789012345678901234567890123456789012345678901234|--enable_warnings# Check the upper limit, just to make sure.create procedure bug17015_0123456789012345678901234567890123456789012345678901234()beginend|--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'show procedure status like 'bug17015%'|drop procedure bug17015_0123456789012345678901234567890123456789012345678901234|## BUG#10969: Stored procedures: crash if default() function#--disable_warningsdrop procedure if exists bug10969|--enable_warnings--error ER_WRONG_COLUMN_NAMEcreate procedure bug10969()begin declare s1 int default 0; select default(s1) from t30;end|# This should workcreate procedure bug10969()begin declare s1 int default 0; select default(t30.s1) from t30;end|drop procedure bug10969|drop table t1|delimiter ;|# BUG#9814: Closing a cursor that is not open create table t1(f1 int);create table t2(f1 int); delimiter |;CREATE PROCEDURE SP001()P1: BEGIN DECLARE ENDTABLE INT DEFAULT 0; DECLARE TEMP_NUM INT; DECLARE TEMP_SUM INT; DECLARE C1 CURSOR FOR SELECT F1 FROM t1; DECLARE C2 CURSOR FOR SELECT F1 FROM t2; DECLARE CONTINUE HANDLER FOR NOT FOUND SET ENDTABLE = 1; SET ENDTABLE=0; SET TEMP_SUM=0; SET TEMP_NUM=0; OPEN C1; FETCH C1 INTO TEMP_NUM; WHILE ENDTABLE = 0 DO SET TEMP_SUM=TEMP_NUM+TEMP_SUM; FETCH C1 INTO TEMP_NUM; END WHILE; SELECT TEMP_SUM; CLOSE C1; CLOSE C1; SELECT 'end of proc';END P1|delimiter ;|--error 1326call SP001();drop procedure SP001;drop table t1, t2;# Bug #11394 "Recursion in SP crash server" and bug #11600 "Stored# procedures: crash with function calling itself".# We have to disable recursion since in many cases LEX and many# Item's can't be used in reentrant way nowdays.delimiter |;--disable_warningsdrop function if exists bug11394|drop function if exists bug11394_1|drop function if exists bug11394_2|drop procedure if exists bug11394|--enable_warningscreate function bug11394(i int) returns intbegin if i <= 0 then return 0; else return (i in (100, 200, bug11394(i-1), 400)); end if;end|# If we allow recursive functions without additional modifications# this will crash server since Item for "IN" is not reenterable.--error 1424select bug11394(2)|drop function bug11394|create function bug11394_1(i int) returns intbegin if i <= 0 then return 0; else return (select bug11394_1(i-1)); end if;end|# The following statement will crash because some LEX members responsible# for selects cannot be used in reentrant fashion.--error 1424select bug11394_1(2)|drop function bug11394_1|# Note that the following should be allowed since it does not contains# recursioncreate function bug11394_2(i int) returns int return i|select bug11394_2(bug11394_2(10))|drop function bug11394_2|create procedure bug11394(i int, j int)begin if i > 0 then call bug11394(i - 1,(select 1)); end if;end|--error ER_SP_RECURSION_LIMITcall bug11394(2, 1)|set @@max_sp_recursion_depth=10|call bug11394(2, 1)|set @@max_sp_recursion_depth=default|drop procedure bug11394|delimiter ;|## BUG 12490 (Packets out of order if calling HELP CONTENTS from Stored Procedure)#--error 1314CREATE PROCEDURE BUG_12490() HELP CONTENTS;--error 1314CREATE FUNCTION BUG_12490() RETURNS INT HELP CONTENTS;CREATE TABLE t_bug_12490(a int);--error 1314CREATE TRIGGER BUG_12490 BEFORE UPDATE ON t_bug_12490 FOR EACH ROW HELP CONTENTS;DROP TABLE t_bug_12490;## Bug#11834 "Re-execution of prepared statement with dropped function# crashes server". Also tests handling of prepared stmts which use# stored functions but does not require prelocking.#--disable_warningsdrop function if exists bug11834_1;drop function if exists bug11834_2;--enable_warningscreate function bug11834_1() returns int return 10;create function bug11834_2() returns int return bug11834_1();prepare stmt from "select bug11834_2()";execute stmt;# Re-execution of statement should not crash server.execute stmt;drop function bug11834_1;# Attempt to execute statement should return proper error and # should not crash server.--error ER_SP_DOES_NOT_EXISTexecute stmt;deallocate prepare stmt;drop function bug11834_2;## Bug#12953 "Stored procedures: crash if OPTIMIZE TABLE in function"#delimiter |;--disable_warningsDROP FUNCTION IF EXISTS bug12953|--enable_warnings--error ER_SP_NO_RETSETCREATE FUNCTION bug12953() RETURNS INTBEGIN OPTIMIZE TABLE t1; RETURN 1;END|delimiter ;|## Bug##12995 "Inside function "Table 't4' was not locked with LOCK TABLES"#delimiter |;--disable_warningsDROP FUNCTION IF EXISTS bug12995|--enable_warnings--error ER_SP_BADSTATEMENTCREATE FUNCTION bug12995() RETURNS INTBEGIN HANDLER t1 OPEN; RETURN 1;END|--error ER_SP_BADSTATEMENTCREATE FUNCTION bug12995() RETURNS INTBEGIN HANDLER t1 READ FIRST; RETURN 1;END|--error ER_SP_BADSTATEMENTCREATE FUNCTION bug12995() RETURNS INTBEGIN HANDLER t1 CLOSE; RETURN 1;END|--error 1305SELECT bug12995()|delimiter ;|## BUG#12712: SET AUTOCOMMIT should fail within SP/functions/triggers#--disable_warningsdrop procedure if exists bug12712;drop function if exists bug12712;--enable_warnings# Can...create procedure bug12712() set session autocommit = 0;select @@autocommit;set @au = @@autocommit;call bug12712();select @@autocommit;set session autocommit = @au;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -