Commit aa18c31d authored by unknown's avatar unknown

Check the number of args to SPs.

Fixes bug #280.


include/mysqld_error.h:
  Check the number of args to SPs.
mysql-test/r/sp-error.result:
  Check the number of args to SPs.
mysql-test/t/sp-error.test:
  Check the number of args to SPs.
sql/share/czech/errmsg.txt:
  Check the number of args to SPs.
sql/share/danish/errmsg.txt:
  Check the number of args to SPs.
sql/share/dutch/errmsg.txt:
  Check the number of args to SPs.
sql/share/english/errmsg.txt:
  Check the number of args to SPs.
sql/share/estonian/errmsg.txt:
  Check the number of args to SPs.
sql/share/french/errmsg.txt:
  Check the number of args to SPs.
sql/share/german/errmsg.txt:
  Check the number of args to SPs.
sql/share/greek/errmsg.txt:
  Check the number of args to SPs.
sql/share/hungarian/errmsg.txt:
  Check the number of args to SPs.
sql/share/italian/errmsg.txt:
  Check the number of args to SPs.
sql/share/japanese/errmsg.txt:
  Check the number of args to SPs.
sql/share/korean/errmsg.txt:
  Check the number of args to SPs.
sql/share/norwegian-ny/errmsg.txt:
  Check the number of args to SPs.
sql/share/norwegian/errmsg.txt:
  Check the number of args to SPs.
sql/share/polish/errmsg.txt:
  Check the number of args to SPs.
sql/share/portuguese/errmsg.txt:
  Check the number of args to SPs.
sql/share/romanian/errmsg.txt:
  Check the number of args to SPs.
sql/share/russian/errmsg.txt:
  Check the number of args to SPs.
sql/share/serbian/errmsg.txt:
  Check the number of args to SPs.
sql/share/slovak/errmsg.txt:
  Check the number of args to SPs.
sql/share/spanish/errmsg.txt:
  Check the number of args to SPs.
sql/share/swedish/errmsg.txt:
  Check the number of args to SPs.
sql/share/ukrainian/errmsg.txt:
  Check the number of args to SPs.
sql/sp_head.cc:
  Check the number of args to SPs.
parent 1ba1e2ae
......@@ -290,4 +290,5 @@
#define ER_UPDATE_LOG_DEPRECATED_IGNORED 1271
#define ER_UPDATE_LOG_DEPRECATED_TRANSLATED 1272
#define ER_QUERY_INTERRUPTED 1273
#define ER_ERROR_MESSAGES 274
#define ER_SP_WRONG_NO_OF_ARGS 1274
#define ER_ERROR_MESSAGES 275
......@@ -15,6 +15,8 @@ PROCEDURE proc1 already exists
create function func1() returns int
return 42;
FUNCTION func1 already exists
drop procedure proc1;
drop function func1;
alter procedure foo;
PROCEDURE foo does not exist
alter function foo;
......@@ -69,5 +71,17 @@ 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;
create procedure p(x int)
insert into test.t1 values (x);
create function f(x int) returns int
return x+42;
call p();
Wrong number of arguments for PROCEDURE p, expected 1, got 0
call p(1, 2);
Wrong number of arguments for PROCEDURE p, expected 1, got 2
select f();
Wrong number of arguments for FUNCTION f, expected 1, got 0
select f(1, 2);
Wrong number of arguments for FUNCTION f, expected 1, got 2
drop procedure p;
drop function f;
......@@ -37,6 +37,9 @@ create procedure proc1()
create function func1() returns int
return 42|
drop procedure proc1|
drop function func1|
# Does not exist
--error 1261
alter procedure foo|
......@@ -105,7 +108,22 @@ begin
return x;
end|
drop procedure proc1|
drop function func1|
# Wrong number of arguments
create procedure p(x int)
insert into test.t1 values (x)|
create function f(x int) returns int
return x+42|
--error 1274
call p()|
--error 1274
call p(1, 2)|
--error 1274
select f()|
--error 1274
select f(1, 2)|
drop procedure p|
drop function f|
delimiter ;|
......@@ -284,3 +284,4 @@ v/*
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -278,3 +278,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -286,3 +286,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -275,3 +275,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -280,3 +280,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -275,3 +275,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -284,3 +284,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -275,3 +275,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -277,3 +277,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -275,3 +275,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -277,3 +277,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -275,3 +275,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -277,3 +277,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -277,3 +277,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -279,3 +279,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -275,3 +275,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -279,3 +279,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -277,3 +277,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -271,3 +271,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -283,3 +283,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -276,3 +276,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -275,3 +275,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -280,3 +280,4 @@
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored."
"The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been translated to SET SQL_LOG_BIN."
"Query execution was interrupted"
"Wrong number of arguments for %s %s, expected %u, got %u"
......@@ -199,7 +199,16 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp)
uint i;
int ret;
// QQ Should have some error checking here? (no. of args, types, etc...)
if (argcount != params)
{
// Need to use my_printf_error here, or it will not terminate the
// invoking query properly.
my_printf_error(ER_SP_WRONG_NO_OF_ARGS, ER(ER_SP_WRONG_NO_OF_ARGS), MYF(0),
"FUNCTION", m_name.str, params, argcount);
DBUG_RETURN(-1);
}
// QQ Should have some error checking here? (types, etc...)
nctx= new sp_rcontext(csize);
for (i= 0 ; i < params && i < argcount ; i++)
{
......@@ -234,6 +243,13 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
sp_rcontext *nctx = NULL;
my_bool tmp_octx = FALSE; // True if we have allocated a temporary octx
if (args->elements != params)
{
net_printf(thd, ER_SP_WRONG_NO_OF_ARGS, "PROCEDURE", m_name.str,
params, args->elements);
DBUG_RETURN(-1);
}
if (csize > 0)
{
uint i;
......@@ -246,7 +262,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
octx = new sp_rcontext(csize);
tmp_octx = TRUE;
}
// QQ: No error checking whatsoever right now. Should do type checking?
// QQ: Should do type checking?
for (i = 0 ; (it= li++) && i < params ; i++)
{
sp_pvar_t *pvar = m_pcont->find_pvar(i);
......
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