diff options
author | Konstantin Osipov <kostja@sun.com> | 2010-02-02 02:22:16 +0300 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2010-02-02 02:22:16 +0300 |
commit | 665100b69dfebe45e2d3b68116c6718560bf63b2 (patch) | |
tree | a19075577cf795c631e5ac514d6dac52880f9b86 /sql/sp_cache.cc | |
parent | 5eed6cc55db0f99aff7845397a824fb2f5ef069e (diff) | |
parent | 4e8d1c6bf30abfd45a993b058ff2a33d4671b73d (diff) | |
download | mariadb-git-665100b69dfebe45e2d3b68116c6718560bf63b2.tar.gz |
Merge next-mr -> next-4284.
Diffstat (limited to 'sql/sp_cache.cc')
-rw-r--r-- | sql/sp_cache.cc | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc index bb962ad0300..a585004b1e8 100644 --- a/sql/sp_cache.cc +++ b/sql/sp_cache.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 MySQL AB +/* Copyright (C) 2002 MySQL AB, 2008-2009 Sun Microsystems, Inc This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ #include "sp_cache.h" #include "sp_head.h" -static pthread_mutex_t Cversion_lock; +static mysql_mutex_t Cversion_lock; static ulong volatile Cversion= 0; @@ -34,10 +34,16 @@ public: sp_cache(); ~sp_cache(); - inline void insert(sp_head *sp) + /** + Inserts a sp_head object into a hash table. + + @returns Success status + @return TRUE Failure + @return FALSE Success + */ + inline bool insert(sp_head *sp) { - /* TODO: why don't we check return value? */ - my_hash_insert(&m_hashtable, (const uchar *)sp); + return my_hash_insert(&m_hashtable, (const uchar *)sp); } inline sp_head *lookup(char *name, uint namelen) @@ -58,12 +64,36 @@ private: HASH m_hashtable; }; // class sp_cache +#ifdef HAVE_PSI_INTERFACE +static PSI_mutex_key key_Cversion_lock; + +static PSI_mutex_info all_sp_cache_mutexes[]= +{ + { &key_Cversion_lock, "Cversion_lock", PSI_FLAG_GLOBAL} +}; + +static void init_sp_cache_psi_keys(void) +{ + const char* category= "sql"; + int count; + + if (PSI_server == NULL) + return; + + count= array_elements(all_sp_cache_mutexes); + PSI_server->register_mutex(category, all_sp_cache_mutexes, count); +} +#endif /* Initialize the SP caching once at startup */ void sp_cache_init() { - pthread_mutex_init(&Cversion_lock, MY_MUTEX_INIT_FAST); +#ifdef HAVE_PSI_INTERFACE + init_sp_cache_psi_keys(); +#endif + + mysql_mutex_init(key_Cversion_lock, &Cversion_lock, MY_MUTEX_INIT_FAST); } |