Commit b0ab8786 authored by marko's avatar marko

branches/zip: Introduce UNIV_AHI_DEBUG for debugging the adaptive hash

index without enabling UNIV_DEBUG.
parent fc249aa5
2008-12-17 The InnoDB Team
* include/univ.i, include/buf0buf.h, include/hash0hash.h,
include/ha0ha.h, include/ha0ha.ic, ha/ha0ha.c, ha/hash0hash.c,
btr/btr0sea.c, buf/buf0lru.c, buf/buf0buf.c:
Introduce the preprocessor symbol UNIV_AHI_DEBUG for enabling
adaptive hash index debugging independently of UNIV_DEBUG.
2008-12-02 The InnoDB Team
* row/row0merge.c:
......
......@@ -1102,7 +1102,7 @@ next_rec:
block->index = NULL;
cleanup:
#ifdef UNIV_DEBUG
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
if (UNIV_UNLIKELY(block->n_pointers)) {
/* Corruption */
ut_print_timestamp(stderr);
......@@ -1118,9 +1118,9 @@ cleanup:
} else {
rw_lock_x_unlock(&btr_search_latch);
}
#else /* UNIV_DEBUG */
#else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
rw_lock_x_unlock(&btr_search_latch);
#endif /* UNIV_DEBUG */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
mem_free(folds);
}
......
......@@ -658,8 +658,10 @@ buf_block_init(
block->page.in_free_list = FALSE;
block->page.in_LRU_list = FALSE;
block->in_unzip_LRU_list = FALSE;
block->n_pointers = 0;
#endif /* UNIV_DEBUG */
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
block->n_pointers = 0;
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
page_zip_des_init(&block->page.zip);
mutex_create(&block->mutex, SYNC_BUF_BLOCK);
......
......@@ -1569,7 +1569,9 @@ buf_LRU_block_free_non_file_page(
ut_error;
}
ut_ad(block->n_pointers == 0);
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
ut_a(block->n_pointers == 0);
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
ut_ad(!block->page.in_free_list);
ut_ad(!block->page.in_flush_list);
ut_ad(!block->page.in_LRU_list);
......
......@@ -40,9 +40,9 @@ ha_create_func(
table = hash_create(n);
#ifdef UNIV_DEBUG
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
table->adaptive = TRUE;
#endif /* UNIV_DEBUG */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
/* Creating MEM_HEAP_BTR_SEARCH type heaps can potentially fail,
but in practise it never should in this case, hence the asserts. */
......@@ -111,9 +111,9 @@ ha_insert_for_fold_func(
the same fold value already exists, it is
updated to point to the same data, and no new
node is created! */
#ifdef UNIV_DEBUG
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* block, /* in: buffer block containing the data */
#endif /* UNIV_DEBUG */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* data) /* in: data, must not be NULL */
{
hash_cell_t* cell;
......@@ -122,7 +122,9 @@ ha_insert_for_fold_func(
ulint hash;
ut_ad(table && data);
ut_ad(block->frame == page_align(data));
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
ut_a(block->frame == page_align(data));
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold)));
hash = hash_calc_hash(fold, table);
......@@ -133,7 +135,7 @@ ha_insert_for_fold_func(
while (prev_node != NULL) {
if (prev_node->fold == fold) {
#ifdef UNIV_DEBUG
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
if (table->adaptive) {
buf_block_t* prev_block = prev_node->block;
ut_a(prev_block->frame
......@@ -144,7 +146,7 @@ ha_insert_for_fold_func(
}
prev_node->block = block;
#endif /* UNIV_DEBUG */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
prev_node->data = data;
return(TRUE);
......@@ -168,11 +170,11 @@ ha_insert_for_fold_func(
ha_node_set_data(node, block, data);
#ifdef UNIV_DEBUG
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
if (table->adaptive) {
block->n_pointers++;
}
#endif /* UNIV_DEBUG */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
node->fold = fold;
node->next = NULL;
......@@ -205,13 +207,13 @@ 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 defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
if (table->adaptive) {
ut_a(del_node->block->frame = page_align(del_node->data));
ut_a(del_node->block->n_pointers > 0);
del_node->block->n_pointers--;
}
#endif /* UNIV_DEBUG */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
HASH_DELETE_AND_COMPACT(ha_node_t, next, table, del_node);
}
......@@ -247,20 +249,22 @@ ha_search_and_update_if_found_func(
hash_table_t* table, /* in: hash table */
ulint fold, /* in: folded value of the searched data */
void* data, /* in: pointer to the data */
#ifdef UNIV_DEBUG
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* new_block,/* in: block containing new_data */
#endif
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* new_data)/* in: new pointer to the data */
{
ha_node_t* node;
ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold)));
ut_ad(new_block->frame == page_align(new_data));
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
ut_a(new_block->frame == page_align(new_data));
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
node = ha_search_with_data(table, fold, data);
if (node) {
#ifdef UNIV_DEBUG
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
if (table->adaptive) {
ut_a(node->block->n_pointers > 0);
node->block->n_pointers--;
......@@ -268,7 +272,7 @@ ha_search_and_update_if_found_func(
}
node->block = new_block;
#endif /* UNIV_DEBUG */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
node->data = new_data;
}
}
......
......@@ -89,9 +89,9 @@ hash_create(
array = ut_malloc(sizeof(hash_cell_t) * prime);
#ifdef UNIV_DEBUG
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
table->adaptive = FALSE;
#endif /* UNIV_DEBUG */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
table->array = array;
table->n_cells = prime;
table->n_mutexes = 0;
......
......@@ -1162,11 +1162,11 @@ struct buf_block_struct{
An exception to this is when we init or create a page
in the buffer pool in buf0buf.c. */
#ifdef UNIV_DEBUG
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
ulint n_pointers; /* used in debugging: the number of
pointers in the adaptive hash index
pointing to this frame */
#endif /* UNIV_DEBUG */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
unsigned is_hashed:1; /* TRUE if hash index has already been
built on this page; note that it does
not guarantee that the index is
......
......@@ -36,18 +36,18 @@ ha_search_and_update_if_found_func(
hash_table_t* table, /* in: hash table */
ulint fold, /* in: folded value of the searched data */
void* data, /* in: pointer to the data */
#ifdef UNIV_DEBUG
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* new_block,/* in: block containing new_data */
#endif
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* new_data);/* in: new pointer to the data */
#ifdef UNIV_DEBUG
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
# define ha_search_and_update_if_found(table,fold,data,new_block,new_data) \
ha_search_and_update_if_found_func(table,fold,data,new_block,new_data)
#else
#else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
# define ha_search_and_update_if_found(table,fold,data,new_block,new_data) \
ha_search_and_update_if_found_func(table,fold,data,new_data)
#endif
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
/*****************************************************************
Creates a hash table with >= n array cells. The actual number of cells is
chosen to be a prime number slightly bigger than n. */
......@@ -92,16 +92,16 @@ ha_insert_for_fold_func(
the same fold value already exists, it is
updated to point to the same data, and no new
node is created! */
#ifdef UNIV_DEBUG
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* block, /* in: buffer block containing the data */
#endif /* UNIV_DEBUG */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* data); /* in: data, must not be NULL */
#ifdef UNIV_DEBUG
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
# define ha_insert_for_fold(t,f,b,d) ha_insert_for_fold_func(t,f,b,d)
#else
#else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
# define ha_insert_for_fold(t,f,b,d) ha_insert_for_fold_func(t,f,d)
#endif
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
/*****************************************************************
Deletes an entry from a hash table. */
......@@ -158,9 +158,9 @@ ha_print_info(
typedef struct ha_node_struct ha_node_t;
struct ha_node_struct {
ha_node_t* next; /* next chain node or NULL if none */
#ifdef UNIV_DEBUG
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* block; /* buffer block containing the data, or NULL */
#endif /* UNIV_DEBUG */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* data; /* pointer to the data */
ulint fold; /* fold value for the data */
};
......
......@@ -37,22 +37,22 @@ void
ha_node_set_data_func(
/*==================*/
ha_node_t* node, /* in: hash chain node */
#ifdef UNIV_DEBUG
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
buf_block_t* block, /* in: buffer block containing the data */
#endif /* UNIV_DEBUG */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
void* data) /* in: pointer to the data */
{
#ifdef UNIV_DEBUG
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
node->block = block;
#endif /* UNIV_DEBUG */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
node->data = data;
}
#ifdef UNIV_DEBUG
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
# define ha_node_set_data(n,b,d) ha_node_set_data_func(n,b,d)
#else /* UNIV_DEBUG */
#else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
# define ha_node_set_data(n,b,d) ha_node_set_data_func(n,d)
#endif /* UNIV_DEBUG */
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
/**********************************************************************
Gets the next node in a hash chain. */
......
......@@ -363,10 +363,10 @@ struct hash_cell_struct{
/* The hash table structure */
struct hash_table_struct {
#ifdef UNIV_DEBUG
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
ibool adaptive;/* TRUE if this is the hash table of the
adaptive hash index */
#endif /* UNIV_DEBUG */
#endif /* UNIV_AHI_DEBUG || 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
......
......@@ -130,6 +130,8 @@ command. Not tested on Windows. */
Valgrind instrumentation */
#define UNIV_DEBUG_PRINT /* Enable the compilation of
some debug print functions */
#define UNIV_AHI_DEBUG /* Enable adaptive hash index
debugging without UNIV_DEBUG */
#define UNIV_BUF_DEBUG /* Enable buffer pool
debugging without UNIV_DEBUG */
#define UNIV_DEBUG /* Enable ut_ad() assertions
......
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