Commit d251e9be authored by unknown's avatar unknown

Bug#21269 (DEFINER-clause is allowed for UDF-functions)

The problem was that the grammar allows to create a function with an optional
definer clause, and define it as a UDF with the SONAME keyword.
Such combination should be reported as an error.

The solution is to not change the grammar itself, and to introduce a
specific check in the yacc actions in 'create_function_tail' for UDF,
that now reports ER_WRONG_USAGE when using both DEFINER and SONAME.


mysql-test/r/udf.result:
  Added tests for Bug#21269 (DEFINER-clause is allowed for UDF-functions)
mysql-test/t/udf.test:
  Added tests for Bug#21269 (DEFINER-clause is allowed for UDF-functions)
sql/sql_yacc.yy:
  Creating a UDF function with a DEFINER clause is now a syntax error.
parent 3c108584
......@@ -93,6 +93,12 @@ NULL
0R
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
CREATE DEFINER=someone@somewhere FUNCTION should_not_parse
RETURNS STRING SONAME "should_not_parse.so";
ERROR HY000: Incorrect usage of SONAME and DEFINER
End of 5.0 tests.
DROP FUNCTION metaphon;
DROP FUNCTION myfunc_double;
......
......@@ -109,6 +109,18 @@ SELECT myfunc_double(n) AS f FROM bug19904;
SELECT metaphon(v) AS f FROM bug19904;
DROP TABLE bug19904;
#
# Bug#21269: DEFINER-clause is allowed for UDF-functions
#
--error ER_WRONG_USAGE
CREATE DEFINER=CURRENT_USER() FUNCTION should_not_parse
RETURNS STRING SONAME "should_not_parse.so";
--error ER_WRONG_USAGE
CREATE DEFINER=someone@somewhere FUNCTION should_not_parse
RETURNS STRING SONAME "should_not_parse.so";
--echo End of 5.0 tests.
#
......
......@@ -1256,6 +1256,17 @@ create_function_tail:
RETURNS_SYM udf_type UDF_SONAME_SYM TEXT_STRING_sys
{
LEX *lex=Lex;
if (lex->definer != NULL)
{
/*
DEFINER is a concept meaningful when interpreting SQL code.
UDF functions are compiled.
Using DEFINER with UDF has therefore no semantic,
and is considered a parsing error.
*/
my_error(ER_WRONG_USAGE, MYF(0), "SONAME", "DEFINER");
YYABORT;
}
lex->sql_command = SQLCOM_CREATE_FUNCTION;
lex->udf.name = lex->spname->m_name;
lex->udf.returns=(Item_result) $2;
......
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