| Bug #4945 | Server UDF: new UDF cannot be created | ||
|---|---|---|---|
| Submitted: | 8 Aug 2004 22:42 | Modified: | 19 Aug 2004 19:53 |
| Reporter: | Christopher Miller | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server | Severity: | S2 (Serious) |
| Version: | 5.0.0 | OS: | Windows (XP) |
| Assigned to: | CPU Architecture: | Any | |
[19 Aug 2004 19:53]
Hartmut Holzgraefe
Thank you for your bug report. This issue has already been fixed in the latest released version of that product, which you can download at http://www.mysql.com/downloads/

Description: In sql/sql_parse.cpp, line 3092, the SQLCOM_CREATE_FUNCTION case checks to see if the UDF already exists and then returns ER_UDF_EXISTS if the UDF does NOT exist. This logic is incorrect and prevents the creation of a non-existant UDF (which is why the function is being created in the first place.) Whoever wrote the code failed to test the trivial case of adding a UDF which does not exist. How to repeat: This bug can be exercised by executing the SQL "create aggregate function 'foo' returns real soname 'foo.dll';". The client message is "ERROR 1125 (HY000): Function 'foo' already exist", which is incorrect. Furthermore the UDF cannot be created. Suggested fix: Change sql/sql_parse:3092 to fail only if sph is non-zero (meaning the function already exists): if (sph= sp_find_function(thd, &lex->udf.name)) Please note this fix might cause a resource leak when the function already exists because sph is a resource that is not released by the calling code after allocation.