From 78e474b1a72082cf2a5199c13c0ba9e1db97afd3 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 25 Oct 2025 20:16:04 +0200 Subject: [PATCH] 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. --- sql/sp.cc | 5 +++-- sql/sp_cache.cc | 9 +++------ sql/sp_cache.h | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/sql/sp.cc b/sql/sp.cc index a4f429c61b5..d393f06d675 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -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(name->m_db.length), name->m_name.str, static_cast(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); } diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc index 9f4ab7b97d2..dd93d6fc101 100644 --- a/sql/sp_cache.cc +++ b/sql/sp_cache.cc @@ -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; } /** diff --git a/sql/sp_cache.h b/sql/sp_cache.h index e4cf131025c..ea157a41ead 100644 --- a/sql/sp_cache.h +++ b/sql/sp_cache.h @@ -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);