Skip to content

Commit 78e474b

Browse files
committed
cleanup: sp_cache_flush_obsolete
it was only truly used in one place, where it needed to compare its arguments before removing an entry from the cache. in the second place it was used, the comparison was redundant, it was only called to remove, not to compare. let's replace it with a function that just removes.
1 parent 9569208 commit 78e474b

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

sql/sp.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ Sp_handler::sp_drop_routine_internal(THD *thd,
11271127
sp_cache **spc= get_cache(thd);
11281128
DBUG_ASSERT(spc);
11291129
if ((sp= sp_cache_lookup(spc, name)))
1130-
sp_cache_flush_obsolete(spc, &sp, sp_cache_version());
1130+
sp_cache_remove(spc, &sp);
11311131
/* Drop statistics for this stored program from performance schema. */
11321132
MYSQL_DROP_SP(type(), name->m_db.str, static_cast<uint>(name->m_db.length),
11331133
name->m_name.str, static_cast<uint>(name->m_name.length));
@@ -2822,7 +2822,8 @@ int Sp_handler::sp_cache_routine(THD *thd,
28222822

28232823
if (*sp)
28242824
{
2825-
sp_cache_flush_obsolete(spc, sp, thd->sp_cache_version());
2825+
if ((*sp)->sp_cache_version() < thd->sp_cache_version())
2826+
sp_cache_remove(spc, sp);
28262827
if (*sp)
28272828
DBUG_RETURN(SP_OK);
28282829
}

sql/sp_cache.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,10 @@ void sp_cache_invalidate()
231231
inside SP'.
232232
*/
233233

234-
void sp_cache_flush_obsolete(sp_cache **cp, sp_head **sp, ulong version)
234+
void sp_cache_remove(sp_cache **cp, sp_head **sp)
235235
{
236-
if ((*sp)->sp_cache_version() < version)
237-
{
238-
(*cp)->remove(*sp);
239-
*sp= NULL;
240-
}
236+
(*cp)->remove(*sp);
237+
*sp= NULL;
241238
}
242239

243240
/**

sql/sp_cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void sp_cache_clear(sp_cache **cp);
5959
void sp_cache_insert(sp_cache **cp, sp_head *sp);
6060
sp_head *sp_cache_lookup(sp_cache **cp, const Database_qualified_name *name);
6161
void sp_cache_invalidate();
62-
void sp_cache_flush_obsolete(sp_cache **cp, sp_head **sp, ulong version);
62+
void sp_cache_remove(sp_cache **cp, sp_head **sp);
6363
ulong sp_cache_version();
6464
void sp_cache_enforce_limit(sp_cache *cp, ulong upper_limit_for_elements);
6565

0 commit comments

Comments
 (0)