1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

Bug#31767 DROP FUNCTION name resolution

Backport to 5.5.99
This commit is contained in:
Marc Alff
2010-02-23 11:43:26 -07:00
parent b6e0f92f05
commit 22e9e95a7c
14 changed files with 175 additions and 47 deletions

View File

@@ -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;