summaryrefslogtreecommitdiff
path: root/storage/innobase/include/ha0ha.ic
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/include/ha0ha.ic')
-rw-r--r--storage/innobase/include/ha0ha.ic46
1 files changed, 21 insertions, 25 deletions
diff --git a/storage/innobase/include/ha0ha.ic b/storage/innobase/include/ha0ha.ic
index c478ff54303..854ff9bc046 100644
--- a/storage/innobase/include/ha0ha.ic
+++ b/storage/innobase/include/ha0ha.ic
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved.
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 the Free Software
@@ -29,7 +29,6 @@ Created 8/18/1994 Heikki Tuuri
/***********************************************************//**
Deletes a hash node. */
-UNIV_INTERN
void
ha_delete_hash_node(
/*================*/
@@ -38,7 +37,7 @@ ha_delete_hash_node(
/******************************************************************//**
Gets a hash node data.
-@return pointer to the data */
+@return pointer to the data */
UNIV_INLINE
const rec_t*
ha_node_get_data(
@@ -68,33 +67,33 @@ ha_node_set_data_func(
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
/** Sets hash node data.
-@param n in: hash chain node
-@param b in: buffer block containing the data
-@param d in: pointer to the data */
+@param n in: hash chain node
+@param b in: buffer block containing the data
+@param d in: pointer to the data */
# define ha_node_set_data(n,b,d) ha_node_set_data_func(n,b,d)
#else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
/** Sets hash node data.
-@param n in: hash chain node
-@param b in: buffer block containing the data
-@param d in: pointer to the data */
+@param n in: hash chain node
+@param b in: buffer block containing the data
+@param d in: pointer to the data */
# define ha_node_set_data(n,b,d) ha_node_set_data_func(n,d)
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
/******************************************************************//**
Gets the next node in a hash chain.
-@return next node, NULL if none */
+@return next node, NULL if none */
UNIV_INLINE
ha_node_t*
ha_chain_get_next(
/*==============*/
- ha_node_t* node) /*!< in: hash chain node */
+ const ha_node_t* node) /*!< in: hash chain node */
{
return(node->next);
}
/******************************************************************//**
Gets the first node in a hash chain.
-@return first node, NULL if none */
+@return first node, NULL if none */
UNIV_INLINE
ha_node_t*
ha_chain_get_first(
@@ -122,9 +121,9 @@ hash_assert_can_modify(
if (table->type == HASH_TABLE_SYNC_MUTEX) {
ut_ad(mutex_own(hash_get_mutex(table, fold)));
} else if (table->type == HASH_TABLE_SYNC_RW_LOCK) {
-# ifdef UNIV_SYNC_DEBUG
+# ifdef UNIV_DEBUG
rw_lock_t* lock = hash_get_lock(table, fold);
- ut_ad(rw_lock_own(lock, RW_LOCK_EX));
+ ut_ad(rw_lock_own(lock, RW_LOCK_X));
# endif
} else {
ut_ad(table->type == HASH_TABLE_SYNC_NONE);
@@ -145,10 +144,10 @@ hash_assert_can_search(
if (table->type == HASH_TABLE_SYNC_MUTEX) {
ut_ad(mutex_own(hash_get_mutex(table, fold)));
} else if (table->type == HASH_TABLE_SYNC_RW_LOCK) {
-# ifdef UNIV_SYNC_DEBUG
+# ifdef UNIV_DEBUG
rw_lock_t* lock = hash_get_lock(table, fold);
- ut_ad(rw_lock_own(lock, RW_LOCK_EX)
- || rw_lock_own(lock, RW_LOCK_SHARED));
+ ut_ad(rw_lock_own(lock, RW_LOCK_X)
+ || rw_lock_own(lock, RW_LOCK_S));
# endif
} else {
ut_ad(table->type == HASH_TABLE_SYNC_NONE);
@@ -167,20 +166,17 @@ ha_search_and_get_data(
hash_table_t* table, /*!< in: hash table */
ulint fold) /*!< in: folded value of the searched data */
{
- ha_node_t* node;
-
hash_assert_can_search(table, fold);
ut_ad(btr_search_enabled);
- node = ha_chain_get_first(table, fold);
+ for (const ha_node_t* node = ha_chain_get_first(table, fold);
+ node != NULL;
+ node = ha_chain_get_next(node)) {
- while (node) {
if (node->fold == fold) {
return(node->data);
}
-
- node = ha_chain_get_next(node);
}
return(NULL);
@@ -188,7 +184,7 @@ ha_search_and_get_data(
/*********************************************************//**
Looks for an element when we know the pointer to the data.
-@return pointer to the hash table node, NULL if not found in the table */
+@return pointer to the hash table node, NULL if not found in the table */
UNIV_INLINE
ha_node_t*
ha_search_with_data(
@@ -220,7 +216,7 @@ ha_search_with_data(
/*********************************************************//**
Looks for an element when we know the pointer to the data, and deletes
it from the hash table, if found.
-@return TRUE if found */
+@return TRUE if found */
UNIV_INLINE
ibool
ha_search_and_delete_if_found(