diff options
author | Dmitry Lenev <Dmitry.Lenev@oracle.com> | 2017-02-23 12:41:13 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-02-27 12:35:10 +0100 |
commit | 494a94158a6f509afad1078615679c51b723b7a6 (patch) | |
tree | 8f758d150bb6e94600624744e366b89cb714a497 /sql/sp.cc | |
parent | 0a480f03c64c7f8ffaef40b49a62d194d4aa6a04 (diff) | |
download | mariadb-git-494a94158a6f509afad1078615679c51b723b7a6.tar.gz |
Fix for bug#11759114 - '51401: GRANT TREATS NONEXISTENT
FUNCTIONS/PRIVILEGES DIFFERENTLY'.
The problem was that attempt to grant EXECUTE or ALTER
ROUTINE privilege on stored procedure which didn't exist
succeed instead of returning an appropriate error like
it happens in similar situation for stored functions or
tables.
The code which handles granting of privileges on individual
routine calls sp_exist_routines() function to check if routine
exists and assumes that the 3rd parameter of the latter
specifies whether it should check for existence of stored
procedure or function. In practice, this parameter had
completely different meaning and, as result, this check was
not done properly for stored procedures.
This fix addresses this problem by bringing sp_exist_routines()
signature and code in line with expectation of its caller.
Diffstat (limited to 'sql/sp.cc')
-rw-r--r-- | sql/sp.cc | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/sql/sp.cc b/sql/sp.cc index 254c9c5a101..e9340608646 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1767,7 +1767,8 @@ sp_find_routine(THD *thd, stored_procedure_type type, sp_name *name, @param thd Thread handler @param routines List of needles in the hay stack - @param any Any of the needles are good enough + @param is_proc Indicates whether routines in the list are procedures + or functions. @return @retval FALSE Found. @@ -1775,7 +1776,7 @@ sp_find_routine(THD *thd, stored_procedure_type type, sp_name *name, */ bool -sp_exist_routines(THD *thd, TABLE_LIST *routines, bool any) +sp_exist_routines(THD *thd, TABLE_LIST *routines, bool is_proc) { TABLE_LIST *routine; bool sp_object_found; @@ -1791,17 +1792,14 @@ sp_exist_routines(THD *thd, TABLE_LIST *routines, bool any) lex_name.str= thd->strmake(routine->table_name, lex_name.length); name= new sp_name(lex_db, lex_name, true); name->init_qname(thd); - sp_object_found= sp_find_routine(thd, TYPE_ENUM_PROCEDURE, name, - &thd->sp_proc_cache, FALSE) != NULL || - sp_find_routine(thd, TYPE_ENUM_FUNCTION, name, - &thd->sp_func_cache, FALSE) != NULL; + sp_object_found= is_proc ? sp_find_routine(thd, TYPE_ENUM_PROCEDURE, + name, &thd->sp_proc_cache, + FALSE) != NULL : + sp_find_routine(thd, TYPE_ENUM_FUNCTION, + name, &thd->sp_func_cache, + FALSE) != NULL; thd->warning_info->clear_warning_info(thd->query_id); - if (sp_object_found) - { - if (any) - break; - } - else if (!any) + if (! sp_object_found) { my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION or PROCEDURE", routine->table_name); |