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.
This commit is contained in:
Sergei Golubchik 2025-10-25 20:16:04 +02:00
parent 956920816e
commit 78e474b1a7
3 changed files with 7 additions and 9 deletions

View File

@ -1127,7 +1127,7 @@ Sp_handler::sp_drop_routine_internal(THD *thd,
sp_cache **spc= get_cache(thd);
DBUG_ASSERT(spc);
if ((sp= sp_cache_lookup(spc, name)))
sp_cache_flush_obsolete(spc, &sp, sp_cache_version());
sp_cache_remove(spc, &sp);
/* Drop statistics for this stored program from performance schema. */
MYSQL_DROP_SP(type(), name->m_db.str, static_cast<uint>(name->m_db.length),
name->m_name.str, static_cast<uint>(name->m_name.length));
@ -2822,7 +2822,8 @@ int Sp_handler::sp_cache_routine(THD *thd,
if (*sp)
{
sp_cache_flush_obsolete(spc, sp, thd->sp_cache_version());
if ((*sp)->sp_cache_version() < thd->sp_cache_version())
sp_cache_remove(spc, sp);
if (*sp)
DBUG_RETURN(SP_OK);
}

View File

@ -231,13 +231,10 @@ void sp_cache_invalidate()
inside SP'.
*/
void sp_cache_flush_obsolete(sp_cache **cp, sp_head **sp, ulong version)
void sp_cache_remove(sp_cache **cp, sp_head **sp)
{
if ((*sp)->sp_cache_version() < version)
{
(*cp)->remove(*sp);
*sp= NULL;
}
(*cp)->remove(*sp);
*sp= NULL;
}
/**

View File

@ -59,7 +59,7 @@ 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 Database_qualified_name *name);
void sp_cache_invalidate();
void sp_cache_flush_obsolete(sp_cache **cp, sp_head **sp, ulong version);
void sp_cache_remove(sp_cache **cp, sp_head **sp);
ulong sp_cache_version();
void sp_cache_enforce_limit(sp_cache *cp, ulong upper_limit_for_elements);