summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarc Alff <marc.alff@sun.com>2010-02-23 11:43:26 -0700
committerMarc Alff <marc.alff@sun.com>2010-02-23 11:43:26 -0700
commit22e9e95a7c0922da63cb0d5a600f204f427caf1f (patch)
tree5ee3669bcedd4780871ead9ac02ce6be6f3a7d0c /sql
parentb6e0f92f052a37568b984330b8cca8331c979a8d (diff)
downloadmariadb-git-22e9e95a7c0922da63cb0d5a600f204f427caf1f.tar.gz
Bug#31767 DROP FUNCTION name resolution
Backport to 5.5.99
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_parse.cc71
1 files changed, 42 insertions, 29 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index c7e1be2237b..714e3af5296 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -4132,6 +4132,47 @@ create_sp_error:
case SQLCOM_DROP_PROCEDURE:
case SQLCOM_DROP_FUNCTION:
{
+#ifdef HAVE_DLOPEN
+ if (lex->sql_command == SQLCOM_DROP_FUNCTION &&
+ ! lex->spname->m_explicit_name)
+ {
+ /* DROP FUNCTION <non qualified name> */
+ udf_func *udf = find_udf(lex->spname->m_name.str,
+ lex->spname->m_name.length);
+ if (udf)
+ {
+ if (check_access(thd, DELETE_ACL, "mysql", NULL, NULL, 1, 0))
+ goto error;
+
+ if (!(res = mysql_drop_function(thd, &lex->spname->m_name)))
+ {
+ my_ok(thd);
+ break;
+ }
+ my_error(ER_SP_DROP_FAILED, MYF(0),
+ "FUNCTION (UDF)", lex->spname->m_name.str);
+ goto error;
+ }
+
+ if (lex->spname->m_db.str == NULL)
+ {
+ if (lex->drop_if_exists)
+ {
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST),
+ "FUNCTION (UDF)", lex->spname->m_name.str);
+ res= FALSE;
+ my_ok(thd);
+ break;
+ }
+ my_error(ER_SP_DOES_NOT_EXIST, MYF(0),
+ "FUNCTION (UDF)", lex->spname->m_name.str);
+ goto error;
+ }
+ /* Fall thought to test for a stored function */
+ }
+#endif
+
int sp_result;
int type= (lex->sql_command == SQLCOM_DROP_PROCEDURE ?
TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION);
@@ -4178,34 +4219,6 @@ create_sp_error:
}
#endif
}
- else
- {
-#ifdef HAVE_DLOPEN
- if (lex->sql_command == SQLCOM_DROP_FUNCTION)
- {
- udf_func *udf = find_udf(lex->spname->m_name.str,
- lex->spname->m_name.length);
- if (udf)
- {
- if (check_access(thd, DELETE_ACL, "mysql", NULL, NULL, 1, 0))
- goto error;
-
- if (!(res = mysql_drop_function(thd, &lex->spname->m_name)))
- {
- my_ok(thd);
- break;
- }
- }
- }
-#endif
- if (lex->spname->m_db.str)
- sp_result= SP_KEY_NOT_FOUND;
- else
- {
- my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
- goto error;
- }
- }
res= sp_result;
switch (sp_result) {
case SP_OK:
@@ -4217,7 +4230,7 @@ create_sp_error:
res= write_bin_log(thd, TRUE, thd->query(), thd->query_length());
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST),
- SP_COM_STRING(lex), lex->spname->m_name.str);
+ SP_COM_STRING(lex), lex->spname->m_qname.str);
if (!res)
my_ok(thd);
break;