Skip to content

Commit

Permalink
MDEV-13302 Avoid using LEX::spname during CREATE PROCEDURE and CREATE…
Browse files Browse the repository at this point in the history
… FUNCTION
  • Loading branch information
Alexander Barkov committed Jul 12, 2017
1 parent 7c3df72 commit 0f348bc
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 14 deletions.
11 changes: 6 additions & 5 deletions sql/sp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@ static TABLE *open_proc_table_for_update(THD *thd)
*/

static int
db_find_routine_aux(THD *thd, stored_procedure_type type, const sp_name *name,
db_find_routine_aux(THD *thd, stored_procedure_type type,
const Database_qualified_name *name,
TABLE *table)
{
uchar key[MAX_KEY_LENGTH]; // db, name, optional key length type
Expand Down Expand Up @@ -969,7 +970,7 @@ sp_returns_type(THD *thd, String &result, sp_head *sp)
*/
static int
sp_drop_routine_internal(THD *thd, stored_procedure_type type,
const sp_name *name, TABLE *table)
const Database_qualified_name *name, TABLE *table)
{
DBUG_ENTER("sp_drop_routine_internal");

Expand Down Expand Up @@ -1079,11 +1080,11 @@ sp_create_routine(THD *thd, stored_procedure_type type, sp_head *sp)
else
{
/* Checking if the routine already exists */
if (db_find_routine_aux(thd, type, lex->spname, table) == SP_OK)
if (db_find_routine_aux(thd, type, sp, table) == SP_OK)
{
if (lex->create_info.or_replace())
{
if ((ret= sp_drop_routine_internal(thd, type, lex->spname, table)))
if ((ret= sp_drop_routine_internal(thd, type, sp, table)))
goto done;
}
else if (lex->create_info.if_not_exists())
Expand All @@ -1092,7 +1093,7 @@ sp_create_routine(THD *thd, stored_procedure_type type, sp_head *sp)
ER_SP_ALREADY_EXISTS,
ER_THD(thd, ER_SP_ALREADY_EXISTS),
SP_TYPE_STRING(type),
lex->spname->m_name.str);
sp->m_name.str);

ret= FALSE;

Expand Down
2 changes: 1 addition & 1 deletion sql/sp_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void sp_cache_insert(sp_cache **cp, sp_head *sp)
NULL if the routine not found.
*/

sp_head *sp_cache_lookup(sp_cache **cp, const sp_name *name)
sp_head *sp_cache_lookup(sp_cache **cp, const Database_qualified_name *name)
{
char buf[NAME_LEN * 2 + 2];
sp_cache *c= *cp;
Expand Down
4 changes: 2 additions & 2 deletions sql/sp_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

class sp_head;
class sp_cache;
class sp_name;
class Database_qualified_name;

/*
Cache usage scenarios:
Expand All @@ -59,7 +59,7 @@ void sp_cache_init();
void sp_cache_end();
void sp_cache_clear(sp_cache **cp);
void sp_cache_insert(sp_cache **cp, sp_head *sp);
sp_head *sp_cache_lookup(sp_cache **cp, const sp_name *name);
sp_head *sp_cache_lookup(sp_cache **cp, const Database_qualified_name *name);
void sp_cache_invalidate();
void sp_cache_flush_obsolete(sp_cache **cp, sp_head **sp);
ulong sp_cache_version();
Expand Down
4 changes: 2 additions & 2 deletions sql/sql_parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2935,8 +2935,8 @@ static int mysql_create_routine(THD *thd, LEX *lex)
/* Checking the drop permissions if CREATE OR REPLACE is used */
if (lex->create_info.or_replace())
{
if (check_routine_access(thd, ALTER_PROC_ACL, lex->spname->m_db.str,
lex->spname->m_name.str,
if (check_routine_access(thd, ALTER_PROC_ACL, lex->sphead->m_db.str,
lex->sphead->m_name.str,
lex->sql_command == SQLCOM_DROP_PROCEDURE, 0))
return true;
}
Expand Down
2 changes: 0 additions & 2 deletions sql/sql_yacc.yy
Original file line number Diff line number Diff line change
Expand Up @@ -16664,7 +16664,6 @@ sf_tail:
if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
TYPE_ENUM_FUNCTION))
MYSQL_YYABORT;
Lex->spname= $2;
}
sp_parenthesized_fdparam_list
sf_return_type
Expand Down Expand Up @@ -16700,7 +16699,6 @@ sp_tail:
if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
TYPE_ENUM_PROCEDURE))
MYSQL_YYABORT;
Lex->spname= $2;
}
sp_parenthesized_pdparam_list
sp_c_chistics
Expand Down
2 changes: 0 additions & 2 deletions sql/sql_yacc_ora.yy
Original file line number Diff line number Diff line change
Expand Up @@ -16903,7 +16903,6 @@ sf_tail:
if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
TYPE_ENUM_FUNCTION))
MYSQL_YYABORT;
Lex->spname= $2;
}
opt_sp_parenthesized_fdparam_list
sf_return_type
Expand Down Expand Up @@ -16942,7 +16941,6 @@ sp_tail:
if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
TYPE_ENUM_PROCEDURE))
MYSQL_YYABORT;
Lex->spname= $2;
}
opt_sp_parenthesized_pdparam_list
sp_c_chistics
Expand Down

0 comments on commit 0f348bc

Please sign in to comment.