-
unknown authored
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()
f1d7a96b