28
29
/*************************************************************
29
30
Looks for an element when we know the pointer to the data and updates
30
31
the pointer to data if found. */
33
ha_search_and_update_if_found(
34
/*==========================*/
34
ha_search_and_update_if_found_func(
35
/*===============================*/
35
36
hash_table_t* table, /* in: hash table */
36
37
ulint fold, /* in: folded value of the searched data */
37
38
void* data, /* in: pointer to the data */
40
buf_block_t* new_block,/* in: block containing new_data */
38
42
void* new_data);/* in: new pointer to the data */
45
# define ha_search_and_update_if_found(table,fold,data,new_block,new_data) \
46
ha_search_and_update_if_found_func(table,fold,data,new_block,new_data)
48
# define ha_search_and_update_if_found(table,fold,data,new_block,new_data) \
49
ha_search_and_update_if_found_func(table,fold,data,new_data)
39
51
/*****************************************************************
40
52
Creates a hash table with >= n array cells. The actual number of cells is
41
53
chosen to be a prime number slightly bigger than n. */
46
58
/* out, own: created table */
47
ibool in_btr_search, /* in: TRUE if the hash table is used in
48
the btr_search module */
49
59
ulint n, /* in: number of array cells */
50
60
#ifdef UNIV_SYNC_DEBUG
51
61
ulint mutex_level, /* in: level of the mutexes in the latching
54
64
ulint n_mutexes); /* in: number of mutexes to protect the
55
65
hash table: must be a power of 2 */
56
66
#ifdef UNIV_SYNC_DEBUG
57
# define ha_create(b,n_c,n_m,level) ha_create_func(b,n_c,level,n_m)
67
# define ha_create(n_c,n_m,level) ha_create_func(n_c,level,n_m)
58
68
#else /* UNIV_SYNC_DEBUG */
59
# define ha_create(b,n_c,n_m,level) ha_create_func(b,n_c,n_m)
69
# define ha_create(n_c,n_m,level) ha_create_func(n_c,n_m)
60
70
#endif /* UNIV_SYNC_DEBUG */
72
/*****************************************************************
73
Empties a hash table and frees the memory heaps. */
78
hash_table_t* table); /* in, own: hash table */
61
80
/*****************************************************************
62
81
Inserts an entry into a hash table. If an entry with the same fold number
63
82
is found, its node is updated to point to the new data, and no new node
86
ha_insert_for_fold_func(
87
/*====================*/
69
88
/* out: TRUE if succeed, FALSE if no more
70
89
memory could be allocated */
71
90
hash_table_t* table, /* in: hash table */
73
92
the same fold value already exists, it is
74
93
updated to point to the same data, and no new
75
94
node is created! */
96
buf_block_t* block, /* in: buffer block containing the data */
97
#endif /* UNIV_DEBUG */
76
98
void* data); /* in: data, must not be NULL */
101
# define ha_insert_for_fold(t,f,b,d) ha_insert_for_fold_func(t,f,b,d)
103
# define ha_insert_for_fold(t,f,b,d) ha_insert_for_fold_func(t,f,d)
77
106
/*****************************************************************
78
107
Deletes an entry from a hash table. */
98
127
/*********************************************************************
99
128
Removes from the chain determined by fold all nodes whose data pointer
100
129
points to the page given. */
103
132
ha_remove_all_nodes_to_page(
104
133
/*========================*/
105
134
hash_table_t* table, /* in: hash table */
106
135
ulint fold, /* in: fold value */
107
page_t* page); /* in: buffer page */
136
const page_t* page); /* in: buffer page */
108
137
/*****************************************************************
109
138
Validates a given range of the cells in hash table. */
129
158
typedef struct ha_node_struct ha_node_t;
130
159
struct ha_node_struct {
131
ha_node_t* next; /* next chain node or NULL if none */
132
void* data; /* pointer to the data */
133
ulint fold; /* fold value for the data */
160
ha_node_t* next; /* next chain node or NULL if none */
162
buf_block_t* block; /* buffer block containing the data, or NULL */
163
#endif /* UNIV_DEBUG */
164
void* data; /* pointer to the data */
165
ulint fold; /* fold value for the data */
136
168
#ifndef UNIV_NONINL