| MySQL 5.6.14 Source Code Document
    | 
#include "univ.i"#include "mem0mem.h"#include "sync0sync.h"#include "sync0rw.h"#include "hash0hash.ic"

Go to the source code of this file.
| Classes | |
| struct | hash_cell_t | 
| struct | hash_table_t | 
| Macros | |
| #define | hash_create hash0_create | 
| #define | hash_create_sync_obj(t, s, n, level) hash_create_sync_obj_func(t, s, n) | 
| #define | HASH_ASSERT_OWN(TABLE, FOLD) | 
| #define | HASH_INSERT(TYPE, NAME, TABLE, FOLD, DATA) | 
| #define | HASH_ASSERT_VALID(DATA) do {} while (0) | 
| #define | HASH_INVALIDATE(DATA, NAME) do {} while (0) | 
| #define | HASH_DELETE(TYPE, NAME, TABLE, FOLD, DATA) | 
| #define | HASH_GET_FIRST(TABLE, HASH_VAL) (hash_get_nth_cell(TABLE, HASH_VAL)->node) | 
| #define | HASH_GET_NEXT(NAME, DATA) ((DATA)->NAME) | 
| #define | HASH_SEARCH(NAME, TABLE, FOLD, TYPE, DATA, ASSERTION, TEST) | 
| #define | HASH_SEARCH_ALL(NAME, TABLE, TYPE, DATA, ASSERTION, TEST) | 
| #define | HASH_DELETE_AND_COMPACT(TYPE, NAME, TABLE, NODE) | 
| #define | HASH_MIGRATE(OLD_TABLE, NEW_TABLE, NODE_TYPE, PTR_NAME, FOLD_FUNC) | 
| Typedefs | |
| typedef void * | hash_node_t | 
| Enumerations | |
| enum | hash_table_sync_t { HASH_TABLE_SYNC_NONE = 0, HASH_TABLE_SYNC_MUTEX, HASH_TABLE_SYNC_RW_LOCK } | 
| #define HASH_ASSERT_OWN | ( | TABLE, | |
| FOLD | |||
| ) | 
Assert that the mutex for the table is held
Definition at line 112 of file hash0hash.h.
| #define HASH_DELETE | ( | TYPE, | |
| NAME, | |||
| TABLE, | |||
| FOLD, | |||
| DATA | |||
| ) | 
Deletes a struct from a hash table.
Definition at line 158 of file hash0hash.h.
| #define HASH_DELETE_AND_COMPACT | ( | TYPE, | |
| NAME, | |||
| TABLE, | |||
| NODE | |||
| ) | 
Deletes a struct which is stored in the heap of the hash table, and compacts the heap. The fold value must be stored in the struct NODE in a field named 'fold'.
Definition at line 273 of file hash0hash.h.
| #define HASH_GET_FIRST | ( | TABLE, | |
| HASH_VAL | |||
| ) | (hash_get_nth_cell(TABLE, HASH_VAL)->node) | 
Gets the first struct in a hash chain, NULL if none.
Definition at line 187 of file hash0hash.h.
| #define HASH_GET_NEXT | ( | NAME, | |
| DATA | |||
| ) | ((DATA)->NAME) | 
Gets the next struct in a hash chain, NULL if none.
Definition at line 193 of file hash0hash.h.
| #define HASH_INSERT | ( | TYPE, | |
| NAME, | |||
| TABLE, | |||
| FOLD, | |||
| DATA | |||
| ) | 
Inserts a struct to a hash table.
Definition at line 122 of file hash0hash.h.
| #define HASH_MIGRATE | ( | OLD_TABLE, | |
| NEW_TABLE, | |||
| NODE_TYPE, | |||
| PTR_NAME, | |||
| FOLD_FUNC | |||
| ) | 
Move all hash table entries from OLD_TABLE to NEW_TABLE.
Definition at line 330 of file hash0hash.h.
| #define HASH_SEARCH | ( | NAME, | |
| TABLE, | |||
| FOLD, | |||
| TYPE, | |||
| DATA, | |||
| ASSERTION, | |||
| TEST | |||
| ) | 
Looks for a struct in a hash table.
Definition at line 197 of file hash0hash.h.
| #define HASH_SEARCH_ALL | ( | NAME, | |
| TABLE, | |||
| TYPE, | |||
| DATA, | |||
| ASSERTION, | |||
| TEST | |||
| ) | 
Looks for an item in all hash buckets.
Definition at line 218 of file hash0hash.h.
| enum hash_table_sync_t | 
Definition at line 46 of file hash0hash.h.
| UNIV_INLINE ulint hash_calc_hash | ( | ulint | fold, | 
| hash_table_t * | table | ||
| ) | 
Calculates the hash value from a folded value.
| fold | in: folded value | 

