summaryrefslogtreecommitdiff
path: root/sql/mdl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/mdl.cc')
-rw-r--r--sql/mdl.cc43
1 files changed, 20 insertions, 23 deletions
diff --git a/sql/mdl.cc b/sql/mdl.cc
index 4a3336d0031..ff53793554a 100644
--- a/sql/mdl.cc
+++ b/sql/mdl.cc
@@ -22,7 +22,6 @@
#include <mysql/plugin.h>
#include <mysql/service_thd_wait.h>
#include <mysql/psi/mysql_stage.h>
-#include <my_murmur3.h>
#ifdef WITH_WSREP
#include "wsrep_mysqld.h"
@@ -137,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. */
@@ -779,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);
};
@@ -859,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);
}
@@ -876,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())))
{
@@ -1036,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;
}
@@ -1047,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)