Commit f74b36a2 authored by unknown's avatar unknown

Improved error handling regarding SPs (with info like names etc in the output).

Disabled queries in FUNCTIONs.


include/mysqld_error.h:
  New error message for queries in FUNCTIONs.
mysql-test/t/sp.test:
  Moved error tests to sp-error.test.
sql/share/czech/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/danish/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/dutch/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/english/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/estonian/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/french/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/german/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/greek/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/hungarian/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/italian/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/japanese/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/korean/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/norwegian-ny/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/norwegian/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/polish/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/portuguese/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/romanian/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/russian/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/serbian/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/slovak/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/spanish/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/swedish/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/share/ukrainian/errmsg.txt:
  New error message for queries in FUNCTIONs.
  Improved most of the SP error messages with added info.
sql/sp_head.cc:
  Added debug output to sp_instr_jump::execute(). (Moved from sp_head.h)
sql/sp_head.h:
  Moved sp_instr_jump::execute() to sp_head.cc.
sql/sql_lex.h:
  Added SQLCOM_CREATE_SPFUNCTION (for improved error handling).
sql/sql_parse.cc:
  Improved error handling regarding SPs (adding info like names etc in output).
sql/sql_yacc.yy:
  Improved error handling regarding SPs (adding info like names etc in output).
  Disabled queries in FUNCTIONS (since it can't work anyway).
parent f519382d
......@@ -277,4 +277,5 @@
#define ER_SP_UNINIT_VAR 1258
#define ER_SP_BADSELECT 1259
#define ER_SP_BADRETURN 1260
#define ER_ERROR_MESSAGES 261
#define ER_SP_BADQUERY 1261
#define ER_ERROR_MESSAGES 262
delete from mysql.proc;
create procedure proc1()
set @x = 42;
create function func1() returns int
return 42;
create procedure foo()
create procedure bar() set @x=3;
Can't create a PROCEDURE from within another stored routine
create procedure foo()
create function bar() returns double return 2.3;
Can't create a FUNCTION from within another stored routine
create procedure proc1()
set @x = 42;
PROCEDURE proc1 already exists
create function func1() returns int
return 42;
FUNCTION func1 already exists
alter procedure foo;
PROCEDURE foo does not exist
alter function foo;
FUNCTION foo does not exist
drop procedure foo;
PROCEDURE foo does not exist
drop function foo;
FUNCTION foo does not exist
call foo();
PROCEDURE foo does not exist
create procedure foo()
foo: loop
leave bar;
end loop;
LEAVE with no matching label: bar
create procedure foo()
foo: loop
iterate bar;
end loop;
ITERATE with no matching label: bar
create procedure foo()
foo: loop
foo: loop
set @x=2;
end loop foo;
end loop foo;
Redefining label foo
create procedure foo()
foo: loop
set @x=2;
end loop bar;
End-label bar without match
create procedure foo(out x int)
begin
declare y int;
set x = y;
end;
Referring to uninitialized variable y
create procedure foo(x int)
select * from test.t1;
SELECT in a stored procedure must have INTO
create procedure foo()
return 42;
RETURN is only allowed in a FUNCTION
create function foo() returns int
begin
declare x int;
select max(c) into x from test.t;
return x;
end;
Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION
drop procedure proc1;
drop function func1;
#
# Stored PROCEDURE error tests
#
# Make sure we don't have any procedures left.
delete from mysql.proc;
delimiter |;
# Check that we get the right error, i.e. UDF declaration parses correctly,
# but foo.so doesn't exist.
# QQ This generates an error message containing a misleading errno which
# 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"|
create procedure proc1()
set @x = 42|
create function func1() returns int
return 42|
# Can't create recursively
--error 1250
create procedure foo()
create procedure bar() set @x=3|
--error 1250
create procedure foo()
create function bar() returns double return 2.3|
# Already exists
--error 1251
create procedure proc1()
set @x = 42|
--error 1251
create function func1() returns int
return 42|
# Does not exist
--error 1252
alter procedure foo|
--error 1252
alter function foo|
--error 1252
drop procedure foo|
--error 1252
drop function foo|
--error 1252
call foo()|
# LEAVE/ITERATE with no match
--error 1255
create procedure foo()
foo: loop
leave bar;
end loop|
--error 1255
create procedure foo()
foo: loop
iterate bar;
end loop|
# Redefining label
--error 1256
create procedure foo()
foo: loop
foo: loop
set @x=2;
end loop foo;
end loop foo|
# End label mismatch
--error 1257
create procedure foo()
foo: loop
set @x=2;
end loop bar|
# Referring to undef variable
--error 1258
create procedure foo(out x int)
begin
declare y int;
set x = y;
end|
# We require INTO in SELECTs (for now; this might change in the future)
--error 1259
create procedure foo(x int)
select * from test.t1|
# RETURN in FUNCTION only
--error 1260
create procedure foo()
return 42|
# Doesn't allow queries in FUNCTIONs (for now :-( )
--error 1261
create function foo() returns int
begin
declare x int;
select max(c) into x from test.t;
return x;
end|
drop procedure proc1|
drop function func1|
delimiter ;|
......@@ -213,16 +213,6 @@ until x = 0 end repeat|
drop procedure b2|
# Btw, this should generate an error (for now; this might change in the future)
--error 1259
create procedure b3(x int)
repeat
select * from test.t1; # No INTO!
insert into test.t1 values (repeat("b3",3), x);
set x = x-1;
until x = 0 end repeat|
# Labelled WHILE with ITERATE (pointless really)
create procedure c(x int)
hmm: while x > 0 do
......@@ -398,14 +388,6 @@ end|
#drop table t2|
drop procedure create_select|
# Check that we get the right error, i.e. UDF declaration parses correctly,
# but foo.so doesn't exist.
# QQ This generates an error message containing a misleading errno which
# 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"|
# A minimal, constant FUNCTION.
create function e() returns double
return 2.7182818284590452354|
......
......@@ -260,14 +260,15 @@ v/*
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -254,14 +254,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -262,14 +262,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -251,14 +251,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -256,14 +256,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -251,14 +251,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -261,14 +261,15 @@
"Select %u wurde während der Optimierung reduziert.",
"Tabelle '%-.64s', die in einem der SELECT-Befehle verwendet wurde kann nicht in %-.32s verwendet werden."
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -251,14 +251,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -253,14 +253,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -251,14 +251,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -253,14 +253,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -251,14 +251,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -253,14 +253,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -253,14 +253,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -255,14 +255,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -251,14 +251,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -255,14 +255,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -254,14 +254,15 @@
"Select %u ",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -247,14 +247,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -259,14 +259,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -252,14 +252,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -251,14 +251,15 @@
"Select %u was reduced during optimisation",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -256,14 +256,15 @@
"Select %u was iii",
"Table '%-.64s' from one of SELECT's can not be used in %-.32s"
"Client does not support authentication protocol requested by server. Consider upgrading MySQL client"
"Can't create a PROCEDURE from within a PROCEDURE"
"PROCEDURE already exists"
"PROCEDURE does not exist"
"Failed to DROP PROCEDURE"
"Failed to CREATE PROCEDURE"
"%s with no matching label"
"Redefining label"
"End-label without match"
"Referring to uninitialized variable"
"Can't create a %s from within another stored routine"
"%s %s already exists"
"%s %s does not exist"
"Failed to DROP %s %s"
"Failed to CREATE %s %s"
"%s with no matching label: %s"
"Redefining label %s"
"End-label %s without match"
"Referring to uninitialized variable %s"
"SELECT in a stored procedure must have INTO"
"RETURN is only allowed in a stored FUNCTION"
"RETURN is only allowed in a FUNCTION"
"Queries, like SELECT, INSERT, UPDATE (and others), are not allowed in a FUNCTION"
......@@ -442,6 +442,19 @@ sp_instr_set::execute(THD *thd, uint *nextp)
DBUG_RETURN(0);
}
//
// sp_instr_jump
//
int
sp_instr_jump::execute(THD *thd, uint *nextp)
{
DBUG_ENTER("sp_instr_jump::execute");
DBUG_PRINT("info", ("destination: %u", m_dest));
*nextp= m_dest;
DBUG_RETURN(0);
}
//
// sp_instr_jump_if
//
......
......@@ -265,11 +265,7 @@ public:
virtual ~sp_instr_jump()
{}
virtual int execute(THD *thd, uint *nextp)
{
*nextp= m_dest;
return 0;
}
virtual int execute(THD *thd, uint *nextp);
virtual void
set_destination(uint dest)
......
......@@ -75,7 +75,7 @@ enum enum_sql_command {
SQLCOM_SHOW_WARNS, SQLCOM_EMPTY_QUERY, SQLCOM_SHOW_ERRORS,
SQLCOM_SHOW_COLUMN_TYPES, SQLCOM_SHOW_TABLE_TYPES, SQLCOM_SHOW_PRIVILEGES,
SQLCOM_HELP,
SQLCOM_CREATE_PROCEDURE, SQLCOM_CALL,
SQLCOM_CREATE_PROCEDURE, SQLCOM_CREATE_SPFUNCTION, SQLCOM_CALL,
SQLCOM_DROP_PROCEDURE, SQLCOM_ALTER_PROCEDURE,SQLCOM_ALTER_FUNCTION,
/* This should be the last !!! */
......
......@@ -52,6 +52,15 @@
#define TRANS_MEM_ROOT_BLOCK_SIZE 4096
#define TRANS_MEM_ROOT_PREALLOC 4096
/* Used in error handling only */
#define SP_TYPE_STRING(LP) \
((LP)->sphead->m_type == TYPE_ENUM_FUNCTION ? "FUNCTION" : "PROCEDURE")
#define SP_COM_STRING(LP) \
((LP)->sql_command == SQLCOM_CREATE_SPFUNCTION || \
(LP)->sql_command == SQLCOM_ALTER_FUNCTION || \
(LP)->sql_command == SQLCOM_DROP_FUNCTION ? \
"FUNCTION" : "PROCEDURE")
extern int yyparse(void *thd);
extern "C" pthread_mutex_t THR_LOCK_keycache;
#ifdef SOLARIS
......@@ -1589,7 +1598,7 @@ mysql_execute_command(THD *thd)
*/
sp_clear_function_cache(thd);
if (lex->sql_command != SQLCOM_CREATE_PROCEDURE &&
lex->sql_command != SQLCOM_CREATE_FUNCTION)
lex->sql_command != SQLCOM_CREATE_SPFUNCTION)
{
if (sp_cache_functions(thd, lex))
DBUG_RETURN(-1);
......@@ -2961,23 +2970,27 @@ mysql_execute_command(THD *thd)
res= -1;
thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE);
break;
case SQLCOM_CREATE_PROCEDURE: // FUNCTION too (but not UDF!)
case SQLCOM_CREATE_PROCEDURE:
case SQLCOM_CREATE_SPFUNCTION:
if (!lex->sphead)
{
send_error(thd, ER_SP_NO_RECURSIVE_CREATE);
goto error;
res= -1; // Shouldn't happen
break;
}
else
{
uint namelen;
char *name= lex->sphead->name(&namelen);
#ifdef HAVE_DLOPEN
udf_func *udf = find_udf(name, namelen);
if (udf)
if (lex->sphead->m_type == TYPE_ENUM_FUNCTION)
{
net_printf(thd, ER_UDF_EXISTS, name);
goto error;
udf_func *udf = find_udf(name, namelen);
if (udf)
{
net_printf(thd, ER_UDF_EXISTS, name);
goto error;
}
}
#endif
res= lex->sphead->create(thd);
......@@ -2987,10 +3000,10 @@ mysql_execute_command(THD *thd)
send_ok(thd);
break;
case SP_WRITE_ROW_FAILED:
send_error(thd, ER_SP_ALREADY_EXISTS);
net_printf(thd, ER_SP_ALREADY_EXISTS, SP_TYPE_STRING(lex), name);
goto error;
default:
send_error(thd, ER_SP_STORE_FAILED);
net_printf(thd, ER_SP_STORE_FAILED, SP_TYPE_STRING(lex), name);
goto error;
}
}
......@@ -3002,7 +3015,7 @@ mysql_execute_command(THD *thd)
sp= sp_find_procedure(thd, &lex->udf.name);
if (! sp)
{
send_error(thd, ER_SP_DOES_NOT_EXIST);
net_printf(thd, ER_SP_DOES_NOT_EXIST, "PROCEDURE", lex->udf.name);
goto error;
}
else
......@@ -3037,7 +3050,7 @@ mysql_execute_command(THD *thd)
sp= sp_find_function(thd, &lex->udf.name);
if (! sp)
{
send_error(thd, ER_SP_DOES_NOT_EXIST);
net_printf(thd, ER_SP_DOES_NOT_EXIST, SP_COM_STRING(lex),lex->udf.name);
goto error;
}
else
......@@ -3079,10 +3092,12 @@ mysql_execute_command(THD *thd)
send_ok(thd);
break;
case SP_KEY_NOT_FOUND:
send_error(thd, ER_SP_DOES_NOT_EXIST);
net_printf(thd, ER_SP_DOES_NOT_EXIST, SP_COM_STRING(lex),
lex->udf.name.str);
goto error;
default:
send_error(thd, ER_SP_DROP_FAILED);
net_printf(thd, ER_SP_DROP_FAILED, SP_COM_STRING(lex),
lex->udf.name.str);
goto error;
}
}
......
......@@ -917,6 +917,11 @@ create:
{
LEX *lex= Lex;
if (lex->sphead)
{
net_printf(YYTHD, ER_SP_NO_RECURSIVE_CREATE, "PROCEDURE");
YYABORT;
}
lex->spcont= new sp_pcontext();
lex->sphead= new sp_head(&$3, lex);
lex->sphead->m_type= TYPE_ENUM_PROCEDURE;
......@@ -948,7 +953,11 @@ create_function_tail:
{
LEX *lex= Lex;
lex->sql_command = SQLCOM_CREATE_PROCEDURE;
if (lex->sphead)
{
net_printf(YYTHD, ER_SP_NO_RECURSIVE_CREATE, "FUNCTION");
YYABORT;
}
lex->spcont= new sp_pcontext();
lex->sphead= new sp_head(&lex->udf.name, lex);
lex->sphead->m_type= TYPE_ENUM_FUNCTION;
......@@ -962,7 +971,9 @@ create_function_tail:
Lex->sphead->m_returns= (enum enum_field_types)$7;
}
sp_proc_stmt
{}
{
Lex->sql_command = SQLCOM_CREATE_SPFUNCTION;
}
;
call:
......@@ -1110,10 +1121,25 @@ sp_proc_stmt:
if (lex->sql_command != SQLCOM_SET_OPTION ||
!lex->var_list.is_empty())
{
sp_instr_stmt *i= new sp_instr_stmt(lex->sphead->instructions());
i->set_lex(lex);
lex->sphead->add_instr(i);
/* Currently we can't handle queries inside a FUNCTION,
** because of the way table locking works.
** This is unfortunate, and limits the usefulness of functions
** a great deal, but it's nothing we can do about this at the
** moment.
*/
if (lex->sphead->m_type == TYPE_ENUM_FUNCTION &&
lex->sql_command != SQLCOM_SET_OPTION)
{
send_error(YYTHD, ER_SP_BADQUERY);
YYABORT;
}
else
{
sp_instr_stmt *i= new sp_instr_stmt(lex->sphead->instructions());
i->set_lex(lex);
lex->sphead->add_instr(i);
}
}
lex->sphead->restore_lex(YYTHD);
}
......@@ -1185,7 +1211,7 @@ sp_proc_stmt:
if (! lab)
{
send_error(YYTHD, ER_SP_LILABEL_MISMATCH, "LEAVE");
net_printf(YYTHD, ER_SP_LILABEL_MISMATCH, "LEAVE", $2.str);
YYABORT;
}
else
......@@ -1203,7 +1229,7 @@ sp_proc_stmt:
if (! lab)
{
send_error(YYTHD, ER_SP_LILABEL_MISMATCH, "ITERATE");
net_printf(YYTHD, ER_SP_LILABEL_MISMATCH, "ITERATE", $2.str);
YYABORT;
}
else
......@@ -1305,7 +1331,7 @@ sp_labeled_control:
if (lab)
{
send_error(YYTHD, ER_SP_LABEL_REDEFINE);
net_printf(YYTHD, ER_SP_LABEL_REDEFINE, $1.str);
YYABORT;
}
else
......@@ -1321,7 +1347,7 @@ sp_labeled_control:
if (! lab || strcasecmp($5.str, lab->name) != 0)
{
send_error(YYTHD, ER_SP_LABEL_MISMATCH);
net_printf(YYTHD, ER_SP_LABEL_MISMATCH, $5.str);
YYABORT;
}
else
......@@ -1965,6 +1991,17 @@ alter:
lex->sql_command= SQLCOM_ALTER_PROCEDURE;
lex->udf.name= $3;
}
| ALTER FUNCTION_SYM ident
/* QQ Characteristics missing for now */
opt_restrict
{
LEX *lex=Lex;
/* This is essensially an no-op right now, since we haven't
put the characteristics in yet. */
lex->sql_command= SQLCOM_ALTER_FUNCTION;
lex->udf.name= $3;
}
;
alter_list:
......@@ -3526,10 +3563,13 @@ select_var_ident:
send_error(lex->thd, ER_SYNTAX_ERROR);
YYABORT;
}
if (lex->result)
((select_dumpvar *)lex->result)->var_list.push_back( new my_var($1,1,t->offset));
else
if (! lex->result)
YYABORT;
else
{
((select_dumpvar *)lex->result)->var_list.push_back( new my_var($1,1,t->offset));
t->isset= TRUE;
}
}
;
......@@ -4384,7 +4424,7 @@ simple_ident:
{ /* We're compiling a stored procedure and found a variable */
if (lex->sql_command != SQLCOM_CALL && ! spv->isset)
{
send_error(YYTHD, ER_SP_UNINIT_VAR);
net_printf(YYTHD, ER_SP_UNINIT_VAR, $1.str);
YYABORT;
}
else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment