From cce719fba8e143c6a94f5c4048e1b72d005b1dd2 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Jan 2006 13:29:46 +0100 Subject: Fixed BUG#16303: erroneus stored procedures and functions should be droppable Use a special lookup function for DROP, which doesn't attempt to parse the definition. mysql-test/r/sp-destruct.result: Updated test result for BUG#16303. mysql-test/t/sp-destruct.test: Added test case for BUG#16303. sql/sp.cc: New function sp_routine_exists_in_table() for DROP PROCEDURE/FUNCTION; which doesn't want to parse the definition, only know if it exists. Renamed sp_exists_routine to sp_exist_routines and added comment, and changed the misnamed parameter/variable 'tables'/'table' to 'routines'/'routine'. sql/sp.h: New function sp_routine_exists_in_table() for DROP PROCEDURE/FUNCTION. Renamed sp_exists_routine to sp_exist_routines, and changed the misnamed parameter 'tables' to 'routines'. sql/sql_acl.cc: Call to sp_exists_routine() renamed to sp_exist_routines(). sql/sql_parse.cc: Use the new sp_routine_exists_in_table() instead of sp_find_routine(), since we don't want the routine definition parsed when doing DROP PROCEDURE/FUNCTION. --- sql/sql_parse.cc | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 1cbc616f63f..2b76024105e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4445,21 +4445,17 @@ end_with_restore_list: case SQLCOM_DROP_PROCEDURE: case SQLCOM_DROP_FUNCTION: { - sp_head *sp; int result; - char *db, *name; + int type= (lex->sql_command == SQLCOM_DROP_PROCEDURE ? + TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION); - if (lex->sql_command == SQLCOM_DROP_PROCEDURE) - sp= sp_find_routine(thd, TYPE_ENUM_PROCEDURE, lex->spname, - &thd->sp_proc_cache, FALSE); - else - sp= sp_find_routine(thd, TYPE_ENUM_FUNCTION, lex->spname, - &thd->sp_func_cache, FALSE); + result= sp_routine_exists_in_table(thd, type, lex->spname); mysql_reset_errors(thd, 0); - if (sp) + if (result == SP_OK) { - db= thd->strdup(sp->m_db.str); - name= thd->strdup(sp->m_name.str); + char *db= lex->spname->m_db.str; + char *name= lex->spname->m_name.str; + if (check_routine_access(thd, ALTER_PROC_ACL, db, name, lex->sql_command == SQLCOM_DROP_PROCEDURE, 0)) goto error; -- cgit v1.2.1