2003-03-05 19:45:17 +01:00
|
|
|
#
|
|
|
|
# Stored PROCEDURE error tests
|
|
|
|
#
|
|
|
|
|
|
|
|
# Make sure we don't have any procedures left.
|
|
|
|
delete from mysql.proc;
|
|
|
|
|
|
|
|
delimiter |;
|
|
|
|
|
2003-06-12 15:31:20 +02:00
|
|
|
# This should give three syntax errors (sometimes crashed; bug #643)
|
|
|
|
# (Unfortunately, this is not a 100% test, on some platforms this
|
|
|
|
# passed despite the bug.)
|
|
|
|
--error 1064
|
|
|
|
create procedure syntaxerror(t int)|
|
|
|
|
--error 1064
|
|
|
|
create procedure syntaxerror(t int)|
|
|
|
|
--error 1064
|
|
|
|
create procedure syntaxerror(t int)|
|
|
|
|
|
2003-03-05 19:45:17 +01:00
|
|
|
# Check that we get the right error, i.e. UDF declaration parses correctly,
|
|
|
|
# but foo.so doesn't exist.
|
2004-11-03 11:39:38 +01:00
|
|
|
# This generates an error message containing a misleading errno which
|
2003-03-05 19:45:17 +01:00
|
|
|
# might vary between systems (it usually doesn't have anything to do with
|
|
|
|
# the actual failing dlopen()).
|
|
|
|
#--error 1126
|
|
|
|
#create function foo returns real soname "foo.so"|
|
|
|
|
|
2004-06-09 18:50:03 +02:00
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
drop table if exists t3|
|
|
|
|
--enable_warnings
|
|
|
|
create table t3 ( x int )|
|
|
|
|
insert into t3 values (2), (3)|
|
|
|
|
|
|
|
|
create procedure bad_into(out param int)
|
|
|
|
select x from t3 into param|
|
|
|
|
|
|
|
|
--error 1172
|
|
|
|
call bad_into(@x)|
|
|
|
|
|
|
|
|
drop procedure bad_into|
|
|
|
|
drop table t3|
|
|
|
|
|
|
|
|
|
2003-03-05 19:45:17 +01:00
|
|
|
create procedure proc1()
|
|
|
|
set @x = 42|
|
|
|
|
|
|
|
|
create function func1() returns int
|
|
|
|
return 42|
|
|
|
|
|
|
|
|
# Can't create recursively
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1303
|
2003-03-05 19:45:17 +01:00
|
|
|
create procedure foo()
|
|
|
|
create procedure bar() set @x=3|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1303
|
2003-03-05 19:45:17 +01:00
|
|
|
create procedure foo()
|
|
|
|
create function bar() returns double return 2.3|
|
|
|
|
|
|
|
|
# Already exists
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1304
|
2003-03-05 19:45:17 +01:00
|
|
|
create procedure proc1()
|
|
|
|
set @x = 42|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1304
|
2003-03-05 19:45:17 +01:00
|
|
|
create function func1() returns int
|
|
|
|
return 42|
|
|
|
|
|
2003-04-17 13:20:02 +02:00
|
|
|
drop procedure proc1|
|
|
|
|
drop function func1|
|
|
|
|
|
2003-03-05 19:45:17 +01:00
|
|
|
# Does not exist
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1305
|
2003-03-05 19:45:17 +01:00
|
|
|
alter procedure foo|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1305
|
2003-03-05 19:45:17 +01:00
|
|
|
alter function foo|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1305
|
2003-03-05 19:45:17 +01:00
|
|
|
drop procedure foo|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1305
|
2003-03-05 19:45:17 +01:00
|
|
|
drop function foo|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1305
|
2003-03-05 19:45:17 +01:00
|
|
|
call foo()|
|
2003-03-26 12:29:58 +01:00
|
|
|
drop procedure if exists foo|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1305
|
2003-11-20 15:07:22 +01:00
|
|
|
show create procedure foo|
|
2005-01-03 19:53:54 +01:00
|
|
|
--error 1305
|
|
|
|
show create function foo|
|
2003-03-05 19:45:17 +01:00
|
|
|
|
2004-08-17 20:20:58 +02:00
|
|
|
# LEAVE/ITERATE/GOTO with no match
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1308
|
2003-03-05 19:45:17 +01:00
|
|
|
create procedure foo()
|
|
|
|
foo: loop
|
|
|
|
leave bar;
|
|
|
|
end loop|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1308
|
2003-03-05 19:45:17 +01:00
|
|
|
create procedure foo()
|
|
|
|
foo: loop
|
|
|
|
iterate bar;
|
|
|
|
end loop|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1308
|
Various bug fixes:
- Duplicate parameters/variables, conditions and cursors (not allowed).
- ITERATE in labelled BEGIN-END (not allowed).
- Missing SQLSTATE [VALUE] keywords in CONDITION/HANDLER declaration (added).
- Empty BEGIN-END (now allowed).
- End label (now optional).
include/mysqld_error.h:
New error code for duplicate things (vars et al) in SPs.
mysql-test/r/sp-error.result:
New error tests for ITERATE in begin-end block and duplicate variables,
conditions and cursors.
mysql-test/r/sp.result:
New tests for empty begin-end blocks, overriding local variables outside scope
only, leave a begin-end block, and SQLSTATE [VALUE] words for CONDITION/HANDLER
declarations.
mysql-test/t/sp-error.test:
New error tests for ITERATE in begin-end block and duplicate variables,
conditions and cursors.
mysql-test/t/sp.test:
New tests for empty begin-end blocks, overriding local variables outside scope
only, leave a begin-end block, and SQLSTATE [VALUE] words for CONDITION/HANDLER
declarations.
sql/lex.h:
New SQLSTATE keyword.
sql/share/czech/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/danish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/dutch/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/english/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/estonian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/french/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/german/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/greek/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/hungarian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/italian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/japanese/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/korean/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/norwegian-ny/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/norwegian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/polish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/portuguese/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/romanian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/russian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/serbian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/slovak/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/spanish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/swedish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/ukrainian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/sp_pcontext.cc:
Keep track on scope limits for error checking of duplicate variables,
conditions and cursors.
sql/sp_pcontext.h:
Keep track on scope limits for error checking of duplicate variables,
conditions and cursors.
Also need to flag BEGIN labels to check for illegal ITERATEs.
sql/sql_yacc.yy:
End-labels in SPs loop and begin-end blocks are now optional.
SQLSTATE [VALUE] added to syntax for sqlstates.
Check for duplicate variable, condition and cursor declarations, but
only in the same scope.
Empty BEGIN-END statements now allowed.
Check if ITERATE is referring to a BEGIN label.
2003-11-13 19:34:56 +01:00
|
|
|
create procedure foo()
|
|
|
|
foo: begin
|
|
|
|
iterate foo;
|
|
|
|
end|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1308
|
2004-08-17 20:20:58 +02:00
|
|
|
create procedure foo()
|
|
|
|
begin
|
|
|
|
goto foo;
|
|
|
|
end|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1308
|
2004-08-26 12:54:30 +02:00
|
|
|
create procedure foo()
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
label foo;
|
|
|
|
end;
|
|
|
|
goto foo;
|
|
|
|
end|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1308
|
2004-08-26 12:54:30 +02:00
|
|
|
create procedure foo()
|
|
|
|
begin
|
|
|
|
goto foo;
|
|
|
|
begin
|
|
|
|
label foo;
|
|
|
|
end;
|
|
|
|
end|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1308
|
2004-08-26 12:54:30 +02:00
|
|
|
create procedure foo()
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
goto foo;
|
|
|
|
end;
|
|
|
|
begin
|
|
|
|
label foo;
|
|
|
|
end;
|
|
|
|
end|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1308
|
2004-08-26 12:54:30 +02:00
|
|
|
create procedure foo()
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
label foo;
|
|
|
|
end;
|
|
|
|
begin
|
|
|
|
goto foo;
|
|
|
|
end;
|
|
|
|
end|
|
2003-03-05 19:45:17 +01:00
|
|
|
|
|
|
|
# Redefining label
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1309
|
2003-03-05 19:45:17 +01:00
|
|
|
create procedure foo()
|
|
|
|
foo: loop
|
|
|
|
foo: loop
|
|
|
|
set @x=2;
|
|
|
|
end loop foo;
|
|
|
|
end loop foo|
|
|
|
|
|
|
|
|
# End label mismatch
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1310
|
2003-03-05 19:45:17 +01:00
|
|
|
create procedure foo()
|
|
|
|
foo: loop
|
|
|
|
set @x=2;
|
|
|
|
end loop bar|
|
|
|
|
|
|
|
|
# RETURN in FUNCTION only
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1313
|
2003-03-05 19:45:17 +01:00
|
|
|
create procedure foo()
|
|
|
|
return 42|
|
|
|
|
|
2003-04-17 13:20:02 +02:00
|
|
|
# Wrong number of arguments
|
|
|
|
create procedure p(x int)
|
WL#2130: Table locking for stored FUNCTIONs
Collect all tables and SPs refered by a statement, and open all tables
with an implicit LOCK TABLES. Do find things refered by triggers and views,
we open them first (and then repeat this until nothing new is found), before
doing the actual lock tables.
mysql-test/r/information_schema.result:
Updated result for WL#2130.
mysql-test/r/lock.result:
Updated result for WL#2130.
mysql-test/r/sp-error.result:
Updated result for WL#2130.
mysql-test/r/sp.result:
Updated result for WL#2130.
mysql-test/r/view.result:
Updated result for WL#2130.
mysql-test/t/information_schema.test:
Disabled one test case due to a bug involving LOCK TABLES,
which shows up with WL#2130.
mysql-test/t/lock.test:
New error message with WL#2130. This change is under debate and might change
in the future, but will do for now.
mysql-test/t/sp-error.test:
Updated for WL#2130. Some tests are voided when table access does work from
functions.
mysql-test/t/sp.test:
Updated for WL#2130.
mysql-test/t/view.test:
Updated for WL#2130.
sql/item_func.cc:
We now have to set net.no_send_ok for functions too, with WL#2130.
sql/share/errmsg.txt:
Reused an error code since the old use was voided by WL#2130, but a new
one was needed instead (similar, but more specific restriction).
sql/sp.cc:
Fixed error handling and collection of used tables for WL#2130.
sql/sp.h:
Fixed error handling and collection of used tables for WL#2130.
sql/sp_head.cc:
Added support functions for collecting and merging hash tables and lists
of used tables from SPs and substatements, for WL#2130.
sql/sp_head.h:
Added support functions for collecting and merging hash tables and lists
of used tables from SPs and substatements, for WL#2130.
sql/sql_base.cc:
Changed the way table->query_id is tested and set during with locked tables
in effect. This makes some SP test cases work with WL#2130, but has a side
effect on some error cases with explicit LOCK TABLES. It's still debated if
this is the correct way, so it might change.
sql/sql_class.h:
Added flags for circumventing some interference between WL#2130 and mysql_make_view().
sql/sql_derived.cc:
Added some missing initializations. (Potential bugs.)
sql/sql_lex.cc:
Clear the new hash tables for WL#2130.
sql/sql_lex.h:
Added hash tables for procedures and tables too (as for functions), for WL#2130.
sql/sql_parse.cc:
WL#2130: Make table accesses from stored functions work by adding an implicit
LOCK TABLES around (most) executed statements. To do this, we have to go through
a loop where we collect all SPs and tables in mysql_execute_statement.
sql/sql_prepare.cc:
Cache both functions and procedures for WL#2130.
sql/sql_show.cc:
Added some missing initializations. (Potential bugs.)
sql/sql_view.cc:
Shortcut mysql_make_view() if thd->shortcut_make_view is true during
the pre-open phase for collecting tables in WL#2130. Otherwise, the
similar mechanism here causes interference.
sql/sql_yacc.yy:
For WL#2130, added caching of procedures and disallowed LOCK/UNLOCK TABLES in SPs.
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
|
|
|
|
return x+42|
|
|
|
|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1318
|
2003-04-17 13:20:02 +02:00
|
|
|
call p()|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1318
|
2003-04-17 13:20:02 +02:00
|
|
|
call p(1, 2)|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1318
|
2003-04-17 13:20:02 +02:00
|
|
|
select f()|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1318
|
2003-04-17 13:20:02 +02:00
|
|
|
select f(1, 2)|
|
|
|
|
|
|
|
|
drop procedure p|
|
|
|
|
drop function f|
|
2003-03-05 19:45:17 +01:00
|
|
|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1319
|
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;
|
|
|
|
end|
|
|
|
|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1319
|
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;
|
|
|
|
end|
|
|
|
|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1320
|
2003-10-03 17:38:12 +02:00
|
|
|
create function f(val int) returns int
|
|
|
|
begin
|
|
|
|
declare x int;
|
|
|
|
|
|
|
|
set x = val+3;
|
|
|
|
end|
|
|
|
|
|
|
|
|
create function f(val int) returns int
|
|
|
|
begin
|
|
|
|
declare x int;
|
|
|
|
|
|
|
|
set x = val+3;
|
|
|
|
if x < 4 then
|
|
|
|
return x;
|
|
|
|
end if;
|
|
|
|
end|
|
|
|
|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1321
|
2003-10-03 17:38:12 +02:00
|
|
|
select f(10)|
|
|
|
|
|
|
|
|
drop function f|
|
|
|
|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1322
|
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;
|
|
|
|
end|
|
|
|
|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1323
|
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;
|
|
|
|
end|
|
|
|
|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1324
|
2003-10-10 16:57:21 +02:00
|
|
|
create procedure p()
|
|
|
|
begin
|
|
|
|
declare c cursor for select * from test.t;
|
|
|
|
|
|
|
|
open cc;
|
|
|
|
close c;
|
|
|
|
end|
|
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
drop table if exists t1|
|
|
|
|
--enable_warnings
|
|
|
|
create table t1 (val int)|
|
|
|
|
|
|
|
|
create procedure p()
|
|
|
|
begin
|
|
|
|
declare c cursor for select * from test.t1;
|
|
|
|
|
|
|
|
open c;
|
|
|
|
open c;
|
|
|
|
close c;
|
|
|
|
end|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1325
|
2003-10-10 16:57:21 +02:00
|
|
|
call p()|
|
|
|
|
drop procedure p|
|
|
|
|
|
|
|
|
create procedure p()
|
|
|
|
begin
|
|
|
|
declare c cursor for select * from test.t1;
|
|
|
|
|
|
|
|
open c;
|
|
|
|
close c;
|
|
|
|
close c;
|
|
|
|
end|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1326
|
2003-10-10 16:57:21 +02:00
|
|
|
call p()|
|
|
|
|
drop procedure p|
|
|
|
|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1305
|
Fixed BUG#1862 (flush table in SPs didn't work).
Fixed various bugs: setting local variables to NULL, SELECT INTO var now actually
might work, SELECT INTO with not row now gives a "no data" warning (instead of
the "empty query" error), etc.
Updated test cases accordingly.
mysql-test/r/sp-error.result:
Corrected security syntax for alter/create procedure.
mysql-test/r/sp.result:
Corrected security syntax for alter/create procedure.
New tests for setting local variables to null,
bug fixes for SELECT INTO var, FLUSH TABLES calls (BUG#1862),
and corrected "no data" warning for SELECT INTO with no rows.
mysql-test/t/sp-error.test:
Corrected security syntax for alter/create procedure.
mysql-test/t/sp.test:
Corrected security syntax for alter/create procedure.
New tests for setting local variables to null,
bug fixes for SELECT INTO var, FLUSH TABLES calls (BUG#1862),
and corrected "no data" warning for SELECT INTO with no rows.
sql/lex.h:
Added SQL_SYM (and added a few _SYM suffixes for new symbols).
sql/sp_head.cc:
Fixed bug in the item_list copying for "with_wild" cases (list nodes ended
up in the wrong memroot).
Catch errors and warnings even if return values is 0 from sub-statements.
Restore table_list which is zapped by SQLCOM_CREATE_TABLE and INSERT_SELECT.
Set old table pointers to NULL after sub-statement call (since all tables are
closed).
sql/sql_class.cc:
Corrected error message when no rows return by a SELECT INTO var; should
be a "no data" warning.
sql/sql_lex.h:
Have to store the original table_list first pointer for some
sub-statements in SPs.
sql/sql_yacc.yy:
Corrected SECURITY INVOKER/DEFINER syntax ("SQL" missing), added some _SYM
suffixes, and fixed valgrind complaints for SP COMMENTs.
(Also removed some now irrelevant comments.)
2003-11-19 11:26:18 +01:00
|
|
|
alter procedure bar3 sql security invoker|
|
2003-11-17 18:21:36 +01:00
|
|
|
|
2003-10-10 16:57:21 +02:00
|
|
|
drop table t1|
|
|
|
|
|
|
|
|
--disable_warnings
|
|
|
|
drop table if exists t1|
|
|
|
|
--enable_warnings
|
|
|
|
create table t1 (val int, x float)|
|
|
|
|
insert into t1 values (42, 3.1), (19, 1.2)|
|
|
|
|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1327
|
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;
|
|
|
|
end|
|
|
|
|
|
|
|
|
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;
|
|
|
|
end|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1328
|
2003-10-10 16:57:21 +02:00
|
|
|
call p()|
|
|
|
|
drop procedure p|
|
|
|
|
|
|
|
|
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;
|
|
|
|
end|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1328
|
2003-10-10 16:57:21 +02:00
|
|
|
call p()|
|
|
|
|
drop procedure p|
|
|
|
|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1330
|
Various bug fixes:
- Duplicate parameters/variables, conditions and cursors (not allowed).
- ITERATE in labelled BEGIN-END (not allowed).
- Missing SQLSTATE [VALUE] keywords in CONDITION/HANDLER declaration (added).
- Empty BEGIN-END (now allowed).
- End label (now optional).
include/mysqld_error.h:
New error code for duplicate things (vars et al) in SPs.
mysql-test/r/sp-error.result:
New error tests for ITERATE in begin-end block and duplicate variables,
conditions and cursors.
mysql-test/r/sp.result:
New tests for empty begin-end blocks, overriding local variables outside scope
only, leave a begin-end block, and SQLSTATE [VALUE] words for CONDITION/HANDLER
declarations.
mysql-test/t/sp-error.test:
New error tests for ITERATE in begin-end block and duplicate variables,
conditions and cursors.
mysql-test/t/sp.test:
New tests for empty begin-end blocks, overriding local variables outside scope
only, leave a begin-end block, and SQLSTATE [VALUE] words for CONDITION/HANDLER
declarations.
sql/lex.h:
New SQLSTATE keyword.
sql/share/czech/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/danish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/dutch/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/english/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/estonian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/french/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/german/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/greek/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/hungarian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/italian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/japanese/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/korean/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/norwegian-ny/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/norwegian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/polish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/portuguese/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/romanian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/russian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/serbian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/slovak/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/spanish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/swedish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/ukrainian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/sp_pcontext.cc:
Keep track on scope limits for error checking of duplicate variables,
conditions and cursors.
sql/sp_pcontext.h:
Keep track on scope limits for error checking of duplicate variables,
conditions and cursors.
Also need to flag BEGIN labels to check for illegal ITERATEs.
sql/sql_yacc.yy:
End-labels in SPs loop and begin-end blocks are now optional.
SQLSTATE [VALUE] added to syntax for sqlstates.
Check for duplicate variable, condition and cursor declarations, but
only in the same scope.
Empty BEGIN-END statements now allowed.
Check if ITERATE is referring to a BEGIN label.
2003-11-13 19:34:56 +01:00
|
|
|
create procedure p(in x int, x char(10))
|
|
|
|
begin
|
|
|
|
end|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1330
|
Various bug fixes:
- Duplicate parameters/variables, conditions and cursors (not allowed).
- ITERATE in labelled BEGIN-END (not allowed).
- Missing SQLSTATE [VALUE] keywords in CONDITION/HANDLER declaration (added).
- Empty BEGIN-END (now allowed).
- End label (now optional).
include/mysqld_error.h:
New error code for duplicate things (vars et al) in SPs.
mysql-test/r/sp-error.result:
New error tests for ITERATE in begin-end block and duplicate variables,
conditions and cursors.
mysql-test/r/sp.result:
New tests for empty begin-end blocks, overriding local variables outside scope
only, leave a begin-end block, and SQLSTATE [VALUE] words for CONDITION/HANDLER
declarations.
mysql-test/t/sp-error.test:
New error tests for ITERATE in begin-end block and duplicate variables,
conditions and cursors.
mysql-test/t/sp.test:
New tests for empty begin-end blocks, overriding local variables outside scope
only, leave a begin-end block, and SQLSTATE [VALUE] words for CONDITION/HANDLER
declarations.
sql/lex.h:
New SQLSTATE keyword.
sql/share/czech/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/danish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/dutch/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/english/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/estonian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/french/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/german/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/greek/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/hungarian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/italian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/japanese/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/korean/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/norwegian-ny/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/norwegian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/polish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/portuguese/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/romanian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/russian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/serbian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/slovak/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/spanish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/swedish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/ukrainian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/sp_pcontext.cc:
Keep track on scope limits for error checking of duplicate variables,
conditions and cursors.
sql/sp_pcontext.h:
Keep track on scope limits for error checking of duplicate variables,
conditions and cursors.
Also need to flag BEGIN labels to check for illegal ITERATEs.
sql/sql_yacc.yy:
End-labels in SPs loop and begin-end blocks are now optional.
SQLSTATE [VALUE] added to syntax for sqlstates.
Check for duplicate variable, condition and cursor declarations, but
only in the same scope.
Empty BEGIN-END statements now allowed.
Check if ITERATE is referring to a BEGIN label.
2003-11-13 19:34:56 +01:00
|
|
|
create function p(x int, x char(10))
|
|
|
|
begin
|
|
|
|
end|
|
2003-11-14 13:46:50 +01:00
|
|
|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1331
|
Various bug fixes:
- Duplicate parameters/variables, conditions and cursors (not allowed).
- ITERATE in labelled BEGIN-END (not allowed).
- Missing SQLSTATE [VALUE] keywords in CONDITION/HANDLER declaration (added).
- Empty BEGIN-END (now allowed).
- End label (now optional).
include/mysqld_error.h:
New error code for duplicate things (vars et al) in SPs.
mysql-test/r/sp-error.result:
New error tests for ITERATE in begin-end block and duplicate variables,
conditions and cursors.
mysql-test/r/sp.result:
New tests for empty begin-end blocks, overriding local variables outside scope
only, leave a begin-end block, and SQLSTATE [VALUE] words for CONDITION/HANDLER
declarations.
mysql-test/t/sp-error.test:
New error tests for ITERATE in begin-end block and duplicate variables,
conditions and cursors.
mysql-test/t/sp.test:
New tests for empty begin-end blocks, overriding local variables outside scope
only, leave a begin-end block, and SQLSTATE [VALUE] words for CONDITION/HANDLER
declarations.
sql/lex.h:
New SQLSTATE keyword.
sql/share/czech/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/danish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/dutch/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/english/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/estonian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/french/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/german/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/greek/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/hungarian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/italian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/japanese/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/korean/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/norwegian-ny/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/norwegian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/polish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/portuguese/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/romanian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/russian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/serbian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/slovak/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/spanish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/swedish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/ukrainian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/sp_pcontext.cc:
Keep track on scope limits for error checking of duplicate variables,
conditions and cursors.
sql/sp_pcontext.h:
Keep track on scope limits for error checking of duplicate variables,
conditions and cursors.
Also need to flag BEGIN labels to check for illegal ITERATEs.
sql/sql_yacc.yy:
End-labels in SPs loop and begin-end blocks are now optional.
SQLSTATE [VALUE] added to syntax for sqlstates.
Check for duplicate variable, condition and cursor declarations, but
only in the same scope.
Empty BEGIN-END statements now allowed.
Check if ITERATE is referring to a BEGIN label.
2003-11-13 19:34:56 +01:00
|
|
|
create procedure p()
|
|
|
|
begin
|
|
|
|
declare x float;
|
|
|
|
declare x int;
|
|
|
|
end|
|
2003-11-14 13:46:50 +01:00
|
|
|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1332
|
Various bug fixes:
- Duplicate parameters/variables, conditions and cursors (not allowed).
- ITERATE in labelled BEGIN-END (not allowed).
- Missing SQLSTATE [VALUE] keywords in CONDITION/HANDLER declaration (added).
- Empty BEGIN-END (now allowed).
- End label (now optional).
include/mysqld_error.h:
New error code for duplicate things (vars et al) in SPs.
mysql-test/r/sp-error.result:
New error tests for ITERATE in begin-end block and duplicate variables,
conditions and cursors.
mysql-test/r/sp.result:
New tests for empty begin-end blocks, overriding local variables outside scope
only, leave a begin-end block, and SQLSTATE [VALUE] words for CONDITION/HANDLER
declarations.
mysql-test/t/sp-error.test:
New error tests for ITERATE in begin-end block and duplicate variables,
conditions and cursors.
mysql-test/t/sp.test:
New tests for empty begin-end blocks, overriding local variables outside scope
only, leave a begin-end block, and SQLSTATE [VALUE] words for CONDITION/HANDLER
declarations.
sql/lex.h:
New SQLSTATE keyword.
sql/share/czech/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/danish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/dutch/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/english/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/estonian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/french/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/german/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/greek/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/hungarian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/italian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/japanese/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/korean/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/norwegian-ny/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/norwegian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/polish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/portuguese/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/romanian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/russian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/serbian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/slovak/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/spanish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/swedish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/ukrainian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/sp_pcontext.cc:
Keep track on scope limits for error checking of duplicate variables,
conditions and cursors.
sql/sp_pcontext.h:
Keep track on scope limits for error checking of duplicate variables,
conditions and cursors.
Also need to flag BEGIN labels to check for illegal ITERATEs.
sql/sql_yacc.yy:
End-labels in SPs loop and begin-end blocks are now optional.
SQLSTATE [VALUE] added to syntax for sqlstates.
Check for duplicate variable, condition and cursor declarations, but
only in the same scope.
Empty BEGIN-END statements now allowed.
Check if ITERATE is referring to a BEGIN label.
2003-11-13 19:34:56 +01:00
|
|
|
create procedure p()
|
|
|
|
begin
|
|
|
|
declare c condition for 1064;
|
|
|
|
declare c condition for 1065;
|
|
|
|
end|
|
2003-11-14 13:46:50 +01:00
|
|
|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1333
|
Various bug fixes:
- Duplicate parameters/variables, conditions and cursors (not allowed).
- ITERATE in labelled BEGIN-END (not allowed).
- Missing SQLSTATE [VALUE] keywords in CONDITION/HANDLER declaration (added).
- Empty BEGIN-END (now allowed).
- End label (now optional).
include/mysqld_error.h:
New error code for duplicate things (vars et al) in SPs.
mysql-test/r/sp-error.result:
New error tests for ITERATE in begin-end block and duplicate variables,
conditions and cursors.
mysql-test/r/sp.result:
New tests for empty begin-end blocks, overriding local variables outside scope
only, leave a begin-end block, and SQLSTATE [VALUE] words for CONDITION/HANDLER
declarations.
mysql-test/t/sp-error.test:
New error tests for ITERATE in begin-end block and duplicate variables,
conditions and cursors.
mysql-test/t/sp.test:
New tests for empty begin-end blocks, overriding local variables outside scope
only, leave a begin-end block, and SQLSTATE [VALUE] words for CONDITION/HANDLER
declarations.
sql/lex.h:
New SQLSTATE keyword.
sql/share/czech/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/danish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/dutch/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/english/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/estonian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/french/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/german/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/greek/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/hungarian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/italian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/japanese/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/korean/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/norwegian-ny/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/norwegian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/polish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/portuguese/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/romanian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/russian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/serbian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/slovak/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/spanish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/swedish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/ukrainian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/sp_pcontext.cc:
Keep track on scope limits for error checking of duplicate variables,
conditions and cursors.
sql/sp_pcontext.h:
Keep track on scope limits for error checking of duplicate variables,
conditions and cursors.
Also need to flag BEGIN labels to check for illegal ITERATEs.
sql/sql_yacc.yy:
End-labels in SPs loop and begin-end blocks are now optional.
SQLSTATE [VALUE] added to syntax for sqlstates.
Check for duplicate variable, condition and cursor declarations, but
only in the same scope.
Empty BEGIN-END statements now allowed.
Check if ITERATE is referring to a BEGIN label.
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;
|
|
|
|
end|
|
|
|
|
|
2004-03-11 17:18:59 +01:00
|
|
|
# USE is not allowed
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1336
|
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
|
|
|
|
2004-03-29 11:16:45 +02:00
|
|
|
# Enforced standard order of declarations
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1337
|
2004-03-29 11:16:45 +02:00
|
|
|
create procedure p()
|
|
|
|
begin
|
|
|
|
declare c cursor for select * from t1;
|
|
|
|
declare x int;
|
|
|
|
end|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1337
|
2004-03-29 11:16:45 +02:00
|
|
|
create procedure p()
|
|
|
|
begin
|
|
|
|
declare x int;
|
|
|
|
declare continue handler for sqlstate '42S99' set x = 1;
|
|
|
|
declare foo condition for sqlstate '42S99';
|
|
|
|
end|
|
|
|
|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1338
|
2004-03-29 11:16:45 +02:00
|
|
|
create procedure p()
|
|
|
|
begin
|
|
|
|
declare x int;
|
|
|
|
declare continue handler for sqlstate '42S99' set x = 1;
|
|
|
|
declare c cursor for select * from t1;
|
|
|
|
end|
|
2004-03-11 17:18:59 +01:00
|
|
|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1358
|
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|
|
|
|
|
|
2003-11-27 16:48:21 +01:00
|
|
|
#
|
|
|
|
# BUG#1965
|
|
|
|
#
|
|
|
|
create procedure bug1965()
|
|
|
|
begin
|
|
|
|
declare c cursor for select val from t1 order by valname;
|
|
|
|
open c;
|
|
|
|
close c;
|
|
|
|
end|
|
|
|
|
|
|
|
|
--error 1054
|
|
|
|
call bug1965()|
|
|
|
|
drop procedure bug1965|
|
|
|
|
|
|
|
|
#
|
|
|
|
# BUG#1966
|
|
|
|
#
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1327
|
2003-11-27 16:48:21 +01:00
|
|
|
select 1 into a|
|
|
|
|
|
2003-12-13 16:40:52 +01:00
|
|
|
#
|
|
|
|
# BUG#1653
|
|
|
|
#
|
|
|
|
--disable_warnings
|
2004-04-05 17:01:19 +02:00
|
|
|
drop table if exists t3|
|
2003-12-13 16:40:52 +01:00
|
|
|
--enable_warnings
|
|
|
|
create table t3 (column_1_0 int)|
|
|
|
|
|
|
|
|
create procedure bug1653()
|
|
|
|
update t3 set column_1 = 0|
|
|
|
|
|
|
|
|
--error 1054
|
|
|
|
call bug1653()|
|
|
|
|
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
|
|
|
#
|
|
|
|
# BUG#2259
|
|
|
|
#
|
|
|
|
# Note: When this bug existed, it did not necessarily cause a crash
|
|
|
|
# in all builds, but valgrind did give warnings.
|
|
|
|
create procedure bug2259()
|
|
|
|
begin
|
|
|
|
declare v1 int;
|
WL#2130: Table locking for stored FUNCTIONs
Collect all tables and SPs refered by a statement, and open all tables
with an implicit LOCK TABLES. Do find things refered by triggers and views,
we open them first (and then repeat this until nothing new is found), before
doing the actual lock tables.
mysql-test/r/information_schema.result:
Updated result for WL#2130.
mysql-test/r/lock.result:
Updated result for WL#2130.
mysql-test/r/sp-error.result:
Updated result for WL#2130.
mysql-test/r/sp.result:
Updated result for WL#2130.
mysql-test/r/view.result:
Updated result for WL#2130.
mysql-test/t/information_schema.test:
Disabled one test case due to a bug involving LOCK TABLES,
which shows up with WL#2130.
mysql-test/t/lock.test:
New error message with WL#2130. This change is under debate and might change
in the future, but will do for now.
mysql-test/t/sp-error.test:
Updated for WL#2130. Some tests are voided when table access does work from
functions.
mysql-test/t/sp.test:
Updated for WL#2130.
mysql-test/t/view.test:
Updated for WL#2130.
sql/item_func.cc:
We now have to set net.no_send_ok for functions too, with WL#2130.
sql/share/errmsg.txt:
Reused an error code since the old use was voided by WL#2130, but a new
one was needed instead (similar, but more specific restriction).
sql/sp.cc:
Fixed error handling and collection of used tables for WL#2130.
sql/sp.h:
Fixed error handling and collection of used tables for WL#2130.
sql/sp_head.cc:
Added support functions for collecting and merging hash tables and lists
of used tables from SPs and substatements, for WL#2130.
sql/sp_head.h:
Added support functions for collecting and merging hash tables and lists
of used tables from SPs and substatements, for WL#2130.
sql/sql_base.cc:
Changed the way table->query_id is tested and set during with locked tables
in effect. This makes some SP test cases work with WL#2130, but has a side
effect on some error cases with explicit LOCK TABLES. It's still debated if
this is the correct way, so it might change.
sql/sql_class.h:
Added flags for circumventing some interference between WL#2130 and mysql_make_view().
sql/sql_derived.cc:
Added some missing initializations. (Potential bugs.)
sql/sql_lex.cc:
Clear the new hash tables for WL#2130.
sql/sql_lex.h:
Added hash tables for procedures and tables too (as for functions), for WL#2130.
sql/sql_parse.cc:
WL#2130: Make table accesses from stored functions work by adding an implicit
LOCK TABLES around (most) executed statements. To do this, we have to go through
a loop where we collect all SPs and tables in mysql_execute_statement.
sql/sql_prepare.cc:
Cache both functions and procedures for WL#2130.
sql/sql_show.cc:
Added some missing initializations. (Potential bugs.)
sql/sql_view.cc:
Shortcut mysql_make_view() if thd->shortcut_make_view is true during
the pre-open phase for collecting tables in WL#2130. Otherwise, the
similar mechanism here causes interference.
sql/sql_yacc.yy:
For WL#2130, added caching of procedures and disallowed LOCK/UNLOCK TABLES in SPs.
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|
|
|
|
|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1326
|
2004-01-08 10:37:31 +01:00
|
|
|
call bug2259()|
|
|
|
|
drop procedure bug2259|
|
|
|
|
|
2004-01-08 09:27:29 +01:00
|
|
|
#
|
|
|
|
# BUG#2272
|
|
|
|
#
|
|
|
|
create procedure bug2272()
|
|
|
|
begin
|
|
|
|
declare v int;
|
|
|
|
|
|
|
|
update t1 set v = 42;
|
|
|
|
end|
|
|
|
|
|
|
|
|
insert into t1 values (666, 51.3)|
|
|
|
|
--error 1054
|
|
|
|
call bug2272()|
|
|
|
|
delete from t1|
|
2004-01-08 10:37:31 +01:00
|
|
|
drop procedure bug2272|
|
2003-12-13 16:40:52 +01:00
|
|
|
|
2004-01-14 12:47:03 +01:00
|
|
|
#
|
|
|
|
# BUG#2329
|
|
|
|
#
|
|
|
|
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|
|
|
|
|
|
|
|
|
--error 1054
|
|
|
|
call bug2329_1()|
|
|
|
|
--error 1054
|
|
|
|
call bug2329_2()|
|
|
|
|
drop procedure bug2329_1|
|
|
|
|
drop procedure bug2329_2|
|
|
|
|
|
2004-03-29 12:29:06 +02:00
|
|
|
#
|
|
|
|
# BUG#3287
|
|
|
|
#
|
|
|
|
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|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1339
|
2004-03-29 12:29:06 +02:00
|
|
|
select bug3287()|
|
|
|
|
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|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1339
|
2004-03-29 12:29:06 +02:00
|
|
|
call bug3287(2)|
|
|
|
|
drop procedure bug3287|
|
|
|
|
|
2004-04-05 17:01:19 +02:00
|
|
|
#
|
|
|
|
# BUG#3297
|
|
|
|
#
|
|
|
|
--disable_warnings
|
|
|
|
drop table if exists t3|
|
|
|
|
--enable_warnings
|
|
|
|
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|
|
|
|
|
--error 1062
|
|
|
|
call bug3279(@x)|
|
|
|
|
select @x|
|
|
|
|
drop procedure bug3279|
|
|
|
|
drop table t3|
|
|
|
|
|
2004-06-15 15:42:28 +02:00
|
|
|
#
|
|
|
|
# BUG#3339
|
|
|
|
#
|
|
|
|
--error 1049
|
|
|
|
create procedure nodb.bug3339() begin end|
|
|
|
|
|
2004-07-21 14:53:09 +02:00
|
|
|
#
|
|
|
|
# BUG#2653
|
|
|
|
#
|
|
|
|
create procedure bug2653_1(a int, out b int)
|
|
|
|
set b = aa|
|
|
|
|
|
|
|
|
create procedure bug2653_2(a int, out b int)
|
|
|
|
begin
|
|
|
|
if aa < 0 then
|
|
|
|
set b = - a;
|
|
|
|
else
|
|
|
|
set b = a;
|
|
|
|
end if;
|
|
|
|
end|
|
|
|
|
|
|
|
|
--error 1054
|
|
|
|
call bug2653_1(1, @b)|
|
|
|
|
--error 1054
|
|
|
|
call bug2653_2(2, @b)|
|
|
|
|
|
|
|
|
drop procedure bug2653_1|
|
|
|
|
drop procedure bug2653_2|
|
2004-06-15 15:42:28 +02:00
|
|
|
|
2004-07-29 17:33:45 +02:00
|
|
|
#
|
|
|
|
# BUG#4344
|
|
|
|
#
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1357
|
2004-07-29 17:33:45 +02:00
|
|
|
create procedure bug4344() drop procedure bug4344|
|
2004-09-09 05:59:26 +02:00
|
|
|
--error 1357
|
2004-07-29 17:33:45 +02:00
|
|
|
create procedure bug4344() drop function bug4344|
|
|
|
|
|
2004-09-10 11:11:52 +02:00
|
|
|
#
|
|
|
|
# BUG#3294: Stored procedure crash if table dropped before use
|
|
|
|
# (Actually, when an error occurs within an error handler.)
|
|
|
|
--disable_warnings
|
|
|
|
drop procedure if exists bug3294|
|
|
|
|
--enable_warnings
|
|
|
|
create procedure bug3294()
|
|
|
|
begin
|
|
|
|
declare continue handler for sqlexception drop table t5;
|
|
|
|
drop table t5;
|
WL#2130: Table locking for stored FUNCTIONs
Collect all tables and SPs refered by a statement, and open all tables
with an implicit LOCK TABLES. Do find things refered by triggers and views,
we open them first (and then repeat this until nothing new is found), before
doing the actual lock tables.
mysql-test/r/information_schema.result:
Updated result for WL#2130.
mysql-test/r/lock.result:
Updated result for WL#2130.
mysql-test/r/sp-error.result:
Updated result for WL#2130.
mysql-test/r/sp.result:
Updated result for WL#2130.
mysql-test/r/view.result:
Updated result for WL#2130.
mysql-test/t/information_schema.test:
Disabled one test case due to a bug involving LOCK TABLES,
which shows up with WL#2130.
mysql-test/t/lock.test:
New error message with WL#2130. This change is under debate and might change
in the future, but will do for now.
mysql-test/t/sp-error.test:
Updated for WL#2130. Some tests are voided when table access does work from
functions.
mysql-test/t/sp.test:
Updated for WL#2130.
mysql-test/t/view.test:
Updated for WL#2130.
sql/item_func.cc:
We now have to set net.no_send_ok for functions too, with WL#2130.
sql/share/errmsg.txt:
Reused an error code since the old use was voided by WL#2130, but a new
one was needed instead (similar, but more specific restriction).
sql/sp.cc:
Fixed error handling and collection of used tables for WL#2130.
sql/sp.h:
Fixed error handling and collection of used tables for WL#2130.
sql/sp_head.cc:
Added support functions for collecting and merging hash tables and lists
of used tables from SPs and substatements, for WL#2130.
sql/sp_head.h:
Added support functions for collecting and merging hash tables and lists
of used tables from SPs and substatements, for WL#2130.
sql/sql_base.cc:
Changed the way table->query_id is tested and set during with locked tables
in effect. This makes some SP test cases work with WL#2130, but has a side
effect on some error cases with explicit LOCK TABLES. It's still debated if
this is the correct way, so it might change.
sql/sql_class.h:
Added flags for circumventing some interference between WL#2130 and mysql_make_view().
sql/sql_derived.cc:
Added some missing initializations. (Potential bugs.)
sql/sql_lex.cc:
Clear the new hash tables for WL#2130.
sql/sql_lex.h:
Added hash tables for procedures and tables too (as for functions), for WL#2130.
sql/sql_parse.cc:
WL#2130: Make table accesses from stored functions work by adding an implicit
LOCK TABLES around (most) executed statements. To do this, we have to go through
a loop where we collect all SPs and tables in mysql_execute_statement.
sql/sql_prepare.cc:
Cache both functions and procedures for WL#2130.
sql/sql_show.cc:
Added some missing initializations. (Potential bugs.)
sql/sql_view.cc:
Shortcut mysql_make_view() if thd->shortcut_make_view is true during
the pre-open phase for collecting tables in WL#2130. Otherwise, the
similar mechanism here causes interference.
sql/sql_yacc.yy:
For WL#2130, added caching of procedures and disallowed LOCK/UNLOCK TABLES in SPs.
2005-02-08 20:52:50 +01:00
|
|
|
drop table t5;
|
2004-09-10 11:11:52 +02:00
|
|
|
end|
|
|
|
|
|
WL#2130: Table locking for stored FUNCTIONs
Collect all tables and SPs refered by a statement, and open all tables
with an implicit LOCK TABLES. Do find things refered by triggers and views,
we open them first (and then repeat this until nothing new is found), before
doing the actual lock tables.
mysql-test/r/information_schema.result:
Updated result for WL#2130.
mysql-test/r/lock.result:
Updated result for WL#2130.
mysql-test/r/sp-error.result:
Updated result for WL#2130.
mysql-test/r/sp.result:
Updated result for WL#2130.
mysql-test/r/view.result:
Updated result for WL#2130.
mysql-test/t/information_schema.test:
Disabled one test case due to a bug involving LOCK TABLES,
which shows up with WL#2130.
mysql-test/t/lock.test:
New error message with WL#2130. This change is under debate and might change
in the future, but will do for now.
mysql-test/t/sp-error.test:
Updated for WL#2130. Some tests are voided when table access does work from
functions.
mysql-test/t/sp.test:
Updated for WL#2130.
mysql-test/t/view.test:
Updated for WL#2130.
sql/item_func.cc:
We now have to set net.no_send_ok for functions too, with WL#2130.
sql/share/errmsg.txt:
Reused an error code since the old use was voided by WL#2130, but a new
one was needed instead (similar, but more specific restriction).
sql/sp.cc:
Fixed error handling and collection of used tables for WL#2130.
sql/sp.h:
Fixed error handling and collection of used tables for WL#2130.
sql/sp_head.cc:
Added support functions for collecting and merging hash tables and lists
of used tables from SPs and substatements, for WL#2130.
sql/sp_head.h:
Added support functions for collecting and merging hash tables and lists
of used tables from SPs and substatements, for WL#2130.
sql/sql_base.cc:
Changed the way table->query_id is tested and set during with locked tables
in effect. This makes some SP test cases work with WL#2130, but has a side
effect on some error cases with explicit LOCK TABLES. It's still debated if
this is the correct way, so it might change.
sql/sql_class.h:
Added flags for circumventing some interference between WL#2130 and mysql_make_view().
sql/sql_derived.cc:
Added some missing initializations. (Potential bugs.)
sql/sql_lex.cc:
Clear the new hash tables for WL#2130.
sql/sql_lex.h:
Added hash tables for procedures and tables too (as for functions), for WL#2130.
sql/sql_parse.cc:
WL#2130: Make table accesses from stored functions work by adding an implicit
LOCK TABLES around (most) executed statements. To do this, we have to go through
a loop where we collect all SPs and tables in mysql_execute_statement.
sql/sql_prepare.cc:
Cache both functions and procedures for WL#2130.
sql/sql_show.cc:
Added some missing initializations. (Potential bugs.)
sql/sql_view.cc:
Shortcut mysql_make_view() if thd->shortcut_make_view is true during
the pre-open phase for collecting tables in WL#2130. Otherwise, the
similar mechanism here causes interference.
sql/sql_yacc.yy:
For WL#2130, added caching of procedures and disallowed LOCK/UNLOCK TABLES in SPs.
2005-02-08 20:52:50 +01:00
|
|
|
create table t5 (x int)|
|
2004-09-10 11:11:52 +02:00
|
|
|
--error 1051
|
|
|
|
call bug3294()|
|
|
|
|
drop procedure bug3294|
|
|
|
|
|
2004-11-25 16:13:06 +01:00
|
|
|
#
|
|
|
|
# BUG#6807: Stored procedure crash if CREATE PROCEDURE ... KILL QUERY
|
|
|
|
#
|
|
|
|
--disable_warnings
|
|
|
|
drop procedure if exists bug6807|
|
|
|
|
--enable_warnings
|
|
|
|
create procedure bug6807()
|
|
|
|
begin
|
|
|
|
declare id int;
|
|
|
|
|
|
|
|
set id = connection_id();
|
|
|
|
kill query id;
|
|
|
|
select 'Not reached';
|
|
|
|
end|
|
|
|
|
|
|
|
|
--error 1317
|
|
|
|
call bug6807()|
|
|
|
|
--error 1317
|
|
|
|
call bug6807()|
|
|
|
|
|
|
|
|
drop procedure bug6807|
|
|
|
|
|
2005-02-28 18:07:06 +01:00
|
|
|
#
|
|
|
|
# BUG#876: Stored Procedures: Invalid SQLSTATE is allowed in
|
|
|
|
# a DECLARE ? HANDLER FOR stmt.
|
|
|
|
#
|
|
|
|
--disable_warnings
|
|
|
|
drop procedure if exists bug8776_1|
|
|
|
|
drop procedure if exists bug8776_2|
|
|
|
|
drop procedure if exists bug8776_3|
|
|
|
|
drop procedure if exists bug8776_4|
|
|
|
|
--enable_warnings
|
|
|
|
--error ER_SP_BAD_SQLSTATE
|
|
|
|
create procedure bug8776_1()
|
|
|
|
begin
|
|
|
|
declare continue handler for sqlstate '42S0200test' begin end;
|
|
|
|
begin end;
|
|
|
|
end|
|
|
|
|
|
|
|
|
--error ER_SP_BAD_SQLSTATE
|
|
|
|
create procedure bug8776_2()
|
|
|
|
begin
|
|
|
|
declare continue handler for sqlstate '4200' begin end;
|
|
|
|
begin end;
|
|
|
|
end|
|
|
|
|
|
|
|
|
--error ER_SP_BAD_SQLSTATE
|
|
|
|
create procedure bug8776_3()
|
|
|
|
begin
|
|
|
|
declare continue handler for sqlstate '420000' begin end;
|
|
|
|
begin end;
|
|
|
|
end|
|
|
|
|
|
|
|
|
--error ER_SP_BAD_SQLSTATE
|
|
|
|
create procedure bug8776_4()
|
|
|
|
begin
|
|
|
|
declare continue handler for sqlstate '42x00' begin end;
|
|
|
|
begin end;
|
|
|
|
end|
|
|
|
|
|
2004-07-29 17:33:45 +02:00
|
|
|
|
2005-03-18 14:33:46 +01:00
|
|
|
#
|
|
|
|
# BUG#NNNN: New bug synopsis
|
|
|
|
#
|
|
|
|
#--disable_warnings
|
|
|
|
#drop procedure if exists bugNNNN|
|
|
|
|
#--enable_warnings
|
|
|
|
#create procedure bugNNNN...
|
|
|
|
|
|
|
|
|
2003-10-10 16:57:21 +02:00
|
|
|
drop table t1|
|
|
|
|
|
2003-03-05 19:45:17 +01:00
|
|
|
delimiter ;|
|