diff options
author | Nirbhay Choubey <nirbhay@skysql.com> | 2014-03-26 14:27:24 -0400 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@skysql.com> | 2014-03-26 14:27:24 -0400 |
commit | 90e4f7f9d3f2669ac99f2817f884315bfc86b0a7 (patch) | |
tree | 60a10a515a9f5656e797d8142f97b94f89f4e797 /sql/mdl.cc | |
parent | 586fab72f01e1c7f0f8bf363fa6b06a2f10965b4 (diff) | |
parent | 5b7cab82195268f7657504d0b53995654748cefa (diff) | |
download | mariadb-git-90e4f7f9d3f2669ac99f2817f884315bfc86b0a7.tar.gz |
* bzr merge -rtag:mariadb-10.0.9 maria/10.0
* Fix for post-merge build failures.
Diffstat (limited to 'sql/mdl.cc')
-rw-r--r-- | sql/mdl.cc | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/sql/mdl.cc b/sql/mdl.cc index 2f00388a14b..7ef105b9269 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -136,15 +136,9 @@ class MDL_map_partition public: MDL_map_partition(); ~MDL_map_partition(); - inline MDL_lock *find_or_insert(const MDL_key *mdl_key, - my_hash_value_type hash_value); - unsigned long get_lock_owner(const MDL_key *key, - my_hash_value_type hash_value); + inline MDL_lock *find_or_insert(const MDL_key *mdl_key); + unsigned long get_lock_owner(const MDL_key *key); inline void remove(MDL_lock *lock); - my_hash_value_type get_key_hash(const MDL_key *mdl_key) const - { - return my_calc_hash(&m_locks, mdl_key->ptr(), mdl_key->length()); - } private: bool move_from_hash_to_lock_mutex(MDL_lock *lock); /** A partition of all acquired locks in the server. */ @@ -778,13 +772,21 @@ void MDL_map::init() } +my_hash_value_type mdl_hash_function(const CHARSET_INFO *cs, + const uchar *key, size_t length) +{ + MDL_key *mdl_key= (MDL_key*) (key - offsetof(MDL_key, m_ptr)); + return mdl_key->hash_value(); +} + + /** Initialize the partition in the container with all MDL locks. */ MDL_map_partition::MDL_map_partition() { mysql_mutex_init(key_MDL_map_mutex, &m_mutex, NULL); - my_hash_init(&m_locks, &my_charset_bin, 16 /* FIXME */, 0, 0, - mdl_locks_key, 0, 0); + my_hash_init2(&m_locks, 0, &my_charset_bin, 16 /* FIXME */, 0, 0, + mdl_locks_key, mdl_hash_function, 0, 0); }; @@ -858,11 +860,10 @@ MDL_lock* MDL_map::find_or_insert(const MDL_key *mdl_key) return lock; } - my_hash_value_type hash_value= m_partitions.at(0)->get_key_hash(mdl_key); - uint part_id= hash_value % mdl_locks_hash_partitions; + uint part_id= mdl_key->hash_value() % mdl_locks_hash_partitions; MDL_map_partition *part= m_partitions.at(part_id); - return part->find_or_insert(mdl_key, hash_value); + return part->find_or_insert(mdl_key); } @@ -875,15 +876,14 @@ MDL_lock* MDL_map::find_or_insert(const MDL_key *mdl_key) @retval NULL - Failure (OOM). */ -MDL_lock* MDL_map_partition::find_or_insert(const MDL_key *mdl_key, - my_hash_value_type hash_value) +MDL_lock* MDL_map_partition::find_or_insert(const MDL_key *mdl_key) { MDL_lock *lock; retry: mysql_mutex_lock(&m_mutex); if (!(lock= (MDL_lock*) my_hash_search_using_hash_value(&m_locks, - hash_value, + mdl_key->hash_value(), mdl_key->ptr(), mdl_key->length()))) { @@ -1035,10 +1035,9 @@ MDL_map::get_lock_owner(const MDL_key *mdl_key) } else { - my_hash_value_type hash_value= m_partitions.at(0)->get_key_hash(mdl_key); - uint part_id= hash_value % mdl_locks_hash_partitions; + uint part_id= mdl_key->hash_value() % mdl_locks_hash_partitions; MDL_map_partition *part= m_partitions.at(part_id); - res= part->get_lock_owner(mdl_key, hash_value); + res= part->get_lock_owner(mdl_key); } return res; } @@ -1046,15 +1045,14 @@ MDL_map::get_lock_owner(const MDL_key *mdl_key) unsigned long -MDL_map_partition::get_lock_owner(const MDL_key *mdl_key, - my_hash_value_type hash_value) +MDL_map_partition::get_lock_owner(const MDL_key *mdl_key) { MDL_lock *lock; unsigned long res= 0; mysql_mutex_lock(&m_mutex); lock= (MDL_lock*) my_hash_search_using_hash_value(&m_locks, - hash_value, + mdl_key->hash_value(), mdl_key->ptr(), mdl_key->length()); if (lock) |