summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mysqld_error.h3
-rw-r--r--mysql-test/r/sp-error.result18
-rw-r--r--mysql-test/t/sp-error.test22
-rw-r--r--sql/share/czech/errmsg.txt1
-rw-r--r--sql/share/danish/errmsg.txt1
-rw-r--r--sql/share/dutch/errmsg.txt1
-rw-r--r--sql/share/english/errmsg.txt1
-rw-r--r--sql/share/estonian/errmsg.txt1
-rw-r--r--sql/share/french/errmsg.txt1
-rw-r--r--sql/share/german/errmsg.txt1
-rw-r--r--sql/share/greek/errmsg.txt1
-rw-r--r--sql/share/hungarian/errmsg.txt1
-rw-r--r--sql/share/italian/errmsg.txt1
-rw-r--r--sql/share/japanese/errmsg.txt1
-rw-r--r--sql/share/korean/errmsg.txt1
-rw-r--r--sql/share/norwegian-ny/errmsg.txt1
-rw-r--r--sql/share/norwegian/errmsg.txt1
-rw-r--r--sql/share/polish/errmsg.txt1
-rw-r--r--sql/share/portuguese/errmsg.txt1
-rw-r--r--sql/share/romanian/errmsg.txt1
-rw-r--r--sql/share/russian/errmsg.txt1
-rw-r--r--sql/share/serbian/errmsg.txt1
-rw-r--r--sql/share/slovak/errmsg.txt1
-rw-r--r--sql/share/spanish/errmsg.txt1
-rw-r--r--sql/share/swedish/errmsg.txt1
-rw-r--r--sql/share/ukrainian/errmsg.txt1
-rw-r--r--sql/sp_head.cc20
27 files changed, 79 insertions, 7 deletions
diff --git a/include/mysqld_error.h b/include/mysqld_error.h
index 5cd38a77614..623e665703e 100644
--- a/include/mysqld_error.h
+++ b/include/mysqld_error.h
@@ -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
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index c754544a840..5e1815d685f 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -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;
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index 63850f409dc..cdeca75cd97 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -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 ;|
diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt
index 4954c8e9c35..76e69e23426 100644
--- a/sql/share/czech/errmsg.txt
+++ b/sql/share/czech/errmsg.txt
@@ -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"
diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt
index 3a129ce39d0..363c9baa54c 100644
--- a/sql/share/danish/errmsg.txt
+++ b/sql/share/danish/errmsg.txt
@@ -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"
diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt
index d7411a727ec..9d008de76bb 100644
--- a/sql/share/dutch/errmsg.txt
+++ b/sql/share/dutch/errmsg.txt
@@ -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"
diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt
index 93b5aefedc9..19032f55d83 100644
--- a/sql/share/english/errmsg.txt
+++ b/sql/share/english/errmsg.txt
@@ -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"
diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt
index 9b6c015ae91..1bfdf8207ac 100644
--- a/sql/share/estonian/errmsg.txt
+++ b/sql/share/estonian/errmsg.txt
@@ -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"
diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt
index d51bbff6fcc..4775f14f30b 100644
--- a/sql/share/french/errmsg.txt
+++ b/sql/share/french/errmsg.txt
@@ -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"
diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt
index 63e93b84dcd..72f66175c0b 100644
--- a/sql/share/german/errmsg.txt
+++ b/sql/share/german/errmsg.txt
@@ -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"
diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt
index 6f03bc26c0a..4c947568f8c 100644
--- a/sql/share/greek/errmsg.txt
+++ b/sql/share/greek/errmsg.txt
@@ -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"
diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt
index 20fab382d78..29f28886320 100644
--- a/sql/share/hungarian/errmsg.txt
+++ b/sql/share/hungarian/errmsg.txt
@@ -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"
diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt
index 8221fbd098e..3b64be1e140 100644
--- a/sql/share/italian/errmsg.txt
+++ b/sql/share/italian/errmsg.txt
@@ -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"
diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt
index 17746d51c46..8e81096cc73 100644
--- a/sql/share/japanese/errmsg.txt
+++ b/sql/share/japanese/errmsg.txt
@@ -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"
diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt
index 5a1d4456cac..45622f0d8c1 100644
--- a/sql/share/korean/errmsg.txt
+++ b/sql/share/korean/errmsg.txt
@@ -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"
diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt
index 8dc7d599756..2dccc62389e 100644
--- a/sql/share/norwegian-ny/errmsg.txt
+++ b/sql/share/norwegian-ny/errmsg.txt
@@ -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"
diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt
index 57118be3532..4af581f29bd 100644
--- a/sql/share/norwegian/errmsg.txt
+++ b/sql/share/norwegian/errmsg.txt
@@ -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"
diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt
index 29410a7fcbb..9bfbfd1a19f 100644
--- a/sql/share/polish/errmsg.txt
+++ b/sql/share/polish/errmsg.txt
@@ -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"
diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt
index 497928a7edf..7cfa3dfb258 100644
--- a/sql/share/portuguese/errmsg.txt
+++ b/sql/share/portuguese/errmsg.txt
@@ -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"
diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt
index f681bedc89e..840c4a78332 100644
--- a/sql/share/romanian/errmsg.txt
+++ b/sql/share/romanian/errmsg.txt
@@ -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"
diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt
index 2c6c81974fa..a96437b3e92 100644
--- a/sql/share/russian/errmsg.txt
+++ b/sql/share/russian/errmsg.txt
@@ -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"
diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt
index a4df5562a84..034a1aec7a9 100644
--- a/sql/share/serbian/errmsg.txt
+++ b/sql/share/serbian/errmsg.txt
@@ -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"
diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt
index 157b21615a3..46cd8fd3052 100644
--- a/sql/share/slovak/errmsg.txt
+++ b/sql/share/slovak/errmsg.txt
@@ -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"
diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt
index 3a863e8df1e..52e9ce77ec3 100644
--- a/sql/share/spanish/errmsg.txt
+++ b/sql/share/spanish/errmsg.txt
@@ -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"
diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt
index 8493bc628cd..76b9b631632 100644
--- a/sql/share/swedish/errmsg.txt
+++ b/sql/share/swedish/errmsg.txt
@@ -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"
diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt
index c35a4b292bb..5867dc07c3c 100644
--- a/sql/share/ukrainian/errmsg.txt
+++ b/sql/share/ukrainian/errmsg.txt
@@ -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"
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 758345f764a..a10fc5792dc 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -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);