summaryrefslogtreecommitdiff
path: root/sql/sp_cache.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sp_cache.cc')
-rw-r--r--sql/sp_cache.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc
index 8972303ef03..d6445799a36 100644
--- a/sql/sp_cache.cc
+++ b/sql/sp_cache.cc
@@ -57,6 +57,20 @@ public:
{
my_hash_delete(&m_hashtable, (uchar *)sp);
}
+
+ /**
+ Remove all elements from a stored routine cache if the current
+ number of elements exceeds the argument value.
+
+ @param[in] upper_limit_for_elements Soft upper limit of elements that
+ can be stored in the cache.
+ */
+ void enforce_limit(ulong upper_limit_for_elements)
+ {
+ if (m_hashtable.records > upper_limit_for_elements)
+ my_hash_reset(&m_hashtable);
+ }
+
private:
void init();
void cleanup();
@@ -228,6 +242,21 @@ ulong sp_cache_version()
}
+/**
+ Enforce that the current number of elements in the cache don't exceed
+ the argument value by flushing the cache if necessary.
+
+ @param[in] c Cache to check
+ @param[in] upper_limit_for_elements Soft upper limit for number of sp_head
+ objects that can be stored in the cache.
+*/
+void
+sp_cache_enforce_limit(sp_cache *c, ulong upper_limit_for_elements)
+{
+ if (c)
+ c->enforce_limit(upper_limit_for_elements);
+}
+
/*************************************************************************
Internal functions
*************************************************************************/