You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

390 lines
11 KiB

20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
branches/innodb+: Merge revisions 3579:3599 from branches/zip: ------------------------------------------------------------------------ r3589 | marko | 2008-12-18 15:24:44 +0200 (Thu, 18 Dec 2008) | 2 lines branches/zip: ha_innodb.cc: Do not include some unnecessary MySQL header files. ------------------------------------------------------------------------ r3594 | marko | 2008-12-19 13:58:13 +0200 (Fri, 19 Dec 2008) | 4 lines branches/zip: HASH_INSERT, HASH_DELETE: Add explicit type conversions, so that the macros will expand to valid C++. Unlike C++, C allows implicit type conversions from void* to other pointer types. ------------------------------------------------------------------------ r3597 | marko | 2008-12-22 12:27:16 +0200 (Mon, 22 Dec 2008) | 3 lines branches/zip: Pass the caller's file name and line number to row_mysql_lock_data_dictionary(), row_mysql_freeze_data_dictionary(), to better track down locking issues that involve dict_operation_lock. ------------------------------------------------------------------------ r3599 | marko | 2008-12-22 15:41:47 +0200 (Mon, 22 Dec 2008) | 36 lines branches/zip: Merge revisions 3479:3598 from branches/5.1: ------------------------------------------------------------------------ r3588 | inaam | 2008-12-18 14:26:54 +0200 (Thu, 18 Dec 2008) | 8 lines branches/5.1 It is a bug in unused code. If we don't calculate the hash value when calculating the mutex number then two pages which map to same hash value can get two different mutex numbers. Approved by: Marko ------------------------------------------------------------------------ r3590 | marko | 2008-12-18 15:33:36 +0200 (Thu, 18 Dec 2008) | 11 lines branches/5.1: When converting a record to MySQL format, copy the default column values for columns that are SQL NULL. This addresses failures in row-based replication (Bug #39648). row_prebuilt_t: Add default_rec, for the default values of the columns in MySQL format. row_sel_store_mysql_rec(): Use prebuilt->default_rec instead of padding columns. rb://64 approved by Heikki Tuuri ------------------------------------------------------------------------ r3598 | marko | 2008-12-22 15:28:03 +0200 (Mon, 22 Dec 2008) | 6 lines branches/5.1: ibuf_delete_rec(): When the record cannot be found and the tablespace has been dropped, commit the mini-transaction, so that InnoDB will not hold the insert buffer tree latch in exclusive mode, causing a potential deadlock. This bug was introduced in the fix of Bug #27276 in r2924. ------------------------------------------------------------------------ ------------------------------------------------------------------------
17 years ago
20 years ago
20 years ago
20 years ago
branches/innodb+: Merge revisions 3579:3599 from branches/zip: ------------------------------------------------------------------------ r3589 | marko | 2008-12-18 15:24:44 +0200 (Thu, 18 Dec 2008) | 2 lines branches/zip: ha_innodb.cc: Do not include some unnecessary MySQL header files. ------------------------------------------------------------------------ r3594 | marko | 2008-12-19 13:58:13 +0200 (Fri, 19 Dec 2008) | 4 lines branches/zip: HASH_INSERT, HASH_DELETE: Add explicit type conversions, so that the macros will expand to valid C++. Unlike C++, C allows implicit type conversions from void* to other pointer types. ------------------------------------------------------------------------ r3597 | marko | 2008-12-22 12:27:16 +0200 (Mon, 22 Dec 2008) | 3 lines branches/zip: Pass the caller's file name and line number to row_mysql_lock_data_dictionary(), row_mysql_freeze_data_dictionary(), to better track down locking issues that involve dict_operation_lock. ------------------------------------------------------------------------ r3599 | marko | 2008-12-22 15:41:47 +0200 (Mon, 22 Dec 2008) | 36 lines branches/zip: Merge revisions 3479:3598 from branches/5.1: ------------------------------------------------------------------------ r3588 | inaam | 2008-12-18 14:26:54 +0200 (Thu, 18 Dec 2008) | 8 lines branches/5.1 It is a bug in unused code. If we don't calculate the hash value when calculating the mutex number then two pages which map to same hash value can get two different mutex numbers. Approved by: Marko ------------------------------------------------------------------------ r3590 | marko | 2008-12-18 15:33:36 +0200 (Thu, 18 Dec 2008) | 11 lines branches/5.1: When converting a record to MySQL format, copy the default column values for columns that are SQL NULL. This addresses failures in row-based replication (Bug #39648). row_prebuilt_t: Add default_rec, for the default values of the columns in MySQL format. row_sel_store_mysql_rec(): Use prebuilt->default_rec instead of padding columns. rb://64 approved by Heikki Tuuri ------------------------------------------------------------------------ r3598 | marko | 2008-12-22 15:28:03 +0200 (Mon, 22 Dec 2008) | 6 lines branches/5.1: ibuf_delete_rec(): When the record cannot be found and the tablespace has been dropped, commit the mini-transaction, so that InnoDB will not hold the insert buffer tree latch in exclusive mode, causing a potential deadlock. This bug was introduced in the fix of Bug #27276 in r2924. ------------------------------------------------------------------------ ------------------------------------------------------------------------
17 years ago
20 years ago
branches/innodb+: Merge revisions 3579:3599 from branches/zip: ------------------------------------------------------------------------ r3589 | marko | 2008-12-18 15:24:44 +0200 (Thu, 18 Dec 2008) | 2 lines branches/zip: ha_innodb.cc: Do not include some unnecessary MySQL header files. ------------------------------------------------------------------------ r3594 | marko | 2008-12-19 13:58:13 +0200 (Fri, 19 Dec 2008) | 4 lines branches/zip: HASH_INSERT, HASH_DELETE: Add explicit type conversions, so that the macros will expand to valid C++. Unlike C++, C allows implicit type conversions from void* to other pointer types. ------------------------------------------------------------------------ r3597 | marko | 2008-12-22 12:27:16 +0200 (Mon, 22 Dec 2008) | 3 lines branches/zip: Pass the caller's file name and line number to row_mysql_lock_data_dictionary(), row_mysql_freeze_data_dictionary(), to better track down locking issues that involve dict_operation_lock. ------------------------------------------------------------------------ r3599 | marko | 2008-12-22 15:41:47 +0200 (Mon, 22 Dec 2008) | 36 lines branches/zip: Merge revisions 3479:3598 from branches/5.1: ------------------------------------------------------------------------ r3588 | inaam | 2008-12-18 14:26:54 +0200 (Thu, 18 Dec 2008) | 8 lines branches/5.1 It is a bug in unused code. If we don't calculate the hash value when calculating the mutex number then two pages which map to same hash value can get two different mutex numbers. Approved by: Marko ------------------------------------------------------------------------ r3590 | marko | 2008-12-18 15:33:36 +0200 (Thu, 18 Dec 2008) | 11 lines branches/5.1: When converting a record to MySQL format, copy the default column values for columns that are SQL NULL. This addresses failures in row-based replication (Bug #39648). row_prebuilt_t: Add default_rec, for the default values of the columns in MySQL format. row_sel_store_mysql_rec(): Use prebuilt->default_rec instead of padding columns. rb://64 approved by Heikki Tuuri ------------------------------------------------------------------------ r3598 | marko | 2008-12-22 15:28:03 +0200 (Mon, 22 Dec 2008) | 6 lines branches/5.1: ibuf_delete_rec(): When the record cannot be found and the tablespace has been dropped, commit the mini-transaction, so that InnoDB will not hold the insert buffer tree latch in exclusive mode, causing a potential deadlock. This bug was introduced in the fix of Bug #27276 in r2924. ------------------------------------------------------------------------ ------------------------------------------------------------------------
17 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
branches/innodb+: Merge revisions 3544:3575 from branches/zip: ------------------------------------------------------------------------ r3572 | marko | 2008-12-17 11:19:56 +0200 (Wed, 17 Dec 2008) | 3 lines Changed paths: M /branches/zip/ChangeLog M /branches/zip/btr/btr0sea.c M /branches/zip/buf/buf0buf.c M /branches/zip/buf/buf0lru.c M /branches/zip/ha/ha0ha.c M /branches/zip/ha/hash0hash.c M /branches/zip/include/buf0buf.h M /branches/zip/include/ha0ha.h M /branches/zip/include/ha0ha.ic M /branches/zip/include/hash0hash.h M /branches/zip/include/univ.i branches/zip: Introduce UNIV_AHI_DEBUG for debugging the adaptive hash index without enabling UNIV_DEBUG. ------------------------------------------------------------------------ r3574 | marko | 2008-12-17 12:44:31 +0200 (Wed, 17 Dec 2008) | 2 lines Changed paths: M /branches/zip/ChangeLog branches/zip: ChangeLog: Document recent changes that were not included in InnoDB Plugin 1.0.2, except changes to source code comments. ------------------------------------------------------------------------ r3575 | marko | 2008-12-17 14:40:58 +0200 (Wed, 17 Dec 2008) | 12 lines Changed paths: M /branches/zip/ChangeLog M /branches/zip/include/row0sel.h M /branches/zip/include/row0upd.h M /branches/zip/pars/pars0pars.c M /branches/zip/row/row0mysql.c M /branches/zip/row/row0sel.c M /branches/zip/row/row0upd.c branches/zip: Remove update-in-place-in-select from the internal SQL interpreter. It was only used for updating the InnoDB internal data dictionary when renaming or dropping tables. It could have caused deadlocks after acquiring latches on insert buffer bitmap pages. This and r3544 should fix Issue #135. Furthermore, the update-in-place-in-select does not account for compression failure. That was not a problem yet, since the InnoDB SQL interpreter has so far assumed ROW_FORMAT=REDUNDANT. rb://63 approved by Heikki Tuuri ------------------------------------------------------------------------
17 years ago
20 years ago
branches/innodb+: Merge revisions 3544:3575 from branches/zip: ------------------------------------------------------------------------ r3572 | marko | 2008-12-17 11:19:56 +0200 (Wed, 17 Dec 2008) | 3 lines Changed paths: M /branches/zip/ChangeLog M /branches/zip/btr/btr0sea.c M /branches/zip/buf/buf0buf.c M /branches/zip/buf/buf0lru.c M /branches/zip/ha/ha0ha.c M /branches/zip/ha/hash0hash.c M /branches/zip/include/buf0buf.h M /branches/zip/include/ha0ha.h M /branches/zip/include/ha0ha.ic M /branches/zip/include/hash0hash.h M /branches/zip/include/univ.i branches/zip: Introduce UNIV_AHI_DEBUG for debugging the adaptive hash index without enabling UNIV_DEBUG. ------------------------------------------------------------------------ r3574 | marko | 2008-12-17 12:44:31 +0200 (Wed, 17 Dec 2008) | 2 lines Changed paths: M /branches/zip/ChangeLog branches/zip: ChangeLog: Document recent changes that were not included in InnoDB Plugin 1.0.2, except changes to source code comments. ------------------------------------------------------------------------ r3575 | marko | 2008-12-17 14:40:58 +0200 (Wed, 17 Dec 2008) | 12 lines Changed paths: M /branches/zip/ChangeLog M /branches/zip/include/row0sel.h M /branches/zip/include/row0upd.h M /branches/zip/pars/pars0pars.c M /branches/zip/row/row0mysql.c M /branches/zip/row/row0sel.c M /branches/zip/row/row0upd.c branches/zip: Remove update-in-place-in-select from the internal SQL interpreter. It was only used for updating the InnoDB internal data dictionary when renaming or dropping tables. It could have caused deadlocks after acquiring latches on insert buffer bitmap pages. This and r3544 should fix Issue #135. Furthermore, the update-in-place-in-select does not account for compression failure. That was not a problem yet, since the InnoDB SQL interpreter has so far assumed ROW_FORMAT=REDUNDANT. rb://63 approved by Heikki Tuuri ------------------------------------------------------------------------
17 years ago
20 years ago
  1. /******************************************************
  2. The simple hash table utility
  3. (c) 1997 Innobase Oy
  4. Created 5/20/1997 Heikki Tuuri
  5. *******************************************************/
  6. #ifndef hash0hash_h
  7. #define hash0hash_h
  8. #include "univ.i"
  9. #include "mem0mem.h"
  10. #include "sync0sync.h"
  11. typedef struct hash_table_struct hash_table_t;
  12. typedef struct hash_cell_struct hash_cell_t;
  13. typedef void* hash_node_t;
  14. /* Fix Bug #13859: symbol collision between imap/mysql */
  15. #define hash_create hash0_create
  16. /*****************************************************************
  17. Creates a hash table with >= n array cells. The actual number
  18. of cells is chosen to be a prime number slightly bigger than n. */
  19. UNIV_INTERN
  20. hash_table_t*
  21. hash_create(
  22. /*========*/
  23. /* out, own: created table */
  24. ulint n); /* in: number of array cells */
  25. /*****************************************************************
  26. Creates a mutex array to protect a hash table. */
  27. UNIV_INTERN
  28. void
  29. hash_create_mutexes_func(
  30. /*=====================*/
  31. hash_table_t* table, /* in: hash table */
  32. #ifdef UNIV_SYNC_DEBUG
  33. ulint sync_level, /* in: latching order level of the
  34. mutexes: used in the debug version */
  35. #endif /* UNIV_SYNC_DEBUG */
  36. ulint n_mutexes); /* in: number of mutexes */
  37. #ifdef UNIV_SYNC_DEBUG
  38. # define hash_create_mutexes(t,n,level) hash_create_mutexes_func(t,level,n)
  39. #else /* UNIV_SYNC_DEBUG */
  40. # define hash_create_mutexes(t,n,level) hash_create_mutexes_func(t,n)
  41. #endif /* UNIV_SYNC_DEBUG */
  42. /*****************************************************************
  43. Frees a hash table. */
  44. UNIV_INTERN
  45. void
  46. hash_table_free(
  47. /*============*/
  48. hash_table_t* table); /* in, own: hash table */
  49. /******************************************************************
  50. Calculates the hash value from a folded value. */
  51. UNIV_INLINE
  52. ulint
  53. hash_calc_hash(
  54. /*===========*/
  55. /* out: hashed value */
  56. ulint fold, /* in: folded value */
  57. hash_table_t* table); /* in: hash table */
  58. /************************************************************************
  59. Assert that the mutex for the table in a hash operation is owned. */
  60. #ifdef UNIV_SYNC_DEBUG
  61. # define HASH_ASSERT_OWNED(TABLE, FOLD) \
  62. ut_ad(!(TABLE)->mutexes || mutex_own(hash_get_mutex(TABLE, FOLD)));
  63. #else
  64. # define HASH_ASSERT_OWNED(TABLE, FOLD)
  65. #endif
  66. /***********************************************************************
  67. Inserts a struct to a hash table. */
  68. #define HASH_INSERT(TYPE, NAME, TABLE, FOLD, DATA)\
  69. do {\
  70. hash_cell_t* cell3333;\
  71. TYPE* struct3333;\
  72. \
  73. HASH_ASSERT_OWNED(TABLE, FOLD)\
  74. \
  75. (DATA)->NAME = NULL;\
  76. \
  77. cell3333 = hash_get_nth_cell(TABLE, hash_calc_hash(FOLD, TABLE));\
  78. \
  79. if (cell3333->node == NULL) {\
  80. cell3333->node = DATA;\
  81. } else {\
  82. struct3333 = (TYPE*) cell3333->node;\
  83. \
  84. while (struct3333->NAME != NULL) {\
  85. \
  86. struct3333 = (TYPE*) struct3333->NAME;\
  87. }\
  88. \
  89. struct3333->NAME = DATA;\
  90. }\
  91. } while (0)
  92. #ifdef UNIV_HASH_DEBUG
  93. # define HASH_ASSERT_VALID(DATA) ut_a((void*) (DATA) != (void*) -1)
  94. # define HASH_INVALIDATE(DATA, NAME) DATA->NAME = (void*) -1
  95. #else
  96. # define HASH_ASSERT_VALID(DATA) do {} while (0)
  97. # define HASH_INVALIDATE(DATA, NAME) do {} while (0)
  98. #endif
  99. /***********************************************************************
  100. Deletes a struct from a hash table. */
  101. #define HASH_DELETE(TYPE, NAME, TABLE, FOLD, DATA)\
  102. do {\
  103. hash_cell_t* cell3333;\
  104. TYPE* struct3333;\
  105. \
  106. HASH_ASSERT_OWNED(TABLE, FOLD)\
  107. \
  108. cell3333 = hash_get_nth_cell(TABLE, hash_calc_hash(FOLD, TABLE));\
  109. \
  110. if (cell3333->node == DATA) {\
  111. HASH_ASSERT_VALID(DATA->NAME);\
  112. cell3333->node = DATA->NAME;\
  113. } else {\
  114. struct3333 = (TYPE*) cell3333->node;\
  115. \
  116. while (struct3333->NAME != DATA) {\
  117. \
  118. struct3333 = (TYPE*) struct3333->NAME;\
  119. ut_a(struct3333);\
  120. }\
  121. \
  122. struct3333->NAME = DATA->NAME;\
  123. }\
  124. HASH_INVALIDATE(DATA, NAME);\
  125. } while (0)
  126. /***********************************************************************
  127. Gets the first struct in a hash chain, NULL if none. */
  128. #define HASH_GET_FIRST(TABLE, HASH_VAL)\
  129. (hash_get_nth_cell(TABLE, HASH_VAL)->node)
  130. /***********************************************************************
  131. Gets the next struct in a hash chain, NULL if none. */
  132. #define HASH_GET_NEXT(NAME, DATA) ((DATA)->NAME)
  133. /************************************************************************
  134. Looks for a struct in a hash table. */
  135. #define HASH_SEARCH(NAME, TABLE, FOLD, TYPE, DATA, TEST)\
  136. {\
  137. \
  138. HASH_ASSERT_OWNED(TABLE, FOLD)\
  139. \
  140. (DATA) = (TYPE) HASH_GET_FIRST(TABLE, hash_calc_hash(FOLD, TABLE));\
  141. HASH_ASSERT_VALID(DATA);\
  142. \
  143. while ((DATA) != NULL) {\
  144. if (TEST) {\
  145. break;\
  146. } else {\
  147. HASH_ASSERT_VALID(HASH_GET_NEXT(NAME, DATA));\
  148. (DATA) = (TYPE) HASH_GET_NEXT(NAME, DATA);\
  149. }\
  150. }\
  151. }
  152. /****************************************************************
  153. Gets the nth cell in a hash table. */
  154. UNIV_INLINE
  155. hash_cell_t*
  156. hash_get_nth_cell(
  157. /*==============*/
  158. /* out: pointer to cell */
  159. hash_table_t* table, /* in: hash table */
  160. ulint n); /* in: cell index */
  161. /*****************************************************************
  162. Clears a hash table so that all the cells become empty. */
  163. UNIV_INLINE
  164. void
  165. hash_table_clear(
  166. /*=============*/
  167. hash_table_t* table); /* in/out: hash table */
  168. /*****************************************************************
  169. Returns the number of cells in a hash table. */
  170. UNIV_INLINE
  171. ulint
  172. hash_get_n_cells(
  173. /*=============*/
  174. /* out: number of cells */
  175. hash_table_t* table); /* in: table */
  176. /***********************************************************************
  177. Deletes a struct which is stored in the heap of the hash table, and compacts
  178. the heap. The fold value must be stored in the struct NODE in a field named
  179. 'fold'. */
  180. #define HASH_DELETE_AND_COMPACT(TYPE, NAME, TABLE, NODE)\
  181. do {\
  182. TYPE* node111;\
  183. TYPE* top_node111;\
  184. hash_cell_t* cell111;\
  185. ulint fold111;\
  186. \
  187. fold111 = (NODE)->fold;\
  188. \
  189. HASH_DELETE(TYPE, NAME, TABLE, fold111, NODE);\
  190. \
  191. top_node111 = (TYPE*)mem_heap_get_top(\
  192. hash_get_heap(TABLE, fold111),\
  193. sizeof(TYPE));\
  194. \
  195. /* If the node to remove is not the top node in the heap, compact the\
  196. heap of nodes by moving the top node in the place of NODE. */\
  197. \
  198. if (NODE != top_node111) {\
  199. \
  200. /* Copy the top node in place of NODE */\
  201. \
  202. *(NODE) = *top_node111;\
  203. \
  204. cell111 = hash_get_nth_cell(TABLE,\
  205. hash_calc_hash(top_node111->fold, TABLE));\
  206. \
  207. /* Look for the pointer to the top node, to update it */\
  208. \
  209. if (cell111->node == top_node111) {\
  210. /* The top node is the first in the chain */\
  211. \
  212. cell111->node = NODE;\
  213. } else {\
  214. /* We have to look for the predecessor of the top\
  215. node */\
  216. node111 = cell111->node;\
  217. \
  218. while (top_node111 != HASH_GET_NEXT(NAME, node111)) {\
  219. \
  220. node111 = HASH_GET_NEXT(NAME, node111);\
  221. }\
  222. \
  223. /* Now we have the predecessor node */\
  224. \
  225. node111->NAME = NODE;\
  226. }\
  227. }\
  228. \
  229. /* Free the space occupied by the top node */\
  230. \
  231. mem_heap_free_top(hash_get_heap(TABLE, fold111), sizeof(TYPE));\
  232. } while (0)
  233. /********************************************************************
  234. Move all hash table entries from OLD_TABLE to NEW_TABLE.*/
  235. #define HASH_MIGRATE(OLD_TABLE, NEW_TABLE, NODE_TYPE, PTR_NAME, FOLD_FUNC) \
  236. do {\
  237. ulint i2222;\
  238. ulint cell_count2222;\
  239. \
  240. cell_count2222 = hash_get_n_cells(OLD_TABLE);\
  241. \
  242. for (i2222 = 0; i2222 < cell_count2222; i2222++) {\
  243. NODE_TYPE* node2222 = HASH_GET_FIRST((OLD_TABLE), i2222);\
  244. \
  245. while (node2222) {\
  246. NODE_TYPE* next2222 = node2222->PTR_NAME;\
  247. ulint fold2222 = FOLD_FUNC(node2222);\
  248. \
  249. HASH_INSERT(NODE_TYPE, PTR_NAME, (NEW_TABLE),\
  250. fold2222, node2222);\
  251. \
  252. node2222 = next2222;\
  253. }\
  254. }\
  255. } while (0)
  256. /****************************************************************
  257. Gets the mutex index for a fold value in a hash table. */
  258. UNIV_INLINE
  259. ulint
  260. hash_get_mutex_no(
  261. /*==============*/
  262. /* out: mutex number */
  263. hash_table_t* table, /* in: hash table */
  264. ulint fold); /* in: fold */
  265. /****************************************************************
  266. Gets the nth heap in a hash table. */
  267. UNIV_INLINE
  268. mem_heap_t*
  269. hash_get_nth_heap(
  270. /*==============*/
  271. /* out: mem heap */
  272. hash_table_t* table, /* in: hash table */
  273. ulint i); /* in: index of the heap */
  274. /****************************************************************
  275. Gets the heap for a fold value in a hash table. */
  276. UNIV_INLINE
  277. mem_heap_t*
  278. hash_get_heap(
  279. /*==========*/
  280. /* out: mem heap */
  281. hash_table_t* table, /* in: hash table */
  282. ulint fold); /* in: fold */
  283. /****************************************************************
  284. Gets the nth mutex in a hash table. */
  285. UNIV_INLINE
  286. mutex_t*
  287. hash_get_nth_mutex(
  288. /*===============*/
  289. /* out: mutex */
  290. hash_table_t* table, /* in: hash table */
  291. ulint i); /* in: index of the mutex */
  292. /****************************************************************
  293. Gets the mutex for a fold value in a hash table. */
  294. UNIV_INLINE
  295. mutex_t*
  296. hash_get_mutex(
  297. /*===========*/
  298. /* out: mutex */
  299. hash_table_t* table, /* in: hash table */
  300. ulint fold); /* in: fold */
  301. /****************************************************************
  302. Reserves the mutex for a fold value in a hash table. */
  303. UNIV_INTERN
  304. void
  305. hash_mutex_enter(
  306. /*=============*/
  307. hash_table_t* table, /* in: hash table */
  308. ulint fold); /* in: fold */
  309. /****************************************************************
  310. Releases the mutex for a fold value in a hash table. */
  311. UNIV_INTERN
  312. void
  313. hash_mutex_exit(
  314. /*============*/
  315. hash_table_t* table, /* in: hash table */
  316. ulint fold); /* in: fold */
  317. /****************************************************************
  318. Reserves all the mutexes of a hash table, in an ascending order. */
  319. UNIV_INTERN
  320. void
  321. hash_mutex_enter_all(
  322. /*=================*/
  323. hash_table_t* table); /* in: hash table */
  324. /****************************************************************
  325. Releases all the mutexes of a hash table. */
  326. UNIV_INTERN
  327. void
  328. hash_mutex_exit_all(
  329. /*================*/
  330. hash_table_t* table); /* in: hash table */
  331. struct hash_cell_struct{
  332. void* node; /* hash chain node, NULL if none */
  333. };
  334. /* The hash table structure */
  335. struct hash_table_struct {
  336. #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
  337. ibool adaptive;/* TRUE if this is the hash table of the
  338. adaptive hash index */
  339. #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
  340. ulint n_cells;/* number of cells in the hash table */
  341. hash_cell_t* array; /* pointer to cell array */
  342. ulint n_mutexes;/* if mutexes != NULL, then the number of
  343. mutexes, must be a power of 2 */
  344. mutex_t* mutexes;/* NULL, or an array of mutexes used to
  345. protect segments of the hash table */
  346. mem_heap_t** heaps; /* if this is non-NULL, hash chain nodes for
  347. external chaining can be allocated from these
  348. memory heaps; there are then n_mutexes many of
  349. these heaps */
  350. mem_heap_t* heap;
  351. ulint magic_n;
  352. };
  353. #define HASH_TABLE_MAGIC_N 76561114
  354. #ifndef UNIV_NONINL
  355. #include "hash0hash.ic"
  356. #endif
  357. #endif