From 70ea50366231ac471a894ab4e91f2322cdacb796 Mon Sep 17 00:00:00 2001 From: "pem@mysql.comhem.se" <> Date: Tue, 21 Oct 2003 18:13:14 +0200 Subject: [PATCH] Bugfix of previous WL#1265 commit. Need a sp_cache_remove() function with implicit name lookup to make the WL task to work. It's a cleaner and more convenient interface anyway... --- sql/sp.cc | 10 ++-------- sql/sp_cache.cc | 8 +++++--- sql/sp_cache.h | 12 ++++++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/sql/sp.cc b/sql/sp.cc index b1cdad4f619..7076778532f 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -286,12 +286,9 @@ sp_drop_procedure(THD *thd, char *name, uint namelen) sp_head *sp; int ret; - sp= sp_cache_lookup(&thd->sp_proc_cache, name, namelen); + sp= sp_cache_remove(&thd->sp_proc_cache, name, namelen); if (sp) - { - sp_cache_remove(&thd->sp_proc_cache, sp); delete sp; - } ret= db_drop_routine(thd, TYPE_ENUM_PROCEDURE, name, namelen); DBUG_RETURN(ret); @@ -344,12 +341,9 @@ sp_drop_function(THD *thd, char *name, uint namelen) sp_head *sp; int ret; - sp= sp_cache_lookup(&thd->sp_func_cache, name, namelen); + sp= sp_cache_remove(&thd->sp_func_cache, name, namelen); if (sp) - { - sp_cache_remove(&thd->sp_func_cache, sp); delete sp; - } ret= db_drop_routine(thd, TYPE_ENUM_FUNCTION, name, namelen); DBUG_RETURN(ret); diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc index 84e3565d543..7e9d5f92ef0 100644 --- a/sql/sp_cache.cc +++ b/sql/sp_cache.cc @@ -92,10 +92,11 @@ sp_cache_lookup(sp_cache **cp, char *name, uint namelen) return c->lookup(name, namelen); } -void -sp_cache_remove(sp_cache **cp, sp_head *sp) +sp_head * +sp_cache_remove(sp_cache **cp, char *name, uint namelen) { sp_cache *c= *cp; + sp_head *sp= NULL; if (c) { @@ -108,9 +109,10 @@ sp_cache_remove(sp_cache **cp, sp_head *sp) if (c->version < v) c->remove_all(); else - c->remove(sp); + sp= c->remove(name, namelen); c->version= v+1; } + return sp; } diff --git a/sql/sp_cache.h b/sql/sp_cache.h index f5b330f6755..3d38d6f1d1f 100644 --- a/sql/sp_cache.h +++ b/sql/sp_cache.h @@ -38,7 +38,7 @@ void sp_cache_insert(sp_cache **cp, sp_head *sp); sp_head *sp_cache_lookup(sp_cache **cp, char *name, uint namelen); /* Remove an SP from cache */ -void sp_cache_remove(sp_cache **cp, sp_head *sp); +sp_head *sp_cache_remove(sp_cache **cp, char *name, uint namelen); /* @@ -75,10 +75,14 @@ public: return (sp_head *)hash_search(&m_hashtable, (const byte *)name, namelen); } - inline void - remove(sp_head *sp) + inline sp_head * + remove(char *name, uint namelen) { - hash_delete(&m_hashtable, (byte *)sp); + sp_head *sp= lookup(name, namelen); + + if (sp) + hash_delete(&m_hashtable, (byte *)sp); + return sp; } inline void