summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <malff@lambda.hsd1.co.comcast.net.>2007-10-15 19:15:38 -0600
committerunknown <malff@lambda.hsd1.co.comcast.net.>2007-10-15 19:15:38 -0600
commitf1d7a96b0a9432793a93571c682aea5fd7e17966 (patch)
treed1de33da80416d5164aaff37fe2c462572ff761d /mysql-test
parent3cf3e2863e446330eee70544e3ca6fe2aa9d8bcd (diff)
downloadmariadb-git-f1d7a96b0a9432793a93571c682aea5fd7e17966.tar.gz
Bug#28318 (CREATE FUNCTION (UDF) requires a schema) -- part II
The root cause of the issue was that the CREATE FUNCTION grammar, for User Defined Functions, was using the sp_name rule. The sp_name rule is intended for fully qualified stored procedure names, like either ident.ident, or just ident but with a default database implicitly selected. A UDF does not have a fully qualified name, only a name (ident), and should not use the sp_name grammar fragment during parsing. The fix is to re-organize the CREATE FUNCTION grammar, to better separate: - creating UDF (no definer, can have AGGREGATE, simple ident) - creating Stored Functions (definer, no AGGREGATE, fully qualified name) With the test case provided, another issue was exposed which is also fixed: the DROP FUNCTION statement was using sp_name and also failing when no database is implicitly selected, when droping UDF functions. The fix is also to change the grammar so that DROP FUNCTION works with both the ident.ident syntax (to drop a stored function), or just the ident syntax (to drop either a UDF or a Stored Function, in the current database) mysql-test/r/sp-error.result: Adjust test results mysql-test/r/udf.result: Adjust test results mysql-test/t/sp-error.test: Adjust test results mysql-test/t/udf.test: Adjust test results sql/sql_parse.cc: CREATE UDF FUNCTION does not use a fully qualified name. sql/sql_yacc.yy: Fix grammar for CREATE / DROP FUNCTION, FOR udf Improve error messages for select no_such_function()
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/sp-error.result4
-rw-r--r--mysql-test/r/udf.result4
-rw-r--r--mysql-test/t/sp-error.test7
-rw-r--r--mysql-test/t/udf.test4
4 files changed, 11 insertions, 8 deletions
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index cc217ecd093..b4bcfbdc7f7 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -1211,7 +1211,7 @@ ERROR 42S02: Unknown table 'c' in field list
drop procedure bug15091;
drop function if exists bug16896;
create aggregate function bug16896() returns int return 1;
-ERROR 42000: AGGREGATE is not supported for stored functions
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '() returns int return 1' at line 1
DROP PROCEDURE IF EXISTS bug14702;
CREATE IF NOT EXISTS PROCEDURE bug14702()
BEGIN
@@ -1457,7 +1457,7 @@ CREATE DATABASE mysqltest;
USE mysqltest;
DROP DATABASE mysqltest;
SELECT inexistent(), 1 + ,;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
+ERROR 42000: FUNCTION inexistent does not exist
SELECT inexistent();
ERROR 42000: FUNCTION inexistent does not exist
SELECT .inexistent();
diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result
index 3e29c780ca8..4a12e8e6d81 100644
--- a/mysql-test/r/udf.result
+++ b/mysql-test/r/udf.result
@@ -95,10 +95,10 @@ FR
DROP TABLE bug19904;
CREATE DEFINER=CURRENT_USER() FUNCTION should_not_parse
RETURNS STRING SONAME "should_not_parse.so";
-ERROR HY000: Incorrect usage of SONAME and DEFINER
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RETURNS STRING SONAME "should_not_parse.so"' at line 2
CREATE DEFINER=someone@somewhere FUNCTION should_not_parse
RETURNS STRING SONAME "should_not_parse.so";
-ERROR HY000: Incorrect usage of SONAME and DEFINER
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RETURNS STRING SONAME "should_not_parse.so"' at line 2
create table t1(f1 int);
insert into t1 values(1),(2);
explain select myfunc_int(f1) from t1 order by 1;
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index a1abf4852b0..8133a2271a1 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -1744,7 +1744,7 @@ drop procedure bug15091;
drop function if exists bug16896;
--enable_warnings
---error ER_SP_NO_AGGREGATE
+--error ER_PARSE_ERROR
create aggregate function bug16896() returns int return 1;
@@ -2099,7 +2099,10 @@ DROP DATABASE IF EXISTS mysqltest;
CREATE DATABASE mysqltest;
USE mysqltest;
DROP DATABASE mysqltest;
---error ER_PARSE_ERROR
+# Both ER_SP_DOES_NOT_EXIST and ER_PARSE_ERROR are valid here,
+# the result is implementation dependent:
+# See Bug#29816 for details
+--error ER_SP_DOES_NOT_EXIST
SELECT inexistent(), 1 + ,;
--error ER_SP_DOES_NOT_EXIST
SELECT inexistent();
diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test
index 6a516a29534..14aef3361e4 100644
--- a/mysql-test/t/udf.test
+++ b/mysql-test/t/udf.test
@@ -113,11 +113,11 @@ DROP TABLE bug19904;
# Bug#21269: DEFINER-clause is allowed for UDF-functions
#
---error ER_WRONG_USAGE
+--error ER_PARSE_ERROR
CREATE DEFINER=CURRENT_USER() FUNCTION should_not_parse
RETURNS STRING SONAME "should_not_parse.so";
---error ER_WRONG_USAGE
+--error ER_PARSE_ERROR
CREATE DEFINER=someone@somewhere FUNCTION should_not_parse
RETURNS STRING SONAME "should_not_parse.so";
#