diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-09-30 10:38:44 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-09-30 10:38:44 +0300 |
commit | a49e394399859b23ba609d0058b498cfa876cac4 (patch) | |
tree | d0f1a85011d7e99078624c2185a9ba69796a4262 /sql/sp.cc | |
parent | 260649de0472e90be665ae2c442c4435e125b022 (diff) | |
parent | be803f037f98812410f24b67af61aa7857969dcf (diff) | |
download | mariadb-git-a49e394399859b23ba609d0058b498cfa876cac4.tar.gz |
Merge 10.5 into 10.6
Diffstat (limited to 'sql/sp.cc')
-rw-r--r-- | sql/sp.cc | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/sql/sp.cc b/sql/sp.cc index 73c9c960cf7..4ef23983f78 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1930,8 +1930,6 @@ bool Sp_handler::sp_show_create_routine(THD *thd, const Database_qualified_name *name) const { - sp_head *sp; - DBUG_ENTER("sp_show_create_routine"); DBUG_PRINT("enter", ("type: %s name: %.*s", type_str(), @@ -1944,20 +1942,28 @@ Sp_handler::sp_show_create_routine(THD *thd, It is "safe" to do as long as it doesn't affect the results of the binary log or the query cache, which currently it does not. */ - if (sp_cache_routine(thd, name, false, &sp)) - DBUG_RETURN(TRUE); + sp_head *sp= 0; - if (sp == NULL || sp->show_create_routine(thd, this)) + DBUG_EXECUTE_IF("cache_sp_in_show_create", + /* Some tests need just need a way to cache SP without other side-effects.*/ + sp_cache_routine(thd, name, false, &sp); + sp->show_create_routine(thd, this); + DBUG_RETURN(false); + ); + + bool free_sp= db_find_routine(thd, name, &sp) == SP_OK; + bool ret= !sp || sp->show_create_routine(thd, this); + if (ret) { /* If we have insufficient privileges, pretend the routine does not exist. */ my_error(ER_SP_DOES_NOT_EXIST, MYF(0), type_str(), name->m_name.str); - DBUG_RETURN(TRUE); } - - DBUG_RETURN(FALSE); + if (free_sp) + sp_head::destroy(sp); + DBUG_RETURN(ret); } |