2003-03-05 19:45:17 +01:00
delete from mysql.proc;
2003-12-16 18:09:22 +01:00
create procedure syntaxerror(t int)|
2004-07-15 03:19:07 +02:00
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
2003-12-16 18:09:22 +01:00
create procedure syntaxerror(t int)|
2004-07-15 03:19:07 +02:00
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
2003-12-16 18:09:22 +01:00
create procedure syntaxerror(t int)|
2004-07-15 03:19:07 +02:00
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
2004-06-09 18:50:03 +02:00
drop table if exists t3|
create table t3 ( x int )|
insert into t3 values (2), (3)|
create procedure bad_into(out param int)
select x from t3 into param|
call bad_into(@x)|
ERROR 42000: Result consisted of more than one row
drop procedure bad_into|
drop table t3|
2003-03-05 19:45:17 +01:00
create procedure proc1()
2003-12-16 18:09:22 +01:00
set @x = 42|
2003-03-05 19:45:17 +01:00
create function func1() returns int
2003-12-16 18:09:22 +01:00
return 42|
2003-03-05 19:45:17 +01:00
create procedure foo()
2003-12-16 18:09:22 +01:00
create procedure bar() set @x=3|
2003-11-21 18:23:05 +01:00
ERROR 2F003: Can't create a PROCEDURE from within another stored routine
2003-03-05 19:45:17 +01:00
create procedure foo()
2003-12-16 18:09:22 +01:00
create function bar() returns double return 2.3|
2003-11-21 18:23:05 +01:00
ERROR 2F003: Can't create a FUNCTION from within another stored routine
2003-03-05 19:45:17 +01:00
create procedure proc1()
2003-12-16 18:09:22 +01:00
set @x = 42|
2003-11-21 18:23:05 +01:00
ERROR 42000: PROCEDURE proc1 already exists
2003-03-05 19:45:17 +01:00
create function func1() returns int
2003-12-16 18:09:22 +01:00
return 42|
2003-11-21 18:23:05 +01:00
ERROR 42000: FUNCTION func1 already exists
2003-12-16 18:09:22 +01:00
drop procedure proc1|
drop function func1|
alter procedure foo|
2004-06-15 15:42:28 +02:00
ERROR 42000: PROCEDURE test.foo does not exist
2003-12-16 18:09:22 +01:00
alter function foo|
2004-06-15 15:42:28 +02:00
ERROR 42000: FUNCTION test.foo does not exist
2003-12-16 18:09:22 +01:00
drop procedure foo|
2004-06-15 15:42:28 +02:00
ERROR 42000: PROCEDURE test.foo does not exist
2003-12-16 18:09:22 +01:00
drop function foo|
2004-06-15 15:42:28 +02:00
ERROR 42000: FUNCTION test.foo does not exist
2003-12-16 18:09:22 +01:00
call foo()|
2004-06-15 15:42:28 +02:00
ERROR 42000: PROCEDURE test.foo does not exist
2003-12-16 18:09:22 +01:00
drop procedure if exists foo|
2003-03-26 12:29:58 +01:00
Warnings:
2004-09-09 05:59:26 +02:00
Note 1305 PROCEDURE foo does not exist
2003-12-16 18:09:22 +01:00
show create procedure foo|
2003-11-21 18:23:05 +01:00
ERROR 42000: PROCEDURE foo does not exist
2005-01-03 19:53:54 +01:00
show create function foo|
ERROR 42000: FUNCTION foo does not exist
2003-03-05 19:45:17 +01:00
create procedure foo()
foo: loop
leave bar;
2003-12-16 18:09:22 +01:00
end loop|
2003-11-21 18:23:05 +01:00
ERROR 42000: LEAVE with no matching label: bar
2003-03-05 19:45:17 +01:00
create procedure foo()
foo: loop
iterate bar;
2003-12-16 18:09:22 +01:00
end loop|
2003-11-21 18:23:05 +01:00
ERROR 42000: ITERATE with no matching label: bar
2003-03-05 19:45:17 +01:00
create procedure foo()
2003-11-13 19:34:56 +01:00
foo: begin
iterate foo;
2003-12-16 18:09:22 +01:00
end|
2003-11-21 18:23:05 +01:00
ERROR 42000: ITERATE with no matching label: foo
2003-11-13 19:34:56 +01:00
create procedure foo()
2004-08-17 20:20:58 +02:00
begin
goto foo;
end|
ERROR 42000: GOTO with no matching label: foo
create procedure foo()
2004-08-26 12:54:30 +02:00
begin
begin
label foo;
end;
goto foo;
end|
ERROR 42000: GOTO with no matching label: foo
create procedure foo()
begin
goto foo;
begin
label foo;
end;
end|
ERROR 42000: GOTO with no matching label: foo
create procedure foo()
begin
begin
goto foo;
end;
begin
label foo;
end;
end|
ERROR 42000: GOTO with no matching label: foo
create procedure foo()
begin
begin
label foo;
end;
begin
goto foo;
end;
end|
ERROR 42000: GOTO with no matching label: foo
create procedure foo()
2003-03-05 19:45:17 +01:00
foo: loop
foo: loop
set @x=2;
end loop foo;
2003-12-16 18:09:22 +01:00
end loop foo|
2003-11-21 18:23:05 +01:00
ERROR 42000: Redefining label foo
2003-03-05 19:45:17 +01:00
create procedure foo()
foo: loop
set @x=2;
2003-12-16 18:09:22 +01:00
end loop bar|
2003-11-21 18:23:05 +01:00
ERROR 42000: End-label bar without match
2003-03-05 19:45:17 +01:00
create procedure foo()
2003-12-16 18:09:22 +01:00
return 42|
2003-11-21 18:23:05 +01:00
ERROR 42000: RETURN is only allowed in a FUNCTION
2003-04-17 13:20:02 +02:00
create procedure p(x int)
2005-02-08 20:52:50 +01:00
set @x = x|
2003-04-17 13:20:02 +02:00
create function f(x int) returns int
2003-12-16 18:09:22 +01:00
return x+42|
call p()|
2004-06-16 07:46:26 +02:00
ERROR 42000: Incorrect number of arguments for PROCEDURE p; expected 1, got 0
2003-12-16 18:09:22 +01:00
call p(1, 2)|
2004-06-16 07:46:26 +02:00
ERROR 42000: Incorrect number of arguments for PROCEDURE p; expected 1, got 2
2003-12-16 18:09:22 +01:00
select f()|
2004-06-16 07:46:26 +02:00
ERROR 42000: Incorrect number of arguments for FUNCTION f; expected 1, got 0
2003-12-16 18:09:22 +01:00
select f(1, 2)|
2004-06-16 07:46:26 +02:00
ERROR 42000: Incorrect number of arguments for FUNCTION f; expected 1, got 2
2003-12-16 18:09:22 +01:00
drop procedure p|
drop function f|
2003-09-16 14:26:08 +02:00
create procedure p(val int, out res int)
begin
declare x int default 0;
declare continue handler for foo set x = 1;
insert into test.t1 values (val);
if (x) then
set res = 0;
else
set res = 1;
end if;
2003-12-16 18:09:22 +01:00
end|
2003-11-21 18:23:05 +01:00
ERROR 42000: Undefined CONDITION: foo
2003-09-16 14:26:08 +02:00
create procedure p(val int, out res int)
begin
declare x int default 0;
declare foo condition for 1146;
declare continue handler for bar set x = 1;
insert into test.t1 values (val);
if (x) then
set res = 0;
else
set res = 1;
end if;
2003-12-16 18:09:22 +01:00
end|
2003-11-21 18:23:05 +01:00
ERROR 42000: Undefined CONDITION: bar
2003-10-03 17:38:12 +02:00
create function f(val int) returns int
begin
declare x int;
set x = val+3;
2003-12-16 18:09:22 +01:00
end|
2003-11-21 18:23:05 +01:00
ERROR 42000: No RETURN found in FUNCTION f
2003-10-03 17:38:12 +02:00
create function f(val int) returns int
begin
declare x int;
set x = val+3;
if x < 4 then
return x;
end if;
2003-12-16 18:09:22 +01:00
end|
select f(10)|
2003-11-21 18:23:05 +01:00
ERROR 2F005: FUNCTION f ended without RETURN
2003-12-16 18:09:22 +01:00
drop function f|
2003-10-10 16:57:21 +02:00
create procedure p()
begin
declare c cursor for insert into test.t1 values ("foo", 42);
open c;
close c;
2003-12-16 18:09:22 +01:00
end|
2003-11-21 18:23:05 +01:00
ERROR 42000: Cursor statement must be a SELECT
2003-10-10 16:57:21 +02:00
create procedure p()
begin
declare x int;
declare c cursor for select * into x from test.t limit 1;
open c;
close c;
2003-12-16 18:09:22 +01:00
end|
2003-11-21 18:23:05 +01:00
ERROR 42000: Cursor SELECT must not have INTO
2003-10-10 16:57:21 +02:00
create procedure p()
begin
declare c cursor for select * from test.t;
open cc;
close c;
2003-12-16 18:09:22 +01:00
end|
2003-11-21 18:23:05 +01:00
ERROR 42000: Undefined CURSOR: cc
2003-12-16 18:09:22 +01:00
drop table if exists t1|
create table t1 (val int)|
2003-10-10 16:57:21 +02:00
create procedure p()
begin
declare c cursor for select * from test.t1;
open c;
open c;
close c;
2003-12-16 18:09:22 +01:00
end|
call p()|
2003-11-21 18:23:05 +01:00
ERROR 24000: Cursor is already open
2003-12-16 18:09:22 +01:00
drop procedure p|
2003-10-10 16:57:21 +02:00
create procedure p()
begin
declare c cursor for select * from test.t1;
open c;
close c;
close c;
2003-12-16 18:09:22 +01:00
end|
call p()|
2003-11-21 18:23:05 +01:00
ERROR 24000: Cursor is not open
2003-12-16 18:09:22 +01:00
drop procedure p|
alter procedure bar3 sql security invoker|
2004-06-15 15:42:28 +02:00
ERROR 42000: PROCEDURE test.bar3 does not exist
2003-12-16 18:09:22 +01:00
drop table t1|
drop table if exists t1|
create table t1 (val int, x float)|
insert into t1 values (42, 3.1), (19, 1.2)|
2003-10-10 16:57:21 +02:00
create procedure p()
begin
declare x int;
2004-03-29 11:16:45 +02:00
declare c cursor for select * from t1;
2003-10-10 16:57:21 +02:00
open c;
fetch c into x, y;
close c;
2003-12-16 18:09:22 +01:00
end|
2003-11-21 18:23:05 +01:00
ERROR 42000: Undeclared variable: y
2003-10-10 16:57:21 +02:00
create procedure p()
begin
declare x int;
2004-03-29 11:16:45 +02:00
declare c cursor for select * from t1;
2003-10-10 16:57:21 +02:00
open c;
fetch c into x;
close c;
2003-12-16 18:09:22 +01:00
end|
call p()|
2004-06-16 07:46:26 +02:00
ERROR HY000: Incorrect number of FETCH variables
2003-12-16 18:09:22 +01:00
drop procedure p|
2003-10-10 16:57:21 +02:00
create procedure p()
begin
declare x int;
declare y float;
declare z int;
2004-03-29 11:16:45 +02:00
declare c cursor for select * from t1;
2003-10-10 16:57:21 +02:00
open c;
fetch c into x, y, z;
close c;
2003-12-16 18:09:22 +01:00
end|
call p()|
2004-06-16 07:46:26 +02:00
ERROR HY000: Incorrect number of FETCH variables
2003-12-16 18:09:22 +01:00
drop procedure p|
2003-11-13 19:34:56 +01:00
create procedure p(in x int, x char(10))
begin
2003-12-16 18:09:22 +01:00
end|
2003-11-21 18:23:05 +01:00
ERROR 42000: Duplicate parameter: x
2003-11-13 19:34:56 +01:00
create function p(x int, x char(10))
begin
2003-12-16 18:09:22 +01:00
end|
2003-11-21 18:23:05 +01:00
ERROR 42000: Duplicate parameter: x
2003-11-13 19:34:56 +01:00
create procedure p()
begin
declare x float;
declare x int;
2003-12-16 18:09:22 +01:00
end|
2003-11-21 18:23:05 +01:00
ERROR 42000: Duplicate variable: x
2003-11-13 19:34:56 +01:00
create procedure p()
begin
declare c condition for 1064;
declare c condition for 1065;
2003-12-16 18:09:22 +01:00
end|
2003-11-21 18:23:05 +01:00
ERROR 42000: Duplicate condition: c
2003-11-13 19:34:56 +01:00
create procedure p()
begin
declare c cursor for select * from t1;
declare c cursor for select field from t1;
2003-12-16 18:09:22 +01:00
end|
2003-11-21 18:23:05 +01:00
ERROR 42000: Duplicate cursor: c
2004-03-11 17:18:59 +01:00
create procedure u()
2004-03-29 11:16:45 +02:00
use sptmp|
2004-03-11 17:18:59 +01:00
ERROR 42000: USE is not allowed in a stored procedure
2004-03-29 11:16:45 +02:00
create procedure p()
begin
declare c cursor for select * from t1;
declare x int;
end|
ERROR 42000: Variable or condition declaration after cursor or handler declaration
create procedure p()
begin
declare x int;
declare continue handler for sqlstate '42S99' set x = 1;
declare foo condition for sqlstate '42S99';
end|
ERROR 42000: Variable or condition declaration after cursor or handler declaration
create procedure p()
begin
declare x int;
declare continue handler for sqlstate '42S99' set x = 1;
declare c cursor for select * from t1;
end|
ERROR 42000: Cursor declaration after handler declaration
2004-08-26 12:54:30 +02:00
create procedure p()
begin
declare continue handler for sqlexception
begin
goto L1;
end;
select field from t1;
label L1;
end|
ERROR HY000: GOTO is not allowed in a stored procedure handler
2003-11-27 16:48:21 +01:00
create procedure bug1965()
begin
declare c cursor for select val from t1 order by valname;
open c;
close c;
2003-12-16 18:09:22 +01:00
end|
call bug1965()|
2003-11-27 16:48:21 +01:00
ERROR 42S22: Unknown column 'valname' in 'order clause'
2003-12-16 18:09:22 +01:00
drop procedure bug1965|
select 1 into a|
2003-11-27 16:48:21 +01:00
ERROR 42000: Undeclared variable: a
2004-04-05 17:01:19 +02:00
drop table if exists t3|
2003-12-16 18:09:22 +01:00
create table t3 (column_1_0 int)|
2003-12-13 16:40:52 +01:00
create procedure bug1653()
2003-12-16 18:09:22 +01:00
update t3 set column_1 = 0|
call bug1653()|
2003-12-13 16:40:52 +01:00
ERROR 42S22: Unknown column 'column_1' in 'field list'
2003-12-16 18:09:22 +01:00
drop table t3|
create table t3 (column_1 int)|
call bug1653()|
drop procedure bug1653|
drop table t3|
2004-01-08 10:37:31 +01:00
create procedure bug2259()
begin
declare v1 int;
2005-02-08 20:52:50 +01:00
declare c1 cursor for select s1 from t1;
2004-01-08 10:37:31 +01:00
fetch c1 into v1;
end|
call bug2259()|
ERROR 24000: Cursor is not open
drop procedure bug2259|
2004-01-08 09:27:29 +01:00
create procedure bug2272()
begin
declare v int;
update t1 set v = 42;
end|
insert into t1 values (666, 51.3)|
call bug2272()|
ERROR 42S22: Unknown column 'v' in 'field list'
delete from t1|
2004-01-08 10:37:31 +01:00
drop procedure bug2272|
2004-01-14 12:47:03 +01:00
create procedure bug2329_1()
begin
declare v int;
insert into t1 (v) values (5);
end|
create procedure bug2329_2()
begin
declare v int;
replace t1 set v = 5;
end|
call bug2329_1()|
ERROR 42S22: Unknown column 'v' in 'field list'
call bug2329_2()|
ERROR 42S22: Unknown column 'v' in 'field list'
drop procedure bug2329_1|
drop procedure bug2329_2|
2004-03-29 12:29:06 +02:00
create function bug3287() returns int
begin
declare v int default null;
case
when v is not null then return 1;
end case;
return 2;
end|
select bug3287()|
ERROR 20000: Case not found for CASE statement
drop function bug3287|
create procedure bug3287(x int)
case x
when 0 then
insert into test.t1 values (x, 0.1);
when 1 then
insert into test.t1 values (x, 1.1);
end case|
call bug3287(2)|
ERROR 20000: Case not found for CASE statement
drop procedure bug3287|
2004-04-05 17:01:19 +02:00
drop table if exists t3|
create table t3 (s1 int, primary key (s1))|
insert into t3 values (5),(6)|
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|
call bug3279(@x)|
ERROR 23000: Duplicate entry '6' for key 1
select @x|
@x
0
drop procedure bug3279|
drop table t3|
2004-06-15 15:42:28 +02:00
create procedure nodb.bug3339() begin end|
ERROR 42000: Unknown database 'nodb'
2004-07-21 14:53:09 +02:00
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|
call bug2653_1(1, @b)|
ERROR 42S22: Unknown column 'aa' in 'order clause'
call bug2653_2(2, @b)|
ERROR 42S22: Unknown column 'aa' in 'order clause'
drop procedure bug2653_1|
drop procedure bug2653_2|
2004-07-29 17:33:45 +02:00
create procedure bug4344() drop procedure bug4344|
ERROR HY000: Can't drop a PROCEDURE from within another stored routine
create procedure bug4344() drop function bug4344|
ERROR HY000: Can't drop a FUNCTION from within another stored routine
2004-09-10 11:11:52 +02:00
drop procedure if exists bug3294|
create procedure bug3294()
begin
declare continue handler for sqlexception drop table t5;
drop table t5;
2005-02-08 20:52:50 +01:00
drop table t5;
2004-09-10 11:11:52 +02:00
end|
2005-02-08 20:52:50 +01:00
create table t5 (x int)|
2004-09-10 11:11:52 +02:00
call bug3294()|
ERROR 42S02: Unknown table 't5'
drop procedure bug3294|
2004-11-25 16:13:06 +01:00
drop procedure if exists bug6807|
create procedure bug6807()
begin
declare id int;
set id = connection_id();
kill query id;
select 'Not reached';
end|
call bug6807()|
ERROR 70100: Query execution was interrupted
call bug6807()|
ERROR 70100: Query execution was interrupted
drop procedure bug6807|
2005-02-28 18:07:06 +01:00
drop procedure if exists bug8776_1|
drop procedure if exists bug8776_2|
drop procedure if exists bug8776_3|
drop procedure if exists bug8776_4|
create procedure bug8776_1()
begin
declare continue handler for sqlstate '42S0200test' begin end;
begin end;
end|
ERROR 42000: Bad SQLSTATE: '42S0200test'
create procedure bug8776_2()
begin
declare continue handler for sqlstate '4200' begin end;
begin end;
end|
ERROR 42000: Bad SQLSTATE: '4200'
create procedure bug8776_3()
begin
declare continue handler for sqlstate '420000' begin end;
begin end;
end|
ERROR 42000: Bad SQLSTATE: '420000'
create procedure bug8776_4()
begin
declare continue handler for sqlstate '42x00' begin end;
begin end;
end|
ERROR 42000: Bad SQLSTATE: '42x00'
2005-03-30 17:43:52 +02:00
create procedure bug6600()
check table t1|
ERROR 0A000: CHECK is not allowed in stored procedures
create procedure bug6600()
lock table t1 read|
ERROR 0A000: LOCK is not allowed in stored procedures
create procedure bug6600()
unlock table t1|
ERROR 0A000: UNLOCK is not allowed in stored procedures
2005-04-07 09:57:47 +02:00
drop procedure if exists bug9566|
create procedure bug9566()
begin
select * from t1;
end|
lock table t1 read|
call bug9566()|
ERROR HY000: Table 'proc' was not locked with LOCK TABLES
unlock tables|
drop procedure bug9566|
2003-12-16 18:09:22 +01:00
drop table t1|