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