Go to the documentation of this file.
31 #ifndef UNIV_HOTBACKUP
39 typedef void* hash_node_t;
42 #define hash_create hash0_create
65 #ifndef UNIV_HOTBACKUP
77 #ifdef UNIV_SYNC_DEBUG
84 #ifdef UNIV_SYNC_DEBUG
85 # define hash_create_sync_obj(t, s, n, level) \
86 hash_create_sync_obj_func(t, s, level, n)
88 # define hash_create_sync_obj(t, s, n, level) \
89 hash_create_sync_obj_func(t, s, n)
109 #ifndef UNIV_HOTBACKUP
112 # define HASH_ASSERT_OWN(TABLE, FOLD) \
113 ut_ad((TABLE)->type != HASH_TABLE_SYNC_MUTEX \
114 || (mutex_own(hash_get_mutex((TABLE), FOLD))));
116 # define HASH_ASSERT_OWN(TABLE, FOLD)
122 #define HASH_INSERT(TYPE, NAME, TABLE, FOLD, DATA)\
124 hash_cell_t* cell3333;\
127 HASH_ASSERT_OWN(TABLE, FOLD)\
129 (DATA)->NAME = NULL;\
131 cell3333 = hash_get_nth_cell(TABLE, hash_calc_hash(FOLD, TABLE));\
133 if (cell3333->node == NULL) {\
134 cell3333->node = DATA;\
136 struct3333 = (TYPE*) cell3333->node;\
138 while (struct3333->NAME != NULL) {\
140 struct3333 = (TYPE*) struct3333->NAME;\
143 struct3333->NAME = DATA;\
147 #ifdef UNIV_HASH_DEBUG
148 # define HASH_ASSERT_VALID(DATA) ut_a((void*) (DATA) != (void*) -1)
149 # define HASH_INVALIDATE(DATA, NAME) *(void**) (&DATA->NAME) = (void*) -1
151 # define HASH_ASSERT_VALID(DATA) do {} while (0)
152 # define HASH_INVALIDATE(DATA, NAME) do {} while (0)
158 #define HASH_DELETE(TYPE, NAME, TABLE, FOLD, DATA)\
160 hash_cell_t* cell3333;\
163 HASH_ASSERT_OWN(TABLE, FOLD)\
165 cell3333 = hash_get_nth_cell(TABLE, hash_calc_hash(FOLD, TABLE));\
167 if (cell3333->node == DATA) {\
168 HASH_ASSERT_VALID(DATA->NAME);\
169 cell3333->node = DATA->NAME;\
171 struct3333 = (TYPE*) cell3333->node;\
173 while (struct3333->NAME != DATA) {\
175 struct3333 = (TYPE*) struct3333->NAME;\
179 struct3333->NAME = DATA->NAME;\
181 HASH_INVALIDATE(DATA, NAME);\
187 #define HASH_GET_FIRST(TABLE, HASH_VAL)\
188 (hash_get_nth_cell(TABLE, HASH_VAL)->node)
193 #define HASH_GET_NEXT(NAME, DATA) ((DATA)->NAME)
197 #define HASH_SEARCH(NAME, TABLE, FOLD, TYPE, DATA, ASSERTION, TEST)\
200 HASH_ASSERT_OWN(TABLE, FOLD)\
202 (DATA) = (TYPE) HASH_GET_FIRST(TABLE, hash_calc_hash(FOLD, TABLE));\
203 HASH_ASSERT_VALID(DATA);\
205 while ((DATA) != NULL) {\
210 HASH_ASSERT_VALID(HASH_GET_NEXT(NAME, DATA));\
211 (DATA) = (TYPE) HASH_GET_NEXT(NAME, DATA);\
218 #define HASH_SEARCH_ALL(NAME, TABLE, TYPE, DATA, ASSERTION, TEST) \
222 for (i3333 = (TABLE)->n_cells; i3333--; ) { \
223 (DATA) = (TYPE) HASH_GET_FIRST(TABLE, i3333); \
225 while ((DATA) != NULL) { \
226 HASH_ASSERT_VALID(DATA); \
233 (DATA) = (TYPE) HASH_GET_NEXT(NAME, DATA); \
236 if ((DATA) != NULL) { \
273 #define HASH_DELETE_AND_COMPACT(TYPE, NAME, TABLE, NODE)\
277 hash_cell_t* cell111;\
280 fold111 = (NODE)->fold;\
282 HASH_DELETE(TYPE, NAME, TABLE, fold111, NODE);\
284 top_node111 = (TYPE*) mem_heap_get_top(\
285 hash_get_heap(TABLE, fold111),\
291 if (NODE != top_node111) {\
295 *(NODE) = *top_node111;\
297 cell111 = hash_get_nth_cell(TABLE,\
298 hash_calc_hash(top_node111->fold, TABLE));\
302 if (cell111->node == top_node111) {\
305 cell111->node = NODE;\
309 node111 = static_cast<TYPE*>(cell111->node);\
311 while (top_node111 != HASH_GET_NEXT(NAME, node111)) {\
313 node111 = static_cast<TYPE*>(\
314 HASH_GET_NEXT(NAME, node111));\
319 node111->NAME = NODE;\
325 mem_heap_free_top(hash_get_heap(TABLE, fold111), sizeof(TYPE));\
328 #ifndef UNIV_HOTBACKUP
332 #define HASH_MIGRATE(OLD_TABLE, NEW_TABLE, NODE_TYPE, PTR_NAME, FOLD_FUNC) \
335 ulint cell_count2222;\
337 cell_count2222 = hash_get_n_cells(OLD_TABLE);\
339 for (i2222 = 0; i2222 < cell_count2222; i2222++) {\
340 NODE_TYPE* node2222 = HASH_GET_FIRST((OLD_TABLE), i2222);\
343 NODE_TYPE* next2222 = node2222->PTR_NAME;\
344 ulint fold2222 = FOLD_FUNC(node2222);\
346 HASH_INSERT(NODE_TYPE, PTR_NAME, (NEW_TABLE),\
347 fold2222, node2222);\
349 node2222 = next2222;\
512 # define hash_get_heap(table, fold) ((table)->heap)
513 # define hash_mutex_enter(table, fold) ((void) 0)
514 # define hash_mutex_exit(table, fold) ((void) 0)
515 # define hash_mutex_enter_all(table) ((void) 0)
516 # define hash_mutex_exit_all(table) ((void) 0)
517 # define hash_mutex_exit_all_but(t, m) ((void) 0)
518 # define hash_lock_s(t, f) ((void) 0)
519 # define hash_lock_x(t, f) ((void) 0)
520 # define hash_unlock_s(t, f) ((void) 0)
521 # define hash_unlock_x(t, f) ((void) 0)
522 # define hash_lock_x_all(t) ((void) 0)
523 # define hash_unlock_x_all(t) ((void) 0)
524 # define hash_unlock_x_all_but(t, l) ((void) 0)
534 #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
535 # ifndef UNIV_HOTBACKUP
543 #ifndef UNIV_HOTBACKUP
567 # define HASH_TABLE_MAGIC_N 76561114