Commit f8b30472 authored by marko's avatar marko

branches/zip: ha_create(): Remove parameter in_btr_search, which was

passed as TRUE.

Enclose hash_table_t::adaptive and buf_block_t::n_pointers in
#ifdef UNIV_DEBUG.

btr_search_drop_page_hash_index(): Enclose the corruption check
(which depends on buf_block_t::n_pointers) in #ifdef UNIV_DEBUG.
parent 120e544d
...@@ -139,7 +139,7 @@ btr_search_sys_create( ...@@ -139,7 +139,7 @@ btr_search_sys_create(
btr_search_sys = mem_alloc(sizeof(btr_search_sys_t)); btr_search_sys = mem_alloc(sizeof(btr_search_sys_t));
btr_search_sys->hash_index = ha_create(TRUE, hash_size, 0, 0); btr_search_sys->hash_index = ha_create(hash_size, 0, 0);
} }
...@@ -1025,6 +1025,7 @@ next_rec: ...@@ -1025,6 +1025,7 @@ next_rec:
block->is_hashed = FALSE; block->is_hashed = FALSE;
block->index = NULL; block->index = NULL;
cleanup: cleanup:
#ifdef UNIV_DEBUG
if (UNIV_UNLIKELY(block->n_pointers)) { if (UNIV_UNLIKELY(block->n_pointers)) {
/* Corruption */ /* Corruption */
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
...@@ -1040,6 +1041,9 @@ cleanup: ...@@ -1040,6 +1041,9 @@ cleanup:
} else { } else {
rw_lock_x_unlock(&btr_search_latch); rw_lock_x_unlock(&btr_search_latch);
} }
#else /* UNIV_DEBUG */
rw_lock_x_unlock(&btr_search_latch);
#endif /* UNIV_DEBUG */
mem_free(folds); mem_free(folds);
} }
......
...@@ -632,8 +632,9 @@ buf_block_init( ...@@ -632,8 +632,9 @@ buf_block_init(
block->in_free_list = FALSE; block->in_free_list = FALSE;
block->in_LRU_list = FALSE; block->in_LRU_list = FALSE;
#ifdef UNIV_DEBUG
block->n_pointers = 0; block->n_pointers = 0;
#endif /* UNIV_DEBUG */
page_zip_des_init(&block->page_zip); page_zip_des_init(&block->page_zip);
rw_lock_create(&block->lock, SYNC_LEVEL_VARYING); rw_lock_create(&block->lock, SYNC_LEVEL_VARYING);
......
...@@ -864,7 +864,7 @@ buf_LRU_block_free_non_file_page( ...@@ -864,7 +864,7 @@ buf_LRU_block_free_non_file_page(
ut_a((block->state == BUF_BLOCK_MEMORY) ut_a((block->state == BUF_BLOCK_MEMORY)
|| (block->state == BUF_BLOCK_READY_FOR_USE)); || (block->state == BUF_BLOCK_READY_FOR_USE));
ut_a(block->n_pointers == 0); ut_ad(block->n_pointers == 0);
ut_a(!block->in_free_list); ut_a(!block->in_free_list);
block->state = BUF_BLOCK_NOT_USED; block->state = BUF_BLOCK_NOT_USED;
......
...@@ -11,7 +11,9 @@ Created 8/22/1994 Heikki Tuuri ...@@ -11,7 +11,9 @@ Created 8/22/1994 Heikki Tuuri
#include "ha0ha.ic" #include "ha0ha.ic"
#endif #endif
#include "buf0buf.h" #ifdef UNIV_DEBUG
# include "buf0buf.h"
#endif /* UNIV_DEBUG */
#include "page0page.h" #include "page0page.h"
/***************************************************************** /*****************************************************************
...@@ -22,8 +24,6 @@ hash_table_t* ...@@ -22,8 +24,6 @@ hash_table_t*
ha_create( ha_create(
/*======*/ /*======*/
/* out, own: created table */ /* out, own: created table */
ibool in_btr_search, /* in: TRUE if the hash table is used in
the btr_search module */
ulint n, /* in: number of array cells */ ulint n, /* in: number of array cells */
ulint n_mutexes, /* in: number of mutexes to protect the ulint n_mutexes, /* in: number of mutexes to protect the
hash table: must be a power of 2, or 0 */ hash table: must be a power of 2, or 0 */
...@@ -35,22 +35,15 @@ ha_create( ...@@ -35,22 +35,15 @@ ha_create(
table = hash_create(n); table = hash_create(n);
if (in_btr_search) { #ifdef UNIV_DEBUG
table->adaptive = TRUE; table->adaptive = TRUE;
} else { #endif /* UNIV_DEBUG */
table->adaptive = FALSE;
}
/* Creating MEM_HEAP_BTR_SEARCH type heaps can potentially fail, /* Creating MEM_HEAP_BTR_SEARCH type heaps can potentially fail,
but in practise it never should in this case, hence the asserts. */ but in practise it never should in this case, hence the asserts. */
if (n_mutexes == 0) { if (n_mutexes == 0) {
if (in_btr_search) { table->heap = mem_heap_create_in_btr_search(4096);
table->heap = mem_heap_create_in_btr_search(4096); ut_a(table->heap);
ut_a(table->heap);
} else {
table->heap = mem_heap_create_in_buffer(4096);
}
return(table); return(table);
} }
...@@ -60,12 +53,8 @@ ha_create( ...@@ -60,12 +53,8 @@ ha_create(
table->heaps = mem_alloc(n_mutexes * sizeof(void*)); table->heaps = mem_alloc(n_mutexes * sizeof(void*));
for (i = 0; i < n_mutexes; i++) { for (i = 0; i < n_mutexes; i++) {
if (in_btr_search) { table->heaps[i] = mem_heap_create_in_btr_search(4096);
table->heaps[i] = mem_heap_create_in_btr_search(4096); ut_a(table->heaps[i]);
ut_a(table->heaps[i]);
} else {
table->heaps[i] = mem_heap_create_in_buffer(4096);
}
} }
return(table); return(table);
...@@ -91,7 +80,9 @@ ha_insert_for_fold( ...@@ -91,7 +80,9 @@ ha_insert_for_fold(
hash_cell_t* cell; hash_cell_t* cell;
ha_node_t* node; ha_node_t* node;
ha_node_t* prev_node; ha_node_t* prev_node;
#ifdef UNIV_DEBUG
buf_block_t* prev_block; buf_block_t* prev_block;
#endif /* UNIV_DEBUG */
ulint hash; ulint hash;
ut_ad(table && data); ut_ad(table && data);
...@@ -106,13 +97,14 @@ ha_insert_for_fold( ...@@ -106,13 +97,14 @@ ha_insert_for_fold(
while (prev_node != NULL) { while (prev_node != NULL) {
if (prev_node->fold == fold) { if (prev_node->fold == fold) {
#ifdef UNIV_DEBUG
if (table->adaptive) { if (table->adaptive) {
prev_block = buf_block_align(prev_node->data); prev_block = buf_block_align(prev_node->data);
ut_a(prev_block->n_pointers > 0); ut_a(prev_block->n_pointers > 0);
prev_block->n_pointers--; prev_block->n_pointers--;
buf_block_align(data)->n_pointers++; buf_block_align(data)->n_pointers++;
} }
#endif /* UNIV_DEBUG */
prev_node->data = data; prev_node->data = data;
return(TRUE); return(TRUE);
...@@ -136,10 +128,11 @@ ha_insert_for_fold( ...@@ -136,10 +128,11 @@ ha_insert_for_fold(
ha_node_set_data(node, data); ha_node_set_data(node, data);
#ifdef UNIV_DEBUG
if (table->adaptive) { if (table->adaptive) {
buf_block_align(data)->n_pointers++; buf_block_align(data)->n_pointers++;
} }
#endif /* UNIV_DEBUG */
node->fold = fold; node->fold = fold;
node->next = NULL; node->next = NULL;
...@@ -172,11 +165,12 @@ ha_delete_hash_node( ...@@ -172,11 +165,12 @@ ha_delete_hash_node(
hash_table_t* table, /* in: hash table */ hash_table_t* table, /* in: hash table */
ha_node_t* del_node) /* in: node to be deleted */ ha_node_t* del_node) /* in: node to be deleted */
{ {
#ifdef UNIV_DEBUG
if (table->adaptive) { if (table->adaptive) {
ut_a(buf_block_align(del_node->data)->n_pointers > 0); ut_a(buf_block_align(del_node->data)->n_pointers > 0);
buf_block_align(del_node->data)->n_pointers--; buf_block_align(del_node->data)->n_pointers--;
} }
#endif /* UNIV_DEBUG */
HASH_DELETE_AND_COMPACT(ha_node_t, next, table, del_node); HASH_DELETE_AND_COMPACT(ha_node_t, next, table, del_node);
} }
...@@ -224,12 +218,13 @@ ha_search_and_update_if_found( ...@@ -224,12 +218,13 @@ ha_search_and_update_if_found(
node = ha_search_with_data(table, fold, data); node = ha_search_with_data(table, fold, data);
if (node) { if (node) {
#ifdef UNIV_DEBUG
if (table->adaptive) { if (table->adaptive) {
ut_a(buf_block_align(node->data)->n_pointers > 0); ut_a(buf_block_align(node->data)->n_pointers > 0);
buf_block_align(node->data)->n_pointers--; buf_block_align(node->data)->n_pointers--;
buf_block_align(new_data)->n_pointers++; buf_block_align(new_data)->n_pointers++;
} }
#endif /* UNIV_DEBUG */
node->data = new_data; node->data = new_data;
} }
} }
......
...@@ -91,7 +91,9 @@ hash_create( ...@@ -91,7 +91,9 @@ hash_create(
array = ut_malloc(sizeof(hash_cell_t) * prime); array = ut_malloc(sizeof(hash_cell_t) * prime);
#ifdef UNIV_DEBUG
table->adaptive = FALSE; table->adaptive = FALSE;
#endif /* UNIV_DEBUG */
table->array = array; table->array = array;
table->n_cells = prime; table->n_cells = prime;
table->n_mutexes = 0; table->n_mutexes = 0;
......
...@@ -855,9 +855,11 @@ struct buf_block_struct{ ...@@ -855,9 +855,11 @@ struct buf_block_struct{
complete, though: there may have been complete, though: there may have been
hash collisions, record deletions, hash collisions, record deletions,
etc. */ etc. */
#ifdef UNIV_DEBUG
ulint n_pointers; /* used in debugging: the number of ulint n_pointers; /* used in debugging: the number of
pointers in the adaptive hash index pointers in the adaptive hash index
pointing to this frame */ pointing to this frame */
#endif /* UNIV_DEBUG */
ulint curr_n_fields; /* prefix length for hash indexing: ulint curr_n_fields; /* prefix length for hash indexing:
number of full fields */ number of full fields */
ulint curr_n_bytes; /* number of bytes in hash indexing */ ulint curr_n_bytes; /* number of bytes in hash indexing */
......
...@@ -44,8 +44,6 @@ hash_table_t* ...@@ -44,8 +44,6 @@ hash_table_t*
ha_create( ha_create(
/*======*/ /*======*/
/* out, own: created table */ /* out, own: created table */
ibool in_btr_search, /* in: TRUE if the hash table is used in
the btr_search module */
ulint n, /* in: number of array cells */ ulint n, /* in: number of array cells */
ulint n_mutexes, /* in: number of mutexes to protect the ulint n_mutexes, /* in: number of mutexes to protect the
hash table: must be a power of 2 */ hash table: must be a power of 2 */
......
...@@ -331,8 +331,10 @@ struct hash_cell_struct{ ...@@ -331,8 +331,10 @@ struct hash_cell_struct{
/* The hash table structure */ /* The hash table structure */
struct hash_table_struct { struct hash_table_struct {
#ifdef UNIV_DEBUG
ibool adaptive;/* TRUE if this is the hash table of the ibool adaptive;/* TRUE if this is the hash table of the
adaptive hash index */ adaptive hash index */
#endif /* UNIV_DEBUG */
ulint n_cells;/* number of cells in the hash table */ ulint n_cells;/* number of cells in the hash table */
hash_cell_t* array; /* pointer to cell array */ hash_cell_t* array; /* pointer to cell array */
ulint n_mutexes;/* if mutexes != NULL, then the number of ulint n_mutexes;/* if mutexes != NULL, then the number of
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment