summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/sp.cc10
-rw-r--r--sql/sp_cache.cc8
-rw-r--r--sql/sp_cache.h12
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