Bug #21269 DEFINER-clause is allowed for UDF-functions
Submitted: 25 Jul 2006 10:07 Modified: 30 Aug 2006 19:24
Reporter: Alexander Nozdrin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: User-defined functions ( UDF ) Severity:S3 (Non-critical)
Version:5.0.24/5.0BK/5.1BK OS:Linux (Linux)
Assigned to: Marc ALFF CPU Architecture:Any

[25 Jul 2006 10:07] Alexander Nozdrin
Description:
Definers are not supported for UDF, however the parser allows DEFINER-clause
to be specified in CREATE UDF statement.

How to repeat:
mysql> CREATE DEFINER=CURRENT_USER() FUNCTION metaphon RETURNS STRING SONAME 'udf_example.so';
Query OK, 0 rows affected (0.00 sec)

Suggested fix:
Forbid DEFINER-clause for UDF, like AGGREGATE-clause was forbidden
for stored functions.
[26 Jul 2006 13:35] MySQL Verification Team
Thank you for the bug report.

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.25-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE DEFINER=CURRENT_USER() FUNCTION metaphon RETURNS STRING SONAME
    -> 'udf_example.so';
Query OK, 0 rows affected (0.02 sec)
[29 Jul 2006 3:47] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/9751

ChangeSet@1.2243, 2006-07-28 21:46:58-07:00, malff@weblab.(none) +3 -0
  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.
[31 Jul 2006 18:26] Marc ALFF
Modified the test cases as per code review comments.
[31 Jul 2006 21:46] Konstantin Osipov
Approved by email.
[2 Aug 2006 15:58] Konstantin Osipov
Pushed into 5.0.25
[14 Aug 2006 20:50] Konstantin Osipov
Merged into 5.1.12
[30 Aug 2006 19:24] Paul DuBois
Noted in 5.0.25, 5.1.12 changelogs.

For user-defined functions created with CREATE FUNCTION,
the DEFINER clause is not legal, but no error was generated.