1
drop table if exists t1, t2;
2
SELECT * FROM mysql.proc INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/proc.txt';
3
delete from mysql.proc;
4
create procedure syntaxerror(t int)|
5
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
6
create procedure syntaxerror(t int)|
7
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
8
create procedure syntaxerror(t int)|
9
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
10
drop table if exists t3|
11
create table t3 ( x int )|
12
insert into t3 values (2), (3)|
13
create procedure bad_into(out param int)
14
select x from t3 into param|
16
ERROR 42000: Result consisted of more than one row
17
drop procedure bad_into|
19
create procedure proc1()
21
create function func1() returns int
23
create procedure foo()
24
create procedure bar() set @x=3|
25
ERROR 2F003: Can't create a PROCEDURE from within another stored routine
26
create procedure foo()
27
create function bar() returns double return 2.3|
28
ERROR 2F003: Can't create a FUNCTION from within another stored routine
29
create procedure proc1()
31
ERROR 42000: PROCEDURE proc1 already exists
32
create function func1() returns int
34
ERROR 42000: FUNCTION func1 already exists
38
ERROR 42000: PROCEDURE test.foo does not exist
40
ERROR 42000: FUNCTION test.foo does not exist
42
ERROR 42000: PROCEDURE test.foo does not exist
44
ERROR 42000: FUNCTION test.foo does not exist
46
ERROR 42000: PROCEDURE test.foo does not exist
47
drop procedure if exists foo|
49
Note 1305 PROCEDURE test.foo does not exist
50
show create procedure foo|
51
ERROR 42000: PROCEDURE foo does not exist
52
show create function foo|
53
ERROR 42000: FUNCTION foo does not exist
54
create procedure foo()
58
ERROR 42000: LEAVE with no matching label: bar
59
create procedure foo()
63
ERROR 42000: ITERATE with no matching label: bar
64
create procedure foo()
68
ERROR 42000: ITERATE with no matching label: foo
69
create procedure foo()
75
ERROR 42000: Redefining label foo
76
create procedure foo()
80
ERROR 42000: End-label bar without match
81
create procedure foo()
83
ERROR 42000: RETURN is only allowed in a FUNCTION
84
create procedure p(x int)
86
create function f(x int) returns int
89
ERROR 42000: Incorrect number of arguments for PROCEDURE test.p; expected 1, got 0
91
ERROR 42000: Incorrect number of arguments for PROCEDURE test.p; expected 1, got 2
93
ERROR 42000: Incorrect number of arguments for FUNCTION test.f; expected 1, got 0
95
ERROR 42000: Incorrect number of arguments for FUNCTION test.f; expected 1, got 2
98
create procedure p(val int, out res int)
100
declare x int default 0;
101
declare continue handler for foo set x = 1;
102
insert into test.t1 values (val);
109
ERROR 42000: Undefined CONDITION: foo
110
create procedure p(val int, out res int)
112
declare x int default 0;
113
declare foo condition for 1146;
114
declare continue handler for bar set x = 1;
115
insert into test.t1 values (val);
122
ERROR 42000: Undefined CONDITION: bar
123
create function f(val int) returns int
128
ERROR 42000: No RETURN found in FUNCTION test.f
129
create function f(val int) returns int
138
ERROR 2F005: FUNCTION f ended without RETURN
142
declare c cursor for insert into test.t1 values ("foo", 42);
146
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'insert into test.t1 values ("foo", 42);
153
declare c cursor for select * into x from test.t limit 1;
157
ERROR 42000: Cursor SELECT must not have INTO
160
declare c cursor for select * from test.t;
164
ERROR 42000: Undefined CURSOR: cc
165
drop table if exists t1|
166
create table t1 (val int)|
169
declare c cursor for select * from test.t1;
175
ERROR 24000: Cursor is already open
179
declare c cursor for select * from test.t1;
185
ERROR 24000: Cursor is not open
187
alter procedure bar3 sql security invoker|
188
ERROR 42000: PROCEDURE test.bar3 does not exist
190
drop table if exists t1|
191
create table t1 (val int, x float)|
192
insert into t1 values (42, 3.1), (19, 1.2)|
196
declare c cursor for select * from t1;
201
ERROR 42000: Undeclared variable: y
205
declare c cursor for select * from t1;
211
ERROR HY000: Incorrect number of FETCH variables
218
declare c cursor for select * from t1;
220
fetch c into x, y, z;
224
ERROR HY000: Incorrect number of FETCH variables
226
create procedure p(in x int, x char(10))
229
ERROR 42000: Duplicate parameter: x
230
create function p(x int, x char(10))
233
ERROR 42000: Duplicate parameter: x
239
ERROR 42000: Duplicate variable: x
242
declare c condition for 1064;
243
declare c condition for 1065;
245
ERROR 42000: Duplicate condition: c
248
declare c cursor for select * from t1;
249
declare c cursor for select field from t1;
251
ERROR 42000: Duplicate cursor: c
254
ERROR 0A000: USE is not allowed in stored procedures
257
declare c cursor for select * from t1;
260
ERROR 42000: Variable or condition declaration after cursor or handler declaration
264
declare continue handler for sqlstate '42S99' set x = 1;
265
declare foo condition for sqlstate '42S99';
267
ERROR 42000: Variable or condition declaration after cursor or handler declaration
271
declare continue handler for sqlstate '42S99' set x = 1;
272
declare c cursor for select * from t1;
274
ERROR 42000: Cursor declaration after handler declaration
275
drop procedure if exists p|
276
create procedure p(in x int, inout y int, out z int)
284
call p(@tmp_x, @tmp_y, @tmp_z)|
285
select @tmp_x, @tmp_y, @tmp_z|
288
call p(42, 43, @tmp_z)|
289
ERROR 42000: OUT or INOUT argument 2 for routine test.p is not a variable or NEW pseudo-variable in BEFORE trigger
290
call p(42, @tmp_y, 43)|
291
ERROR 42000: OUT or INOUT argument 3 for routine test.p is not a variable or NEW pseudo-variable in BEFORE trigger
293
create procedure p() begin end|
298
lock tables t1 read, mysql.proc write|
299
ERROR HY000: You can't combine write-locking of system tables with other tables or lock types
300
lock tables mysql.proc write, mysql.user write|
301
ERROR HY000: You can't combine write-locking of system tables with other tables or lock types
302
lock tables t1 read, mysql.proc read|
304
lock tables mysql.proc write|
306
drop function if exists f1|
307
create function f1(i int) returns int
309
insert into t1 (val) values (i);
312
select val, f1(val) from t1|
313
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
314
select val, f1(val) from t1 as tab|
315
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
320
update t1 set val= f1(val)|
321
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
334
delete from t1 where val= 17|
336
create procedure bug1965()
338
declare c cursor for select val from t1 order by valname;
343
ERROR 42S22: Unknown column 'valname' in 'order clause'
344
drop procedure bug1965|
346
ERROR 42000: Undeclared variable: a
347
drop table if exists t3|
348
create table t3 (column_1_0 int)|
349
create procedure bug1653()
350
update t3 set column_1 = 0|
352
ERROR 42S22: Unknown column 'column_1' in 'field list'
354
create table t3 (column_1 int)|
356
drop procedure bug1653|
358
create procedure bug2259()
361
declare c1 cursor for select s1 from t1;
365
ERROR 24000: Cursor is not open
366
drop procedure bug2259|
367
create procedure bug2272()
370
update t1 set v = 42;
372
insert into t1 values (666, 51.3)|
374
ERROR 42S22: Unknown column 'v' in 'field list'
376
drop procedure bug2272|
377
create procedure bug2329_1()
380
insert into t1 (v) values (5);
382
create procedure bug2329_2()
385
replace t1 set v = 5;
388
ERROR 42S22: Unknown column 'v' in 'field list'
390
ERROR 42S22: Unknown column 'v' in 'field list'
391
drop procedure bug2329_1|
392
drop procedure bug2329_2|
393
create function bug3287() returns int
395
declare v int default null;
397
when v is not null then return 1;
402
ERROR 20000: Case not found for CASE statement
403
drop function bug3287|
404
create procedure bug3287(x int)
407
insert into test.t1 values (x, 0.1);
409
insert into test.t1 values (x, 1.1);
412
ERROR 20000: Case not found for CASE statement
413
drop procedure bug3287|
414
drop table if exists t3|
415
create table t3 (s1 int, primary key (s1))|
416
insert into t3 values (5),(6)|
417
create procedure bug3279(out y int)
419
declare x int default 0;
421
declare exit handler for sqlexception set x = x+1;
422
insert into t3 values (5);
426
insert into t3 values (6);
432
ERROR 23000: Duplicate entry '6' for key 'PRIMARY'
436
drop procedure bug3279|
438
create procedure nodb.bug3339() begin end|
439
ERROR 42000: Unknown database 'nodb'
440
create procedure bug2653_1(a int, out b int)
442
create procedure bug2653_2(a int, out b int)
450
call bug2653_1(1, @b)|
451
ERROR 42S22: Unknown column 'aa' in 'field list'
452
call bug2653_2(2, @b)|
453
ERROR 42S22: Unknown column 'aa' in 'field list'
454
drop procedure bug2653_1|
455
drop procedure bug2653_2|
456
create procedure bug4344() drop procedure bug4344|
457
ERROR HY000: Can't drop or alter a PROCEDURE from within another stored routine
458
create procedure bug4344() drop function bug4344|
459
ERROR HY000: Can't drop or alter a FUNCTION from within another stored routine
460
drop procedure if exists bug3294|
461
create procedure bug3294()
463
declare continue handler for sqlexception drop table t5;
467
create table t5 (x int)|
469
ERROR 42S02: Unknown table 'test.t5'
470
drop procedure bug3294|
471
drop procedure if exists bug8776_1|
472
drop procedure if exists bug8776_2|
473
drop procedure if exists bug8776_3|
474
drop procedure if exists bug8776_4|
475
create procedure bug8776_1()
477
declare continue handler for sqlstate '42S0200test' begin end;
480
ERROR 42000: Bad SQLSTATE: '42S0200test'
481
create procedure bug8776_2()
483
declare continue handler for sqlstate '4200' begin end;
486
ERROR 42000: Bad SQLSTATE: '4200'
487
create procedure bug8776_3()
489
declare continue handler for sqlstate '420000' begin end;
492
ERROR 42000: Bad SQLSTATE: '420000'
493
create procedure bug8776_4()
495
declare continue handler for sqlstate '42x00' begin end;
498
ERROR 42000: Bad SQLSTATE: '42x00'
499
create procedure bug6600()
501
ERROR 0A000: CHECK is not allowed in stored procedures
502
create procedure bug6600()
504
ERROR 0A000: LOCK is not allowed in stored procedures
505
create procedure bug6600()
507
ERROR 0A000: UNLOCK is not allowed in stored procedures
508
drop procedure if exists bug9566|
509
create procedure bug9566()
514
alter procedure bug9566 comment 'Some comment'|
515
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
517
drop procedure bug9566|
518
drop procedure if exists bug7299|
519
create procedure bug7299()
522
declare c cursor for select val from t1;
523
declare exit handler for sqlexception select 'Error!';
529
ERROR 02000: No data - zero rows fetched, selected, or processed
530
drop procedure bug7299|
531
create procedure bug9073()
533
declare continue handler for sqlexception select 1;
534
declare continue handler for sqlexception select 2;
536
ERROR 42000: Duplicate handler declared in the same block
537
create procedure bug9073()
539
declare condname1 condition for 1234;
540
declare continue handler for condname1 select 1;
541
declare exit handler for condname1 select 2;
543
ERROR 42000: Duplicate handler declared in the same block
544
create procedure bug9073()
546
declare condname1 condition for sqlstate '42000';
547
declare condname2 condition for sqlstate '42000';
548
declare exit handler for condname1 select 1;
549
declare continue handler for condname2 select 2;
551
ERROR 42000: Duplicate handler declared in the same block
552
create procedure bug9073()
554
declare condname1 condition for sqlstate '42000';
555
declare exit handler for condname1 select 1;
556
declare exit handler for sqlstate '42000' select 2;
558
ERROR 42000: Duplicate handler declared in the same block
559
drop procedure if exists bug9073|
560
create procedure bug9073()
562
declare condname1 condition for sqlstate '42000';
563
declare continue handler for condname1 select 1;
565
declare exit handler for sqlstate '42000' select 2;
567
declare continue handler for sqlstate '42000' select 3;
571
drop procedure bug9073|
572
create procedure bug7047()
573
alter procedure bug7047|
574
ERROR HY000: Can't drop or alter a PROCEDURE from within another stored routine
575
create function bug7047() returns int
577
alter function bug7047;
580
ERROR HY000: Can't drop or alter a FUNCTION from within another stored routine
581
create function bug8408() returns int
586
ERROR 0A000: Not allowed to return a result set from a function
587
create function bug8408() returns int
592
ERROR 0A000: Not allowed to return a result set from a function
593
create function bug8408(a int) returns int
599
ERROR 0A000: Not allowed to return a result set from a function
600
drop function if exists bug8408_f|
601
drop procedure if exists bug8408_p|
602
create function bug8408_f() returns int
607
create procedure bug8408_p()
612
ERROR 0A000: Not allowed to return a result set from a function
613
drop procedure bug8408_p|
614
drop function bug8408_f|
615
create function bug8408() returns int
617
declare n int default 0;
618
select count(*) into n from t1;
621
insert into t1 value (2, 2.7), (3, 3.14), (7, 7.0)|
622
select *,bug8408() from t1|
627
drop function bug8408|
629
drop procedure if exists bug10537|
630
create procedure bug10537()
631
load data local infile '/tmp/somefile' into table t1|
632
ERROR 0A000: LOAD DATA is not allowed in stored procedures
633
drop function if exists bug8409|
634
create function bug8409()
640
ERROR 0A000: FLUSH is not allowed in stored function or trigger
641
create function bug8409() returns int begin reset query cache;
643
ERROR 0A000: RESET is not allowed in stored function or trigger
644
create function bug8409() returns int begin reset master;
646
ERROR 0A000: RESET is not allowed in stored function or trigger
647
create function bug8409() returns int begin reset slave;
649
ERROR 0A000: RESET is not allowed in stored function or trigger
650
create function bug8409() returns int begin flush hosts;
652
ERROR 0A000: FLUSH is not allowed in stored function or trigger
653
create function bug8409() returns int begin flush privileges;
655
ERROR 0A000: FLUSH is not allowed in stored function or trigger
656
create function bug8409() returns int begin flush tables with read lock;
658
ERROR 0A000: FLUSH is not allowed in stored function or trigger
659
create function bug8409() returns int begin flush tables;
661
ERROR 0A000: FLUSH is not allowed in stored function or trigger
662
create function bug8409() returns int begin flush logs;
664
ERROR 0A000: FLUSH is not allowed in stored function or trigger
665
create function bug8409() returns int begin flush status;
667
ERROR 0A000: FLUSH is not allowed in stored function or trigger
668
create function bug8409() returns int begin flush des_key_file;
670
ERROR 0A000: FLUSH is not allowed in stored function or trigger
671
create function bug8409() returns int begin flush user_resources;
673
ERROR 0A000: FLUSH is not allowed in stored function or trigger
674
create procedure bug9529_901234567890123456789012345678901234567890123456789012345()
677
ERROR 42000: Identifier name 'bug9529_901234567890123456789012345678901234567890123456789012345' is too long
678
drop procedure if exists bug17015_0123456789012345678901234567890123456789012345678901234|
679
create procedure bug17015_0123456789012345678901234567890123456789012345678901234()
682
show procedure status like 'bug17015%'|
683
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
684
test bug17015_0123456789012345678901234567890123456789012345678901234 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
685
drop procedure bug17015_0123456789012345678901234567890123456789012345678901234|
686
drop procedure if exists bug10969|
687
create procedure bug10969()
689
declare s1 int default 0;
690
select default(s1) from t30;
692
ERROR 42000: Incorrect column name 's1'
693
create procedure bug10969()
695
declare s1 int default 0;
696
select default(t30.s1) from t30;
698
drop procedure bug10969|
700
create table t1(f1 int);
701
create table t2(f1 int);
702
CREATE PROCEDURE SP001()
704
DECLARE ENDTABLE INT DEFAULT 0;
705
DECLARE TEMP_NUM INT;
706
DECLARE TEMP_SUM INT;
707
DECLARE C1 CURSOR FOR SELECT F1 FROM t1;
708
DECLARE C2 CURSOR FOR SELECT F1 FROM t2;
709
DECLARE CONTINUE HANDLER FOR NOT FOUND SET ENDTABLE = 1;
714
FETCH C1 INTO TEMP_NUM;
715
WHILE ENDTABLE = 0 DO
716
SET TEMP_SUM=TEMP_NUM+TEMP_SUM;
717
FETCH C1 INTO TEMP_NUM;
722
SELECT 'end of proc';
727
ERROR 24000: Cursor is not open
728
drop procedure SP001;
730
drop function if exists bug11394|
731
drop function if exists bug11394_1|
732
drop function if exists bug11394_2|
733
drop procedure if exists bug11394|
734
create function bug11394(i int) returns int
739
return (i in (100, 200, bug11394(i-1), 400));
743
ERROR HY000: Recursive stored functions and triggers are not allowed.
744
drop function bug11394|
745
create function bug11394_1(i int) returns int
750
return (select bug11394_1(i-1));
753
select bug11394_1(2)|
754
ERROR HY000: Recursive stored functions and triggers are not allowed.
755
drop function bug11394_1|
756
create function bug11394_2(i int) returns int return i|
757
select bug11394_2(bug11394_2(10))|
758
bug11394_2(bug11394_2(10))
760
drop function bug11394_2|
761
create procedure bug11394(i int, j int)
764
call bug11394(i - 1,(select 1));
768
ERROR HY000: Recursive limit 0 (as set by the max_sp_recursion_depth variable) was exceeded for routine bug11394
769
set @@max_sp_recursion_depth=10|
771
set @@max_sp_recursion_depth=default|
772
drop procedure bug11394|
773
CREATE PROCEDURE BUG_12490() HELP CONTENTS;
774
ERROR 0A000: HELP is not allowed in stored procedures
775
CREATE FUNCTION BUG_12490() RETURNS INT HELP CONTENTS;
776
ERROR 0A000: HELP is not allowed in stored procedures
777
CREATE TABLE t_bug_12490(a int);
778
CREATE TRIGGER BUG_12490 BEFORE UPDATE ON t_bug_12490 FOR EACH ROW HELP CONTENTS;
779
ERROR 0A000: HELP is not allowed in stored procedures
780
DROP TABLE t_bug_12490;
781
drop function if exists bug11834_1;
782
drop function if exists bug11834_2;
783
create function bug11834_1() returns int return 10;
784
create function bug11834_2() returns int return bug11834_1();
785
prepare stmt from "select bug11834_2()";
792
drop function bug11834_1;
794
ERROR 42000: FUNCTION test.bug11834_1 does not exist
795
deallocate prepare stmt;
796
drop function bug11834_2;
797
DROP FUNCTION IF EXISTS bug12953|
798
CREATE FUNCTION bug12953() RETURNS INT
803
ERROR 0A000: Not allowed to return a result set from a function
804
DROP FUNCTION IF EXISTS bug12995|
805
CREATE FUNCTION bug12995() RETURNS INT
810
ERROR 0A000: HANDLER is not allowed in stored procedures
811
CREATE FUNCTION bug12995() RETURNS INT
813
HANDLER t1 READ FIRST;
816
ERROR 0A000: HANDLER is not allowed in stored procedures
817
CREATE FUNCTION bug12995() RETURNS INT
822
ERROR 0A000: HANDLER is not allowed in stored procedures
824
ERROR 42000: FUNCTION test.bug12995 does not exist
825
drop procedure if exists bug12712;
826
drop function if exists bug12712;
827
create procedure bug12712()
828
set session autocommit = 0;
832
set @au = @@autocommit;
837
set session autocommit = @au;
838
create function bug12712()
845
ERROR HY000: Not allowed to set autocommit from a stored function or trigger
846
drop procedure bug12712|
847
drop function bug12712|
848
create function bug12712()
851
set session autocommit = 0;
854
ERROR HY000: Not allowed to set autocommit from a stored function or trigger
855
create function bug12712()
858
set @@autocommit = 0;
861
ERROR HY000: Not allowed to set autocommit from a stored function or trigger
862
create function bug12712()
865
set local autocommit = 0;
868
ERROR HY000: Not allowed to set autocommit from a stored function or trigger
869
create trigger bug12712
870
before insert on t1 for each row set session autocommit = 0;
871
ERROR HY000: Not allowed to set autocommit from a stored function or trigger
872
drop procedure if exists bug13510_1|
873
drop procedure if exists bug13510_2|
874
drop procedure if exists bug13510_3|
875
drop procedure if exists bug13510_4|
876
create procedure bug13510_1()
878
declare password varchar(10);
879
set password = 'foo1';
882
ERROR 42000: Variable 'password' must be quoted with `...`, or renamed
884
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
885
create procedure bug13510_2()
887
declare names varchar(10);
891
ERROR 42000: Variable 'names' must be quoted with `...`, or renamed
892
create procedure bug13510_3()
894
declare password varchar(10);
895
set `password` = 'foo3';
898
create procedure bug13510_4()
900
declare names varchar(10);
901
set `names` = 'foo4';
910
drop procedure bug13510_3|
911
drop procedure bug13510_4|
912
drop function if exists bug_13627_f|
913
CREATE TABLE t1 (a int)|
914
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN DROP TRIGGER test1; END |
915
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
916
CREATE FUNCTION bug_13627_f() returns int BEGIN DROP TRIGGER test1; return 1; END |
917
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
918
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create table t2 (a int); END |
919
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
920
CREATE FUNCTION bug_13627_f() returns int BEGIN create table t2 (a int); return 1; END |
921
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
922
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create index t1_i on t1 (a); END |
923
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
924
CREATE FUNCTION bug_13627_f() returns int BEGIN create index t1_i on t1 (a); return 1; END |
925
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
926
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN alter table t1 add column b int; END |
927
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
928
CREATE FUNCTION bug_13627_f() returns int BEGIN alter table t1 add column b int; return 1; END |
929
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
930
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN rename table t1 to t2; END |
931
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
932
CREATE FUNCTION bug_13627_f() returns int BEGIN rename table t1 to t2; return 1; END |
933
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
934
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN truncate table t1; END |
935
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
936
CREATE FUNCTION bug_13627_f() returns int BEGIN truncate table t1; return 1; END |
937
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
938
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN drop table t1; END |
939
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
940
CREATE FUNCTION bug_13627_f() returns int BEGIN drop table t1; return 1; END |
941
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
942
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN drop index t1_i on t1; END |
943
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
944
CREATE FUNCTION bug_13627_f() returns int BEGIN drop index t1_i on t1; return 1; END |
945
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
946
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN unlock tables; END |
947
ERROR 0A000: UNLOCK is not allowed in stored procedures
948
CREATE FUNCTION bug_13627_f() returns int BEGIN unlock tables; return 1; END |
949
ERROR 0A000: UNLOCK is not allowed in stored procedures
950
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN LOCK TABLE t1 READ; END |
951
ERROR 0A000: LOCK is not allowed in stored procedures
952
CREATE FUNCTION bug_13627_f() returns int BEGIN LOCK TABLE t1 READ; return 1; END |
953
ERROR 0A000: LOCK is not allowed in stored procedures
954
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create database mysqltest; END |
955
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
956
CREATE FUNCTION bug_13627_f() returns int BEGIN create database mysqltest; return 1; END |
957
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
958
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN drop database mysqltest; END |
959
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
960
CREATE FUNCTION bug_13627_f() returns int BEGIN drop database mysqltest; return 1; END |
961
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
962
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create user 'mysqltest_1'; END |
963
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
964
CREATE FUNCTION bug_13627_f() returns int BEGIN create user 'mysqltest_1'; return 1; END |
965
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
966
CREATE TRIGGER bug21975 BEFORE INSERT ON t1 FOR EACH ROW BEGIN grant select on t1 to 'mysqltest_1'; END |
967
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
968
CREATE FUNCTION bug21975() returns int BEGIN grant select on t1 to 'mysqltest_1'; return 1; END |
969
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
970
CREATE TRIGGER bug21975 BEFORE INSERT ON t1 FOR EACH ROW BEGIN revoke select on t1 from 'mysqltest_1'; END |
971
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
972
CREATE FUNCTION bug21975() returns int BEGIN revoke select on t1 from 'mysqltest_1'; return 1; END |
973
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
974
CREATE TRIGGER bug21975 BEFORE INSERT ON t1 FOR EACH ROW BEGIN revoke all privileges on *.* from 'mysqltest_1'; END |
975
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
976
CREATE FUNCTION bug21975() returns int BEGIN revoke all privileges on *.* from 'mysqltest_1'; return 1; END |
977
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
978
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN drop user 'mysqltest_1'; END |
979
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
980
CREATE FUNCTION bug_13627_f() returns int BEGIN drop user 'mysqltest_1'; return 1; END |
981
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
982
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN rename user 'mysqltest_2' to 'mysqltest_1'; END |
983
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
984
CREATE FUNCTION bug_13627_f() returns int BEGIN rename user 'mysqltest_2' to 'mysqltest_1'; return 1; END |
985
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
986
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create view v1 as select 1; END |
987
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
988
CREATE FUNCTION bug_13627_f() returns int BEGIN create view v1 as select 1; return 1; END |
989
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
990
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN alter view v1 as select 1; END |
991
ERROR 0A000: ALTER VIEW is not allowed in stored procedures
992
CREATE FUNCTION bug_13627_f() returns int BEGIN alter view v1 as select 1; return 1; END |
993
ERROR 0A000: ALTER VIEW is not allowed in stored procedures
994
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN drop view v1; END |
995
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
996
CREATE FUNCTION bug_13627_f() returns int BEGIN drop view v1; return 1; END |
997
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
998
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create trigger tr2 before insert on t1 for each row do select 1; END |
999
ERROR 2F003: Can't create a TRIGGER from within another stored routine
1000
CREATE FUNCTION bug_13627_f() returns int BEGIN create trigger tr2 before insert on t1 for each row do select 1; return 1; END |
1001
ERROR 2F003: Can't create a TRIGGER from within another stored routine
1002
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN drop function bug_13627_f; END |
1003
ERROR HY000: Can't drop or alter a FUNCTION from within another stored routine
1004
CREATE FUNCTION bug_13627_f() returns int BEGIN drop function bug_13627_f; return 1; END |
1005
ERROR HY000: Can't drop or alter a FUNCTION from within another stored routine
1006
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create function f2 () returns int return 1; END |
1007
ERROR 2F003: Can't create a FUNCTION from within another stored routine
1008
CREATE FUNCTION bug_13627_f() returns int BEGIN create function f2 () returns int return 1; return 1; END |
1009
ERROR 2F003: Can't create a FUNCTION from within another stored routine
1010
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW
1012
CREATE TEMPORARY TABLE t2 (a int);
1013
DROP TEMPORARY TABLE t2;
1015
CREATE FUNCTION bug_13627_f() returns int
1017
CREATE TEMPORARY TABLE t2 (a int);
1018
DROP TEMPORARY TABLE t2;
1022
drop function bug_13627_f|
1023
drop function if exists bug12329;
1025
Note 1305 FUNCTION test.bug12329 does not exist
1026
create table t1 as select 1 a;
1027
create table t2 as select 1 a;
1028
create function bug12329() returns int return (select a from t1);
1029
prepare stmt1 from 'select bug12329()';
1033
drop function bug12329;
1034
create function bug12329() returns int return (select a+100 from t2);
1041
deallocate prepare stmt1;
1042
drop function bug12329;
1044
create database mysqltest1;
1046
drop database mysqltest1;
1047
create function f1() returns int return 1;
1048
ERROR 3D000: No database selected
1049
create procedure p1(out param1 int)
1051
select count(*) into param1 from t3;
1053
ERROR 3D000: No database selected
1055
DROP PROCEDURE IF EXISTS bug13037_p1;
1056
DROP PROCEDURE IF EXISTS bug13037_p2;
1057
DROP PROCEDURE IF EXISTS bug13037_p3;
1058
CREATE PROCEDURE bug13037_p1()
1060
IF bug13037_foo THEN
1064
CREATE PROCEDURE bug13037_p2()
1066
SET @bug13037_foo = bug13037_bar;
1068
CREATE PROCEDURE bug13037_p3()
1070
SELECT bug13037_foo;
1074
ERROR 42S22: Unknown column 'bug13037_foo' in 'field list'
1076
ERROR 42S22: Unknown column 'bug13037_bar' in 'field list'
1078
ERROR 42S22: Unknown column 'bug13037_foo' in 'field list'
1080
ERROR 42S22: Unknown column 'bug13037_foo' in 'field list'
1082
ERROR 42S22: Unknown column 'bug13037_bar' in 'field list'
1084
ERROR 42S22: Unknown column 'bug13037_foo' in 'field list'
1085
DROP PROCEDURE bug13037_p1;
1086
DROP PROCEDURE bug13037_p2;
1087
DROP PROCEDURE bug13037_p3;
1088
create database mysqltest1;
1089
create database mysqltest2;
1091
drop database mysqltest1;
1092
create procedure mysqltest2.p1() select version();
1093
create procedure p2() select version();
1094
ERROR 3D000: No database selected
1096
show procedure status;
1097
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
1098
mysqltest2 p1 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
1099
drop database mysqltest2;
1101
DROP FUNCTION IF EXISTS bug13012|
1102
CREATE FUNCTION bug13012() RETURNS INT
1107
ERROR 0A000: Not allowed to return a result set from a function
1108
create table t1 (a int)|
1109
CREATE PROCEDURE bug13012_1() REPAIR TABLE t1|
1110
CREATE FUNCTION bug13012_2() RETURNS INT
1115
SELECT bug13012_2()|
1116
ERROR 0A000: Not allowed to return a result set from a function
1118
drop procedure bug13012_1|
1119
drop function bug13012_2|
1120
drop function if exists bug11555_1;
1121
drop function if exists bug11555_2;
1122
drop view if exists v1, v2, v3, v4;
1123
create function bug11555_1() returns int return (select max(i) from t1);
1124
create function bug11555_2() returns int return bug11555_1();
1125
create view v1 as select bug11555_1();
1127
create view v2 as select bug11555_2();
1129
create table t1 (i int);
1130
create view v1 as select bug11555_1();
1131
create view v2 as select bug11555_2();
1132
create view v3 as select * from v1;
1135
ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
1137
ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
1139
ERROR HY000: View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
1140
create view v4 as select * from v1;
1141
drop view v1, v2, v3, v4;
1142
drop function bug11555_1;
1143
drop function bug11555_2;
1144
create table t1 (i int);
1145
create table t2 (i int);
1146
create trigger t1_ai after insert on t1 for each row insert into t2 values (new.i);
1147
create view v1 as select * from t1;
1149
insert into v1 values (1);
1150
ERROR 42S02: Table 'test.t2' doesn't exist
1152
create function bug11555_1() returns int return (select max(i) from t2);
1153
create trigger t1_ai after insert on t1 for each row set @a:=bug11555_1();
1154
insert into v1 values (2);
1155
ERROR 42S02: Table 'test.t2' doesn't exist
1156
drop function bug11555_1;
1159
drop procedure if exists ` bug15658`;
1160
create procedure ``() select 1;
1161
ERROR 42000: Incorrect routine name ''
1162
create procedure ` `() select 1;
1163
ERROR 42000: Incorrect routine name ' '
1164
create procedure `bug15658 `() select 1;
1165
ERROR 42000: Incorrect routine name 'bug15658 '
1166
create procedure ``.bug15658() select 1;
1167
ERROR 42000: Incorrect database name ''
1168
create procedure `x `.bug15658() select 1;
1169
ERROR 42000: Incorrect database name 'x '
1170
create procedure ` bug15658`() select 1;
1174
show procedure status;
1175
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
1176
test bug15658 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
1177
drop procedure ` bug15658`;
1178
drop function if exists bug14270;
1179
drop table if exists t1;
1180
create table t1 (s1 int primary key);
1181
create function bug14270() returns int
1183
load index into cache t1;
1186
ERROR 0A000: Not allowed to return a result set from a function
1187
create function bug14270() returns int
1189
cache index t1 key (`primary`) in keycache1;
1192
ERROR 0A000: Not allowed to return a result set from a function
1194
drop procedure if exists bug15091;
1195
create procedure bug15091()
1197
declare selectstr varchar(6000) default ' ';
1198
declare conditionstr varchar(5000) default '';
1199
set selectstr = concat(selectstr,
1202
'in (',conditionstr, ')');
1205
ERROR 42S02: Unknown table 'c' in field list
1206
drop procedure bug15091;
1207
drop function if exists bug16896;
1208
create aggregate function bug16896() returns int return 1;
1209
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '() returns int return 1' at line 1
1210
DROP PROCEDURE IF EXISTS bug14702;
1211
CREATE IF NOT EXISTS PROCEDURE bug14702()
1214
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF NOT EXISTS PROCEDURE bug14702()
1217
CREATE PROCEDURE IF NOT EXISTS bug14702()
1220
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF NOT EXISTS bug14702()
1223
DROP TABLE IF EXISTS t1;
1224
CREATE TABLE t1 (i INT);
1225
CREATE PROCEDURE bug20953() CREATE VIEW v AS SELECT 1 INTO @a;
1226
ERROR HY000: View's SELECT contains a 'INTO' clause
1227
CREATE PROCEDURE bug20953() CREATE VIEW v AS SELECT 1 INTO DUMPFILE "file";
1228
ERROR HY000: View's SELECT contains a 'INTO' clause
1229
CREATE PROCEDURE bug20953() CREATE VIEW v AS SELECT 1 INTO OUTFILE "file";
1230
ERROR HY000: View's SELECT contains a 'INTO' clause
1231
CREATE PROCEDURE bug20953()
1232
CREATE VIEW v AS SELECT i FROM t1 PROCEDURE ANALYSE();
1233
ERROR HY000: View's SELECT contains a 'PROCEDURE' clause
1234
CREATE PROCEDURE bug20953() CREATE VIEW v AS SELECT 1 FROM (SELECT 1) AS d1;
1235
ERROR HY000: View's SELECT contains a subquery in the FROM clause
1236
CREATE PROCEDURE bug20953(i INT) CREATE VIEW v AS SELECT i;
1237
ERROR HY000: View's SELECT contains a variable or parameter
1238
CREATE PROCEDURE bug20953()
1241
CREATE VIEW v AS SELECT i;
1243
ERROR HY000: View's SELECT contains a variable or parameter
1244
PREPARE stmt FROM "CREATE VIEW v AS SELECT ?";
1245
ERROR HY000: View's SELECT contains a variable or parameter
1247
drop tables if exists t1;
1248
drop procedure if exists bug24491;
1249
create table t1 (id int primary key auto_increment, value varchar(10));
1250
insert into t1 (id, value) values (1, 'FIRST'), (2, 'SECOND'), (3, 'THIRD');
1251
create procedure bug24491()
1252
insert into t1 (id, value) select * from (select 4 as i, 'FOURTH' as v) as y on duplicate key update v = 'DUP';
1254
ERROR 42S22: Unknown column 'v' in 'field list'
1256
ERROR 42S22: Unknown column 'v' in 'field list'
1257
drop procedure bug24491;
1258
create procedure bug24491()
1259
insert into t1 (id, value) select * from (select 4 as id, 'FOURTH' as value) as y on duplicate key update y.value = 'DUP';
1261
ERROR 42S22: Unknown column 'y.value' in 'field list'
1263
ERROR 42S22: Unknown column 'y.value' in 'field list'
1264
drop procedure bug24491;
1266
DROP FUNCTION IF EXISTS bug18914_f1;
1267
DROP FUNCTION IF EXISTS bug18914_f2;
1268
DROP PROCEDURE IF EXISTS bug18914_p1;
1269
DROP PROCEDURE IF EXISTS bug18914_p2;
1270
DROP TABLE IF EXISTS t1, t2;
1271
CREATE TABLE t1 (i INT);
1272
CREATE PROCEDURE bug18914_p1() CREATE TABLE t2 (i INT);
1273
CREATE PROCEDURE bug18914_p2() DROP TABLE IF EXISTS no_such_table;
1274
CREATE FUNCTION bug18914_f1() RETURNS INT
1279
CREATE FUNCTION bug18914_f2() RETURNS INT
1284
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
1286
INSERT INTO t1 VALUES (1);
1287
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
1288
SELECT bug18914_f1();
1289
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
1290
SELECT bug18914_f2();
1291
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
1293
ERROR 42S02: Table 'test.t2' doesn't exist
1294
DROP FUNCTION bug18914_f1;
1295
DROP FUNCTION bug18914_f2;
1296
DROP PROCEDURE bug18914_p1;
1297
DROP PROCEDURE bug18914_p2;
1299
drop table if exists bogus_table_20713;
1300
drop function if exists func_20713_a;
1301
drop function if exists func_20713_b;
1302
create table bogus_table_20713( id int(10) not null primary key);
1303
insert into bogus_table_20713 values (1), (2), (3);
1304
create function func_20713_a() returns int(11)
1307
declare continue handler for sqlexception set id=null;
1309
set id = (select id from bogus_table_20713 where id = 3);
1313
create function func_20713_b() returns int(11)
1316
declare continue handler for sqlstate value '42S02' set id=null;
1318
set id = (select id from bogus_table_20713 where id = 3);
1323
select func_20713_a();
1330
select func_20713_b();
1336
drop table bogus_table_20713;
1338
select func_20713_a();
1345
select func_20713_b();
1351
drop function if exists func_20713_a;
1352
drop function if exists func_20713_b;
1353
drop table if exists table_25345_a;
1354
drop table if exists table_25345_b;
1355
drop procedure if exists proc_25345;
1356
drop function if exists func_25345;
1357
drop function if exists func_25345_b;
1358
create table table_25345_a (a int);
1359
create table table_25345_b (b int);
1360
create procedure proc_25345()
1362
declare c1 cursor for select a from table_25345_a;
1363
declare c2 cursor for select b from table_25345_b;
1366
create function func_25345() returns int(11)
1371
create function func_25345_b() returns int(11)
1373
declare c1 cursor for select a from table_25345_a;
1374
declare c2 cursor for select b from table_25345_b;
1380
select func_25345();
1381
ERROR 0A000: Not allowed to return a result set from a function
1382
select func_25345_b();
1385
drop table table_25345_a;
1389
select func_25345();
1390
ERROR 0A000: Not allowed to return a result set from a function
1391
select func_25345_b();
1394
drop table table_25345_b;
1395
drop procedure proc_25345;
1396
drop function func_25345;
1397
drop function func_25345_b;
1399
drop function if exists bug20701;
1400
create function bug20701() returns varchar(25) binary return "test";
1401
ERROR 42000: This version of MySQL doesn't yet support 'return value collation'
1402
create function bug20701() returns varchar(25) return "test";
1403
drop function bug20701;
1404
create procedure proc_26503_error_1()
1409
declare continue handler for sqlexception
1413
select "do something";
1415
until true end repeat retry;
1417
ERROR 42000: ITERATE with no matching label: retry
1418
create procedure proc_26503_error_2()
1423
declare continue handler for sqlexception
1425
select "do something";
1427
until true end repeat retry;
1429
ERROR 42000: ITERATE with no matching label: retry
1430
create procedure proc_26503_error_3()
1435
declare continue handler for sqlexception
1439
select "do something";
1441
until true end repeat retry;
1443
ERROR 42000: LEAVE with no matching label: retry
1444
create procedure proc_26503_error_4()
1449
declare continue handler for sqlexception
1451
select "do something";
1453
until true end repeat retry;
1455
ERROR 42000: LEAVE with no matching label: retry
1456
drop procedure if exists proc_28360;
1457
drop function if exists func_28360;
1458
CREATE PROCEDURE proc_28360()
1460
ALTER DATABASE `#mysql50#upgrade-me` UPGRADE DATA DIRECTORY NAME;
1462
ERROR HY000: Can't drop or alter a DATABASE from within another stored routine
1463
CREATE FUNCTION func_28360() RETURNS int
1465
ALTER DATABASE `#mysql50#upgrade-me` UPGRADE DATA DIRECTORY NAME;
1468
ERROR HY000: Can't drop or alter a DATABASE from within another stored routine
1469
DROP PROCEDURE IF EXISTS p1;
1470
CREATE PROCEDURE p1()
1472
DECLARE c char(100);
1473
DECLARE cur1 CURSOR FOR SHOW TABLES;
1479
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SHOW TABLES;
1485
DROP DATABASE IF EXISTS mysqltest;
1486
CREATE DATABASE mysqltest;
1488
DROP DATABASE mysqltest;
1489
SELECT inexistent(), 1 + ,;
1490
ERROR 42000: FUNCTION inexistent does not exist
1491
SELECT inexistent();
1492
ERROR 42000: FUNCTION inexistent does not exist
1493
SELECT .inexistent();
1494
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '()' at line 1
1495
SELECT ..inexistent();
1496
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.inexistent()' at line 1
1498
create function f1() returns int
1500
set @test = 1, password = password('foo');
1503
ERROR HY000: Not allowed to set autocommit from a stored function or trigger
1505
before insert on t2 for each row set password = password('foo');|
1506
ERROR HY000: Not allowed to set autocommit from a stored function or trigger
1507
drop function if exists f1;
1508
drop function if exists f2;
1509
drop table if exists t1, t2;
1510
create function f1() returns int
1512
drop temporary table t1;
1515
create temporary table t1 as select f1();
1516
ERROR HY000: Can't reopen table: 't1'
1517
create function f2() returns int
1519
create temporary table t2 as select f1();
1522
create temporary table t1 as select f2();
1523
ERROR HY000: Can't reopen table: 't1'
1526
create function f1() returns int
1528
drop temporary table t2,t1;
1531
create function f2() returns int
1533
create temporary table t2 as select f1();
1536
create temporary table t1 as select f2();
1537
ERROR HY000: Can't reopen table: 't2'
1540
create temporary table t2(a int);
1543
create function f2() returns int
1545
drop temporary table t2;
1553
ERROR 42S02: Unknown table 'test.t2'
1555
drop procedure if exists proc_33983_a;
1556
drop procedure if exists proc_33983_b;
1557
drop procedure if exists proc_33983_c;
1558
drop procedure if exists proc_33983_d;
1559
create procedure proc_33983_a()
1569
ERROR 42000: End-label label1 without match
1570
create procedure proc_33983_b()
1577
until FALSE end repeat label1;
1578
until FALSE end repeat;
1580
ERROR 42000: End-label label1 without match
1581
create procedure proc_33983_c()
1591
ERROR 42000: End-label label1 without match
1592
create procedure proc_33983_d()
1602
ERROR 42000: End-label label1 without match
1603
CREATE TABLE t1 (a INT)|
1604
INSERT INTO t1 VALUES (1),(2)|
1605
CREATE PROCEDURE p1(a INT) BEGIN END|
1606
CALL p1((SELECT * FROM t1))|
1607
ERROR 21000: Subquery returns more than 1 row
1608
DROP PROCEDURE IF EXISTS p1|
1610
drop procedure if exists p1;
1611
create procedure p1()
1613
create table t1 (a int) engine=MyISAM;
1619
drop procedure if exists proc_8759;
1620
create procedure proc_8759()
1622
declare should_be_illegal condition for sqlstate '00000';
1623
declare continue handler for should_be_illegal set @x=0;
1625
ERROR 42000: Bad SQLSTATE: '00000'
1626
create procedure proc_8759()
1628
declare continue handler for sqlstate '00000' set @x=0;
1630
ERROR 42000: Bad SQLSTATE: '00000'
1631
drop procedure if exists proc_36510;
1632
create procedure proc_36510()
1634
declare should_be_illegal condition for sqlstate '00123';
1635
declare continue handler for should_be_illegal set @x=0;
1637
ERROR 42000: Bad SQLSTATE: '00123'
1638
create procedure proc_36510()
1640
declare continue handler for sqlstate '00123' set @x=0;
1642
ERROR 42000: Bad SQLSTATE: '00123'
1643
create procedure proc_36510()
1645
declare should_be_illegal condition for 0;
1646
declare continue handler for should_be_illegal set @x=0;
1648
ERROR HY000: Incorrect CONDITION value: '0'
1649
create procedure proc_36510()
1651
declare continue handler for 0 set @x=0;
1653
ERROR HY000: Incorrect CONDITION value: '0'
1654
drop procedure if exists p1;
1655
set @old_recursion_depth = @@max_sp_recursion_depth;
1656
set @@max_sp_recursion_depth = 255;
1657
create procedure p1(a int)
1659
declare continue handler for 1436 -- ER_STACK_OVERRUN_NEED_MORE
1664
set @@max_sp_recursion_depth = @old_recursion_depth;
1666
LOAD DATA INFILE '../../tmp/proc.txt' INTO TABLE mysql.proc;
1667
CREATE TABLE t1 (a INT, b INT);
1668
INSERT INTO t1 VALUES (1,1), (2,2);
1669
SELECT MAX (a) FROM t1 WHERE b = 999999;
1670
ERROR 42000: FUNCTION test.MAX does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual
1671
SELECT AVG (a) FROM t1 WHERE b = 999999;
1674
SELECT non_existent (a) FROM t1 WHERE b = 999999;
1675
ERROR 42000: FUNCTION test.non_existent does not exist
1677
CREATE TABLE t1 ( f2 INTEGER, f3 INTEGER );
1678
INSERT INTO t1 VALUES ( 1, 1 );
1679
CREATE FUNCTION func_1 () RETURNS INTEGER
1681
INSERT INTO t1 SELECT * FROM t1 ;
1684
INSERT INTO t1 SELECT * FROM (SELECT 2 AS f1, 2 AS f2) AS A WHERE func_1() = 5;
1685
ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
1686
DROP FUNCTION func_1;
1689
# Bug #47788: Crash in TABLE_LIST::hide_view_error on UPDATE + VIEW +
1690
# SP + MERGE + ALTER
1692
CREATE TABLE t1 (pk INT, b INT, KEY (b));
1693
CREATE ALGORITHM = TEMPTABLE VIEW v1 AS SELECT * FROM t1;
1694
CREATE PROCEDURE p1 (a int) UPDATE IGNORE v1 SET b = a;
1696
ERROR HY000: The target table v1 of the UPDATE is not updatable
1697
ALTER TABLE t1 CHANGE COLUMN b b2 INT;
1699
ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
1704
# Bug#12428824 - PARSER STACK OVERFLOW AND CRASH IN SP_ADD_USED_ROUTINE
1705
# WITH OBSCURE QUERY
1707
SELECT very_long_fn_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999();
1708
ERROR 42000: Identifier name 'very_long_fn_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222' is too long
1709
CALL very_long_pr_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999();
1710
ERROR 42000: Identifier name 'very_long_pr_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222' is too long
1711
SELECT very_long_db_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999.simple_func();
1712
ERROR 42000: Incorrect database name 'very_long_db_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222'
1713
CALL very_long_db_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999.simple_proc();
1714
ERROR 42000: Incorrect database name 'very_long_db_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222'
1715
SELECT db_name.very_long_fn_name_111111111111111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999999999999999999();
1716
ERROR 42000: Identifier name 'very_long_fn_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222' is too long
1717
CALL db_name.very_long_pr_name_111111111111111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999999999999999999();
1718
ERROR 42000: Identifier name 'very_long_pr_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222' is too long
1721
# Bug#23032: Handlers declared in a SP do not handle warnings generated in sub-SP
1726
DROP PROCEDURE IF EXISTS p1;
1727
DROP PROCEDURE IF EXISTS p2;
1728
DROP PROCEDURE IF EXISTS p3;
1729
DROP PROCEDURE IF EXISTS p4;
1730
DROP PROCEDURE IF EXISTS p5;
1731
DROP PROCEDURE IF EXISTS p6;
1732
CREATE PROCEDURE p1()
1734
SELECT CAST('10 ' as unsigned integer);
1738
CREATE PROCEDURE p2()
1740
SELECT CAST('10 ' as unsigned integer);
1743
CAST('10 ' as unsigned integer)
1747
CAST('10 ' as unsigned integer)
1750
Warning 1292 Truncated incorrect INTEGER value: '10 '
1756
DROP TABLE IF EXISTS t1;
1757
CREATE TABLE t1(a INT);
1758
CREATE PROCEDURE p1()
1760
DECLARE c INT DEFAULT 0;
1761
DECLARE CONTINUE HANDLER FOR SQLWARNING
1764
SELECT 'Warning caught!' AS Msg;
1766
CALL p2(); # 1 warning
1767
CALL p3(); # 1 warning
1768
CALL p4(); # No warnings
1769
CALL p5(); # 1 warning
1771
SELECT @@warning_count;
1774
CREATE PROCEDURE p2()
1776
SELECT CAST('2 ' as unsigned integer);
1778
CREATE PROCEDURE p3()
1780
SELECT CAST('3 ' as unsigned integer);
1781
SELECT 1; # does not clear the warning
1783
CREATE PROCEDURE p4()
1785
SELECT CAST('4 ' as unsigned integer);
1786
INSERT INTO t1 VALUES(1); # Clears the warning
1788
CREATE PROCEDURE p5()
1790
SELECT CAST('5 ' as unsigned integer);
1793
CREATE PROCEDURE p6()
1795
SELECT CAST('6 ' as unsigned integer);
1798
CREATE PROCEDURE p7()
1800
DECLARE c INT DEFAULT 0;
1801
DECLARE CONTINUE HANDLER FOR SQLWARNING
1804
SELECT 'Warning caught!' AS Msg;
1811
CAST('2 ' as unsigned integer)
1815
CAST('3 ' as unsigned integer)
1821
CAST('4 ' as unsigned integer)
1823
CAST('5 ' as unsigned integer)
1825
CAST('2 ' as unsigned integer)
1836
CAST('6 ' as unsigned integer)
1839
Warning 1292 Truncated incorrect INTEGER value: '6 '
1854
# - Case 3: check that "Exception trumps No Data".
1856
DROP TABLE IF EXISTS t1;
1857
CREATE TABLE t1(a INT);
1858
INSERT INTO t1 VALUES (1), (2), (3);
1859
CREATE PROCEDURE p1()
1861
DECLARE c CURSOR FOR SELECT a FROM t1;
1866
DECLARE EXIT HANDLER FOR SQLEXCEPTION
1867
SELECT "Error caught (expected)";
1868
DECLARE EXIT HANDLER FOR NOT FOUND
1869
SELECT "End of Result Set found!";
1871
FETCH c INTO v1, v2;
1875
SELECT a INTO @foo FROM t1 LIMIT 1; # Clear warning stack
1878
Error caught (expected)
1879
Error caught (expected)
1883
# Bug#36185: Incorrect precedence for warning and exception handlers
1885
DROP TABLE IF EXISTS t1;
1886
DROP PROCEDURE IF EXISTS p1;
1887
CREATE TABLE t1 (a INT, b INT NOT NULL);
1888
CREATE PROCEDURE p1()
1890
DECLARE CONTINUE HANDLER FOR SQLWARNING SELECT 'warning';
1891
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SELECT 'exception';
1892
INSERT INTO t1 VALUES (CAST('10 ' AS SIGNED), NULL);
1900
# Bug#5889: Exit handler for a warning doesn't hide the warning in trigger
1902
CREATE TABLE t1(a INT, b INT);
1903
INSERT INTO t1 VALUES (1, 2);
1904
CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW
1906
DECLARE EXIT HANDLER FOR SQLWARNING
1908
SET NEW.a = 99999999999;
1910
UPDATE t1 SET b = 20;
1919
# Bug#9857: Stored procedures: handler for sqlwarning ignored
1921
SET @sql_mode_saved = @@sql_mode;
1922
SET sql_mode = traditional;
1923
CREATE PROCEDURE p1()
1925
DECLARE CONTINUE HANDLER FOR SQLWARNING
1926
SELECT 'warning caught (expected)';
1929
CREATE PROCEDURE p2()
1931
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
1932
SELECT 'error caught (unexpected)';
1938
warning caught (expected)
1939
warning caught (expected)
1946
Warning 1365 Division by 0
1949
Warning 1365 Division by 0
1952
SET sql_mode = @sql_mode_saved;
1954
# Bug#55850: Trigger warnings not cleared.
1956
DROP TABLE IF EXISTS t1;
1957
DROP TABLE IF EXISTS t2;
1958
DROP PROCEDURE IF EXISTS p1;
1959
CREATE TABLE t1(x SMALLINT, y SMALLINT, z SMALLINT);
1960
CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT,
1961
d SMALLINT, e SMALLINT, f SMALLINT);
1962
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
1963
INSERT INTO t2(a, b, c) VALUES(99999, 99999, 99999);
1964
CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW
1965
INSERT INTO t2(d, e, f) VALUES(99999, 99999, 99999);
1966
CREATE PROCEDURE p1()
1967
INSERT INTO t1 VALUES(99999, 99999, 99999);
1971
Warning 1264 Out of range value for column 'x' at row 1
1972
Warning 1264 Out of range value for column 'y' at row 1
1973
Warning 1264 Out of range value for column 'z' at row 1
1977
Warning 1264 Out of range value for column 'x' at row 1
1978
Warning 1264 Out of range value for column 'y' at row 1
1979
Warning 1264 Out of range value for column 'z' at row 1
1984
# ----------------------------------------------------------------------
1985
CREATE TABLE t1(x SMALLINT, y SMALLINT, z SMALLINT);
1986
CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT NOT NULL);
1987
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
1989
INSERT INTO t2 VALUES(
1990
CAST('111111 ' AS SIGNED),
1991
CAST('222222 ' AS SIGNED),
1994
CREATE PROCEDURE p1()
1995
INSERT INTO t1 VALUES(99999, 99999, 99999);
1998
ERROR 23000: Column 'c' cannot be null
2002
Warning 1264 Out of range value for column 'x' at row 1
2003
Warning 1264 Out of range value for column 'y' at row 1
2004
Warning 1264 Out of range value for column 'z' at row 1
2005
Warning 1292 Truncated incorrect INTEGER value: '111111 '
2006
Warning 1264 Out of range value for column 'a' at row 1
2007
Warning 1292 Truncated incorrect INTEGER value: '222222 '
2008
Warning 1264 Out of range value for column 'b' at row 1
2009
Error 1048 Column 'c' cannot be null
2015
###################################################################
2016
# Tests for the following bugs:
2017
# - Bug#11763171: 55852 - Possibly inappropriate handler activation.
2018
# - Bug#11749343: 38806 - Wrong scope for SQL HANDLERS in SP.
2019
###################################################################
2022
# -- Check that SQL-conditions thrown by Statement-blocks are
2023
# -- handled by Handler-decl blocks properly.
2025
CREATE PROCEDURE p1()
2027
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2028
SELECT 'H1' AS HandlerId;
2029
DECLARE CONTINUE HANDLER FOR SQLWARNING
2030
SELECT 'H2' AS HandlerId;
2031
SIGNAL SQLSTATE '01000'; # Should be handled by H2.
2038
# -- Check that SQL-conditions thrown by Statement-blocks are
2039
# -- handled by Handler-decl blocks properly in case of nested
2042
CREATE PROCEDURE p2()
2044
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2045
SELECT 'H1' AS HandlerId;
2046
DECLARE CONTINUE HANDLER FOR SQLWARNING
2047
SELECT 'H2' AS HandlerId;
2049
SELECT 'B1' AS BlockId;
2051
SELECT 'B2' AS BlockId;
2053
SELECT 'B3' AS BlockId;
2054
SIGNAL SQLSTATE '01000'; # Should be handled by H2.
2070
# -- Check SQL-handler resolution rules.
2072
CREATE PROCEDURE p3()
2074
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2075
SELECT 'H1' AS HandlerId;
2076
DECLARE CONTINUE HANDLER FOR SQLWARNING
2077
SELECT 'H2' AS HandlerId;
2078
DECLARE CONTINUE HANDLER FOR SQLSTATE '01000'
2079
SELECT 'H3' AS HandlerId;
2080
SIGNAL SQLSTATE '01000'; # Should be handled by H3.
2087
CREATE PROCEDURE p4()
2089
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2090
SELECT 'H1' AS HandlerId;
2091
DECLARE CONTINUE HANDLER FOR SQLSTATE '01000'
2092
SELECT 'H2' AS HandlerId;
2093
DECLARE CONTINUE HANDLER FOR SQLWARNING
2094
SELECT 'H3' AS HandlerId;
2095
SIGNAL SQLSTATE '01000'; # Should be handled by H2.
2102
CREATE PROCEDURE p5()
2104
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2105
SELECT 'H1' AS HandlerId;
2106
DECLARE CONTINUE HANDLER FOR SQLSTATE '01000'
2107
SELECT 'H2' AS HandlerId;
2109
DECLARE CONTINUE HANDLER FOR SQLWARNING
2110
SELECT 'H3' AS HandlerId;
2111
SIGNAL SQLSTATE '01000'; # Should be handled by H3.
2119
# -- Check that handlers don't handle its own exceptions.
2121
CREATE PROCEDURE p6()
2123
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2125
SELECT 'H1' AS HandlerId;
2126
SIGNAL SQLSTATE 'HY000'; # Should *not* be handled by H1.
2128
SELECT 'S1' AS SignalId;
2129
SIGNAL SQLSTATE 'HY000'; # Should be handled by H1.
2137
ERROR HY000: Unhandled user-defined exception condition
2139
# -- Check that handlers don't handle its own warnings.
2141
CREATE PROCEDURE p7()
2143
DECLARE CONTINUE HANDLER FOR SQLWARNING
2145
SELECT 'H1' AS HandlerId;
2146
SIGNAL SQLSTATE '01000'; # Should *not* be handled by H1.
2148
SELECT 'S1' AS SignalId;
2149
SIGNAL SQLSTATE '01000'; # Should be handled by H1.
2158
Warning 1642 Unhandled user-defined warning condition
2160
# -- Check that conditions for handlers are not handled by the handlers
2161
# -- from the same block.
2163
CREATE PROCEDURE p8()
2165
DECLARE CONTINUE HANDLER FOR SQLWARNING
2166
SELECT 'H1' AS HandlerId;
2167
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2169
SELECT 'H2' AS HandlerId;
2170
SIGNAL SQLSTATE '01000'; # Should *not* be handled by H1.
2172
SELECT 'S1' AS SignalId;
2173
SIGNAL SQLSTATE 'HY000'; # Should be handled by H2.
2182
Warning 1642 Unhandled user-defined warning condition
2184
# -- Check that conditions for handlers are not handled by the handlers
2185
# -- from the same block even if they are thrown deep down the stack.
2187
CREATE PROCEDURE p9()
2189
DECLARE CONTINUE HANDLER FOR SQLSTATE '01000'
2190
SELECT 'Wrong:H1:1' AS HandlerId;
2191
DECLARE CONTINUE HANDLER FOR SQLWARNING
2192
SELECT 'Wrong:H1:2' AS HandlerId;
2193
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2195
DECLARE CONTINUE HANDLER FOR SQLSTATE '01000'
2196
SELECT 'Wrong:H2:1' AS HandlerId;
2197
DECLARE CONTINUE HANDLER FOR SQLWARNING
2198
SELECT 'Wrong:H2:2' AS HandlerId;
2199
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2201
DECLARE CONTINUE HANDLER FOR SQLSTATE '01000'
2202
SELECT 'Wrong:H3:1' AS HandlerId;
2203
DECLARE CONTINUE HANDLER FOR SQLWARNING
2204
SELECT 'Wrong:H3:2' AS HandlerId;
2205
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2207
DECLARE CONTINUE HANDLER FOR SQLSTATE '01000'
2208
SELECT 'Wrong:H4:1' AS HandlerId;
2209
DECLARE CONTINUE HANDLER FOR SQLWARNING
2210
SELECT 'Wrong:H4:2' AS HandlerId;
2211
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2213
DECLARE CONTINUE HANDLER FOR SQLSTATE '01000'
2214
SELECT 'Wrong:H5:1' AS HandlerId;
2215
DECLARE CONTINUE HANDLER FOR SQLWARNING
2216
SELECT 'Wrong:H5:2' AS HandlerId;
2217
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2219
DECLARE CONTINUE HANDLER FOR SQLSTATE '01000'
2220
SELECT 'Wrong:H6:1' AS HandlerId;
2221
DECLARE CONTINUE HANDLER FOR SQLWARNING
2222
SELECT 'Wrong:H6:2' AS HandlerId;
2223
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2225
SELECT 'H2' AS HandlerId;
2226
SIGNAL SQLSTATE '01000'; # Should *not* be handled by H1.
2228
SELECT 'S6' AS SignalId;
2229
SIGNAL SQLSTATE 'HY000';
2231
SELECT 'S5' AS SignalId;
2232
SIGNAL SQLSTATE 'HY000';
2234
SELECT 'S4' AS SignalId;
2235
SIGNAL SQLSTATE 'HY000';
2237
SELECT 'S3' AS SignalId;
2238
SIGNAL SQLSTATE 'HY000';
2240
SELECT 'S2' AS SignalId;
2241
SIGNAL SQLSTATE 'HY000';
2243
SELECT 'S1' AS SignalId;
2244
SIGNAL SQLSTATE 'HY000'; # Should be handled by H2.
2263
Warning 1642 Unhandled user-defined warning condition
2265
# -- Check that handlers are choosen properly in case of deep stack and
2266
# -- nested SQL-blocks.
2268
CREATE PROCEDURE p10()
2270
DECLARE CONTINUE HANDLER FOR SQLSTATE '01000'
2271
SELECT 'H1' AS HandlerId;
2272
DECLARE CONTINUE HANDLER FOR SQLWARNING
2273
SELECT 'H2' AS HandlerId;
2277
DECLARE CONTINUE HANDLER FOR SQLSTATE '01000'
2278
SELECT 'Wrong:H1:1' AS HandlerId;
2279
DECLARE CONTINUE HANDLER FOR SQLWARNING
2280
SELECT 'Wrong:H1:2' AS HandlerId;
2281
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2283
DECLARE CONTINUE HANDLER FOR SQLSTATE '01000'
2284
SELECT 'Wrong:H2:1' AS HandlerId;
2285
DECLARE CONTINUE HANDLER FOR SQLWARNING
2286
SELECT 'Wrong:H2:2' AS HandlerId;
2287
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2289
DECLARE CONTINUE HANDLER FOR SQLSTATE '01000'
2290
SELECT 'Wrong:H3:1' AS HandlerId;
2291
DECLARE CONTINUE HANDLER FOR SQLWARNING
2292
SELECT 'Wrong:H3:2' AS HandlerId;
2293
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2295
DECLARE CONTINUE HANDLER FOR SQLSTATE '01000'
2296
SELECT 'Wrong:H4:1' AS HandlerId;
2297
DECLARE CONTINUE HANDLER FOR SQLWARNING
2298
SELECT 'Wrong:H4:2' AS HandlerId;
2299
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2301
DECLARE CONTINUE HANDLER FOR SQLSTATE '01000'
2302
SELECT 'Wrong:H5:1' AS HandlerId;
2303
DECLARE CONTINUE HANDLER FOR SQLWARNING
2304
SELECT 'Wrong:H5:2' AS HandlerId;
2305
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2307
DECLARE CONTINUE HANDLER FOR SQLSTATE '01000'
2308
SELECT 'Wrong:H6:1' AS HandlerId;
2309
DECLARE CONTINUE HANDLER FOR SQLWARNING
2310
SELECT 'Wrong:H6:2' AS HandlerId;
2311
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2313
SELECT 'H2' AS HandlerId;
2314
SIGNAL SQLSTATE '01000'; # Should be handled by H1.
2316
SELECT 'S6' AS SignalId;
2317
SIGNAL SQLSTATE 'HY000';
2319
SELECT 'S5' AS SignalId;
2320
SIGNAL SQLSTATE 'HY000';
2322
SELECT 'S4' AS SignalId;
2323
SIGNAL SQLSTATE 'HY000';
2325
SELECT 'S3' AS SignalId;
2326
SIGNAL SQLSTATE 'HY000';
2328
SELECT 'S2' AS SignalId;
2329
SIGNAL SQLSTATE 'HY000';
2331
SELECT 'S1' AS SignalId;
2332
SIGNAL SQLSTATE 'HY000'; # Should be handled by H2.
2356
# -- Test stored procedure from Peter's mail.
2358
CREATE PROCEDURE p11()
2360
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2361
SELECT 'H1' AS HandlerId;
2362
DECLARE CONTINUE HANDLER FOR SQLWARNING
2363
SELECT 'H2' AS HandlerId;
2365
DECLARE CONTINUE HANDLER FOR SQLSTATE '01000', 1249
2367
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
2368
SELECT 'H3' AS HandlerId;
2369
DECLARE CONTINUE HANDLER FOR SQLWARNING
2370
SELECT 'H4' AS HandlerId;
2372
SELECT 'H5' AS HandlerId;
2373
SELECT 'S3' AS SignalId;
2374
SIGNAL SQLSTATE 'HY000'; # H3
2375
SELECT 'S4' AS SignalId;
2376
SIGNAL SQLSTATE '22003'; # H3
2377
SELECT 'S5' AS SignalId;
2378
SIGNAL SQLSTATE '01000' SET MYSQL_ERRNO = 1249; # H4
2381
SELECT 'S6' AS SignalId;
2382
SIGNAL SQLSTATE 'HY000'; # H1
2383
SELECT 'S7' AS SignalId;
2384
SIGNAL SQLSTATE '22003'; # H1
2385
SELECT 'S8' AS SignalId;
2386
SIGNAL SQLSTATE '01000' SET MYSQL_ERRNO = 1249; # H5
2388
SELECT 'S1' AS SignalId;
2389
SIGNAL SQLSTATE 'HY000'; # H1
2390
SELECT 'S2' AS SignalId;
2391
SIGNAL SQLSTATE '01000' SET MYSQL_ERRNO = 1249; # H2
2428
# -- Check that runtime stack-trace can be deeper than parsing-time one.
2430
CREATE PROCEDURE p12()
2432
DECLARE CONTINUE HANDLER FOR SQLSTATE '01001'
2434
DECLARE CONTINUE HANDLER FOR SQLSTATE '01001'
2436
DECLARE CONTINUE HANDLER FOR SQLSTATE '01001'
2438
DECLARE CONTINUE HANDLER FOR SQLSTATE '01001'
2440
DECLARE CONTINUE HANDLER FOR SQLSTATE '01001'
2442
SELECT 'H1:5' AS HandlerId;
2443
SIGNAL SQLSTATE '01002';
2445
SELECT 'H1:4' AS HandlerId;
2446
SIGNAL SQLSTATE '01001';
2448
SELECT 'H1:3' AS HandlerId;
2449
SIGNAL SQLSTATE '01001';
2451
SELECT 'H1:2' AS HandlerId;
2452
SIGNAL SQLSTATE '01001';
2454
SELECT 'H1:1' AS HandlerId;
2455
SIGNAL SQLSTATE '01001';
2457
#########################################################
2458
DECLARE CONTINUE HANDLER FOR SQLSTATE '01002'
2460
#########################################################
2462
DECLARE CONTINUE HANDLER FOR SQLWARNING
2464
DECLARE CONTINUE HANDLER FOR SQLWARNING
2466
DECLARE CONTINUE HANDLER FOR SQLWARNING
2468
DECLARE CONTINUE HANDLER FOR SQLWARNING
2470
DECLARE CONTINUE HANDLER FOR SQLWARNING
2472
SELECT 'H2:5' AS HandlerId;
2473
SIGNAL SQLSTATE '01001';
2475
SELECT 'H2:4' AS HandlerId;
2476
SIGNAL SQLSTATE '01000';
2478
SELECT 'H2:3' AS HandlerId;
2479
SIGNAL SQLSTATE '01000';
2481
SELECT 'H2:2' AS HandlerId;
2482
SIGNAL SQLSTATE '01000';
2484
SELECT 'H2:1' AS HandlerId;
2485
SIGNAL SQLSTATE '01000';
2487
#######################################################
2488
SELECT 'Throw 01000' AS Msg;
2489
SIGNAL SQLSTATE '01000';
2517
Warning 1642 Unhandled user-defined warning condition
2519
# -- Check that handler-call-frames are removed properly for EXIT
2522
CREATE PROCEDURE p13()
2524
DECLARE CONTINUE HANDLER FOR SQLWARNING
2526
DECLARE CONTINUE HANDLER FOR SQLWARNING
2528
DECLARE EXIT HANDLER FOR SQLWARNING
2530
SELECT 'EXIT handler 3' AS Msg;
2532
SELECT 'CONTINUE handler 2: 1' AS Msg;
2533
SIGNAL SQLSTATE '01000';
2534
SELECT 'CONTINUE handler 2: 2' AS Msg;
2536
SELECT 'CONTINUE handler 1: 1' AS Msg;
2537
SIGNAL SQLSTATE '01000';
2538
SELECT 'CONTINUE handler 1: 2' AS Msg;
2540
SELECT 'Throw 01000' AS Msg;
2541
SIGNAL SQLSTATE '01000';
2548
CONTINUE handler 1: 1
2550
CONTINUE handler 2: 1
2554
CONTINUE handler 1: 2
2556
# That's it. Cleanup.
2572
# Bug#12731619: NESTED SP HANDLERS CAN TRIGGER ASSERTION
2574
DROP FUNCTION IF EXISTS f1;
2575
DROP TABLE IF EXISTS t1;
2576
CREATE TABLE t1(msg VARCHAR(255));
2577
CREATE FUNCTION f1() RETURNS INT
2579
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION # handler 1
2581
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION # handler 2
2583
INSERT INTO t1 VALUE('WRONG: Inside H2');
2586
INSERT INTO t1 VALUE('CORRECT: Inside H1');
2590
DECLARE CONTINUE HANDLER FOR SQLWARNING # handler 3
2592
INSERT INTO t1 VALUE('WRONG: Inside H3');
2595
INSERT INTO t1 VALUE('CORRECT: Calling f1()');
2596
RETURN f1(); # -- exception here
2598
INSERT INTO t1 VALUE('WRONG: Returning 10');
2608
CORRECT: Calling f1()
2614
# Check that handled SQL-conditions are properly cleared from DA.
2616
DROP TABLE IF EXISTS t1;
2617
DROP TABLE IF EXISTS t2;
2618
DROP PROCEDURE IF EXISTS p1;
2619
DROP PROCEDURE IF EXISTS p2;
2620
DROP PROCEDURE IF EXISTS p3;
2621
DROP PROCEDURE IF EXISTS p4;
2622
DROP PROCEDURE IF EXISTS p5;
2623
CREATE TABLE t1(a CHAR, b CHAR, c CHAR);
2624
CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT);
2626
# Check that SQL-conditions for which SQL-handler has been invoked,
2627
# are cleared from the Diagnostics Area. Note, there might be several
2628
# SQL-conditions, but SQL-handler must be invoked only once.
2630
CREATE PROCEDURE p1()
2632
DECLARE EXIT HANDLER FOR SQLWARNING
2633
SELECT 'Warning caught' AS msg;
2634
# The INSERT below raises 3 SQL-conditions (warnings). The EXIT HANDLER
2635
# above must be invoked once (for one condition), but all three conditions
2636
# must be cleared from the Diagnostics Area.
2637
INSERT INTO t1 VALUES('qqqq', 'ww', 'eee');
2638
# The following INSERT will not be executed, because of the EXIT HANDLER.
2639
INSERT INTO t1 VALUES('zzz', 'xx', 'yyyy');
2650
# Check that SQL-conditions for which SQL-handler has *not* been
2651
# invoked, are *still* cleared from the Diagnostics Area.
2653
CREATE PROCEDURE p2()
2655
DECLARE CONTINUE HANDLER FOR 1292
2656
SELECT 'Warning 1292 caught' AS msg;
2657
# The following INSERT raises 6 SQL-warnings with code 1292,
2658
# and 3 SQL-warnings with code 1264. The CONTINUE HANDLER above must be
2659
# invoked once, and all nine SQL-warnings must be cleared from
2660
# the Diagnostics Area.
2663
CAST(CONCAT(CAST('1 ' AS UNSIGNED INTEGER), '999999 ') AS SIGNED INTEGER),
2664
CAST(CONCAT(CAST('2 ' AS UNSIGNED INTEGER), '999999 ') AS SIGNED INTEGER),
2665
CAST(CONCAT(CAST('3 ' AS UNSIGNED INTEGER), '999999 ') AS SIGNED INTEGER);
2672
# Check that if there are two equally ranked SQL-handlers to handle
2673
# SQL-conditions from SQL-statement, only one of them will be invoked.
2675
CREATE PROCEDURE p3()
2677
DECLARE CONTINUE HANDLER FOR 1292
2678
SELECT 'Warning 1292 caught' AS msg;
2679
DECLARE CONTINUE HANDLER FOR 1264
2680
SELECT 'Warning 1264 caught' AS msg;
2681
# The following INSERT raises 6 SQL-warnings with code 1292,
2682
# and 3 SQL-warnings with code 1264. Only one of the CONTINUE HANDLERs above
2683
# must be called, and only once. The SQL Standard does not define, which one
2684
# should be invoked.
2687
CAST(CONCAT(CAST('1 ' AS UNSIGNED INTEGER), '999999 ') AS SIGNED INTEGER),
2688
CAST(CONCAT(CAST('2 ' AS UNSIGNED INTEGER), '999999 ') AS SIGNED INTEGER),
2689
CAST(CONCAT(CAST('3 ' AS UNSIGNED INTEGER), '999999 ') AS SIGNED INTEGER);
2696
# The same as p3, but 1264 comes first.
2698
CREATE PROCEDURE p4()
2700
DECLARE CONTINUE HANDLER FOR 1292
2701
SELECT 'Warning 1292 caught' AS msg;
2702
DECLARE CONTINUE HANDLER FOR 1264
2703
SELECT 'Warning 1264 caught' AS msg;
2704
# The following INSERT raises 4 SQL-warnings with code 1292,
2705
# and 3 SQL-warnings with code 1264. Only one of the CONTINUE HANDLERs above
2706
# must be called, and only once. The SQL Standard does not define, which one
2707
# should be invoked.
2710
CAST(999999 AS SIGNED INTEGER),
2711
CAST(CONCAT(CAST('2 ' AS UNSIGNED INTEGER), '999999 ') AS SIGNED INTEGER),
2712
CAST(CONCAT(CAST('3 ' AS UNSIGNED INTEGER), '999999 ') AS SIGNED INTEGER);
2719
# Check that if a SQL-handler raised its own SQL-conditions, there are
2720
# preserved after handler exit.
2722
CREATE PROCEDURE p5()
2724
DECLARE EXIT HANDLER FOR 1292
2726
SELECT 'Handler for 1292 (1)' AS Msg;
2727
SIGNAL SQLSTATE '01000' SET MYSQL_ERRNO = 1234;
2729
SELECT 'Handler for 1292 (2)' AS Msg;
2733
CAST(999999 AS SIGNED INTEGER),
2734
CAST(CONCAT(CAST('2 ' AS UNSIGNED INTEGER), '999999 ') AS SIGNED INTEGER),
2735
CAST(CONCAT(CAST('3 ' AS UNSIGNED INTEGER), '999999 ') AS SIGNED INTEGER);
2740
Handler for 1292 (1)
2742
Warning 1234 Unhandled user-defined warning condition
2744
Handler for 1292 (2)
2746
Warning 1234 Unhandled user-defined warning condition
2748
# Check that SQL-conditions are available inside the handler, but
2749
# cleared after the handler exits.
2751
CREATE PROCEDURE p6()
2753
DECLARE CONTINUE HANDLER FOR 1292
2756
SELECT 'Handler for 1292' Msg;
2760
CAST(CONCAT(CAST('1 ' AS UNSIGNED INTEGER), '999999 ') AS SIGNED INTEGER),
2761
CAST(CONCAT(CAST('2 ' AS UNSIGNED INTEGER), '999999 ') AS SIGNED INTEGER),
2762
CAST(CONCAT(CAST('3 ' AS UNSIGNED INTEGER), '999999 ') AS SIGNED INTEGER);
2767
Warning 1292 Truncated incorrect INTEGER value: '1 '
2768
Warning 1292 Truncated incorrect INTEGER value: '1999999 '
2769
Warning 1264 Out of range value for column 'a' at row 1
2770
Warning 1292 Truncated incorrect INTEGER value: '2 '
2771
Warning 1292 Truncated incorrect INTEGER value: '2999999 '
2772
Warning 1264 Out of range value for column 'b' at row 1
2773
Warning 1292 Truncated incorrect INTEGER value: '3 '
2774
Warning 1292 Truncated incorrect INTEGER value: '3999999 '
2775
Warning 1264 Out of range value for column 'c' at row 1
2788
# Bug#13059316: ASSERTION FAILURE IN SP_RCONTEXT.CC
2789
# Check DECLARE statements that raise conditions before handlers
2792
DROP PROCEDURE IF EXISTS p1;
2793
DROP PROCEDURE IF EXISTS p2;
2794
CREATE PROCEDURE p1()
2796
DECLARE var1 INTEGER DEFAULT 'string';
2797
DECLARE EXIT HANDLER FOR SQLWARNING SELECT 'H1';
2802
Warning 1366 Incorrect integer value: 'string' for column 'var1' at row 1
2804
CREATE PROCEDURE p2()
2806
DECLARE EXIT HANDLER FOR SQLWARNING SELECT 'H2';
2817
# Bug#13113222 RQG_SIGNAL_RESIGNAL FAILED WITH ASSERTION.
2819
DROP PROCEDURE IF EXISTS p1;
2820
DROP PROCEDURE IF EXISTS p2;
2821
CREATE PROCEDURE p1()
2823
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SELECT 'triggered p1';
2824
# This will trigger an error.
2825
SIGNAL SQLSTATE 'HY000';
2827
CREATE PROCEDURE p2()
2829
DECLARE CONTINUE HANDLER FOR SQLWARNING SELECT 'triggered p2';
2830
# This will trigger a warning.
2831
SIGNAL SQLSTATE '01000';
2833
SET @old_max_error_count= @@session.max_error_count;
2834
SET SESSION max_error_count= 0;
2839
SET SESSION max_error_count= @old_max_error_count;
2843
# Bug#12652873: 61392: Continue handler for NOT FOUND being triggered
2844
# from internal stored function.
2846
DROP FUNCTION IF EXISTS f1;
2847
DROP FUNCTION IF EXISTS f2;
2848
DROP TABLE IF EXISTS t1;
2850
CREATE TABLE t1 (a INT, b INT);
2851
INSERT INTO t1 VALUES (1, 2);
2853
# f1() raises NOT_FOUND condition.
2854
# Raising NOT_FOUND can not be simulated by SIGNAL,
2855
# because SIGNAL would raise SQL-error in that case.
2857
CREATE FUNCTION f1() RETURNS INTEGER
2859
DECLARE v VARCHAR(5) DEFAULT -1;
2860
SELECT b FROM t1 WHERE a = 2 INTO v;
2864
# Here we check that the NOT_FOUND condition raised in f1()
2865
# is not visible in the outer function (f2), i.e. the continue
2866
# handler in f2() will not be called.
2868
CREATE FUNCTION f2() RETURNS INTEGER
2871
DECLARE CONTINUE HANDLER FOR NOT FOUND
2872
SET @msg = 'Handler activated.';