| UNIV_INTERN hash_table_t* hash_create | ( | ulint | n | ) | 
Creates a hash table with >= n array cells. The actual number of cells is chosen to be a prime number slightly bigger than n.
Creates a hash table with >= n array cells. The actual number of cells is chosen to be a prime number slightly bigger than n.
| n | in: number of array cells | 
Definition at line 293 of file hash0hash.cc.

| UNIV_INTERN void hash_create_sync_obj_func | ( | hash_table_t * | table, | 
| enum hash_table_sync_t | type, | ||
| ulint | n_sync_obj | ||
| ) | 
Creates a sync object array array to protect a hash table. ::sync_obj can be mutexes or rw_locks depening on the type of hash table. in: number of sync objects, must be a power of 2
Creates a sync object array to protect a hash table. ::sync_obj can be mutexes or rw_locks depening on the type of hash table.
| table | in: hash table | 
| type | in: HASH_TABLE_SYNC_MUTEX or HASH_TABLE_SYNC_RW_LOCK | 
| n_sync_obj | in: number of sync objects, must be a power of 2 | 
Definition at line 352 of file hash0hash.cc.
| UNIV_INLINE mem_heap_t* hash_get_heap | ( | hash_table_t * | table, | 
| ulint | fold | ||
| ) | 
Gets the heap for a fold value in a hash table.
| table | in: hash table | 

| UNIV_INLINE rw_lock_t* hash_get_lock | ( | hash_table_t * | table, | 
| ulint | fold | ||
| ) | 
Gets the rw_lock for a fold value in a hash table.
| table | in: hash table | 

| UNIV_INLINE ib_mutex_t* hash_get_mutex | ( | hash_table_t * | table, | 
| ulint | fold | ||
| ) | 
Gets the mutex for a fold value in a hash table.
| table | in: hash table | 

| UNIV_INLINE ulint hash_get_n_cells | ( | hash_table_t * | table | ) | 
Returns the number of cells in a hash table.

| UNIV_INLINE hash_cell_t* hash_get_nth_cell | ( | hash_table_t * | table, | 
| ulint | n | ||
| ) | 
Gets the nth cell in a hash table.
| table | in: hash table | 

| UNIV_INLINE mem_heap_t* hash_get_nth_heap | ( | hash_table_t * | table, | 
| ulint | i | ||
| ) | 
Gets the nth heap in a hash table.
| table | in: hash table | 
| UNIV_INLINE rw_lock_t* hash_get_nth_lock | ( | hash_table_t * | table, | 
| ulint | i | ||
| ) | 
Gets the nth rw_lock in a hash table.
| table | in: hash table | 
| UNIV_INLINE ib_mutex_t* hash_get_nth_mutex | ( | hash_table_t * | table, | 
| ulint | i | ||
| ) | 
Gets the nth mutex in a hash table.
| table | in: hash table | 
| UNIV_INLINE ulint hash_get_sync_obj_index | ( | hash_table_t * | table, | 
| ulint | fold | ||
| ) | 
Gets the sync object index for a fold value in a hash table.
| table | in: hash table | 
| UNIV_INTERN void hash_lock_s | ( | hash_table_t * | table, | 
| ulint | fold | ||
| ) | 
s-lock a lock for a fold value in a hash table. in: fold
s-lock a lock for a fold value in a hash table.
| table | in: hash table | 
| fold | in: fold | 
Definition at line 129 of file hash0hash.cc.

