22 static ulong
volatile Cversion= 0;
44 return my_hash_insert(&m_hashtable, (
const uchar *)sp);
49 return (
sp_head *) my_hash_search(&m_hashtable, (
const uchar *)name,
55 my_hash_delete(&m_hashtable, (uchar *)sp);
67 if (m_hashtable.records > upper_limit_for_elements)
68 my_hash_reset(&m_hashtable);
79 #ifdef HAVE_PSI_INTERFACE
80 static PSI_mutex_key key_Cversion_lock;
82 static PSI_mutex_info all_sp_cache_mutexes[]=
84 { &key_Cversion_lock,
"Cversion_lock", PSI_FLAG_GLOBAL}
87 static void init_sp_cache_psi_keys(
void)
89 const char* category=
"sql";
92 count= array_elements(all_sp_cache_mutexes);
101 #ifdef HAVE_PSI_INTERFACE
102 init_sp_cache_psi_keys();
157 DBUG_PRINT(
"info",(
"sp_cache: inserting: %.*s", (
int) sp->
m_qname.length,
185 return c->lookup(name->m_qname.str, name->m_qname.length);
201 void sp_cache_invalidate()
203 DBUG_PRINT(
"info",(
"sp_cache: invalidating"));
204 thread_safe_increment(Cversion, &Cversion_lock);
221 if ((*sp)->sp_cache_version() < Cversion && !(*sp)->is_invoked())
233 ulong sp_cache_version()
248 sp_cache_enforce_limit(
sp_cache *c, ulong upper_limit_for_elements)
258 extern "C" uchar *hash_get_key_for_sp_head(
const uchar *ptr,
size_t *plen,
260 extern "C" void hash_free_sp_head(
void *p);
262 uchar *hash_get_key_for_sp_head(
const uchar *ptr,
size_t *plen,
267 return (uchar*) sp->
m_qname.str;
271 void hash_free_sp_head(
void *p)
284 sp_cache::~sp_cache()
286 my_hash_free(&m_hashtable);
293 my_hash_init(&m_hashtable, system_charset_info, 0, 0, 0,
294 hash_get_key_for_sp_head, hash_free_sp_head, 0);
301 my_hash_free(&m_hashtable);