| UNIV_INTERN void hash_lock_x | ( | hash_table_t * | table, | 
| ulint | fold | ||
| ) | 
x-lock a lock for a fold value in a hash table. in: fold
x-lock a lock for a fold value in a hash table.
| table | in: hash table | 
| fold | in: fold | 
Definition at line 152 of file hash0hash.cc.

| UNIV_INTERN void hash_lock_x_all | ( | hash_table_t * | table | ) | 
Reserves all the locks of a hash table, in an ascending order. in: hash table
Reserves all the locks of a hash table, in an ascending order.
| table | in: hash table | 
Definition at line 219 of file hash0hash.cc.

| UNIV_INTERN void hash_mutex_enter | ( | hash_table_t * | table, | 
| ulint | fold | ||
| ) | 
Reserves the mutex for a fold value in a hash table. in: fold
Reserves the mutex for a fold value in a hash table.
| table | in: hash table | 
| fold | in: fold | 
Definition at line 46 of file hash0hash.cc.

| UNIV_INTERN void hash_mutex_enter_all | ( | hash_table_t * | table | ) | 
Reserves all the mutexes of a hash table, in an ascending order. in: hash table
Reserves all the mutexes of a hash table, in an ascending order.
| table | in: hash table | 
Definition at line 72 of file hash0hash.cc.
| UNIV_INTERN void hash_mutex_exit | ( | hash_table_t * | table, | 
| ulint | fold | ||
| ) | 
Releases the mutex for a fold value in a hash table. in: fold
Releases the mutex for a fold value in a hash table.
| table | in: hash table | 
| fold | in: fold | 
Definition at line 59 of file hash0hash.cc.

| UNIV_INTERN void hash_mutex_exit_all | ( | hash_table_t * | table | ) | 
Releases all the mutexes of a hash table. in: hash table
Releases all the mutexes of a hash table.
| table | in: hash table | 
Definition at line 89 of file hash0hash.cc.
| UNIV_INTERN void hash_mutex_exit_all_but | ( | hash_table_t * | table, | 
| ib_mutex_t * | keep_mutex | ||
| ) | 
Releases all but the passed in mutex of a hash table. in: mutex to keep
Releases all but the passed in mutex of a hash table.
| table | in: hash table | 
| keep_mutex | in: mutex to keep | 
Definition at line 106 of file hash0hash.cc.
| UNIV_INLINE void hash_table_clear | ( | hash_table_t * | table | ) | 
Clears a hash table so that all the cells become empty. in/out: hash table

| UNIV_INTERN void hash_table_free | ( | hash_table_t * | table | ) | 
Frees a hash table. in, own: hash table
Frees a hash table.
| table | in, own: hash table | 
Definition at line 334 of file hash0hash.cc.


| UNIV_INTERN void hash_unlock_s | ( | hash_table_t * | table, | 
| ulint | fold | ||
| ) | 
unlock an s-lock for a fold value in a hash table. in: fold
unlock an s-lock for a fold value in a hash table.
| table | in: hash table | 
| fold | in: fold | 
Definition at line 175 of file hash0hash.cc.

| UNIV_INTERN void hash_unlock_x | ( | hash_table_t * | table, | 
| ulint | fold | ||
| ) | 
unlock x-lock for a fold value in a hash table. in: fold
unlock x-lock for a fold value in a hash table.
| table | in: hash table | 
| fold | in: fold | 
Definition at line 198 of file hash0hash.cc.

| UNIV_INTERN void hash_unlock_x_all | ( | hash_table_t * | table | ) | 
Releases all the locks of a hash table, in an ascending order. in: hash table
Releases all the locks of a hash table, in an ascending order.
| table | in: hash table | 
Definition at line 242 of file hash0hash.cc.
| UNIV_INTERN void hash_unlock_x_all_but | ( | hash_table_t * | table, | 
| rw_lock_t * | keep_lock | ||
| ) | 
Releases all but passed in lock of a hash table, in: lock to keep
Releases all but passed in lock of a hash table,
| table | in: hash table | 
| keep_lock | in: lock to keep | 
Definition at line 264 of file hash0hash.cc.
