Commit 7696b8dd authored by marko's avatar marko

Remove dict_tree_t, which should have been removed in r453.

There always was a one-to-one mapping between dict_tree_t and dict_index_t.

This saves 6 machine words per B-tree index in the data dictionary
cache plus the memory allocation overhead.  We save one mem_heap_t
object per index (15 machine words).  Considering the internal
fragmentation of the buddy allocator in mem_area_alloc(), this should
save 32 machine words per index (128 bytes on 32-bit systems and 256
bytes on 64-bit systems).  (Bug #20877)

struct dict_tree_struct, dict_tree_t: Remove.

struct dict_index_struct: Add page and lock.

dict_tree_create(): Remove.  Replace the invocation with
assignment to index->page and a call to rw_lock_create(&index->lock).

dict_tree_free(): Remove.  Replace the invocation wtih
a call to rw_lock_free(&index->lock).

dict_index_get_tree(): Remove.

dict_tree_get_space_reserve(): Rename to dict_index_get_space_reserve()
and remove the parameter, which was unused.

btr_level_list_remove(): Remove the unused parameter "tree".

Replace the occurrences of "tree" with "index" in names of variables,
functions and data types, e.g. "dict_tree_t tree" becomes
"dict_index_t index".  Remove local variables "tree" or "index" of
functions that needed both "tree" and "index".
parent b00733ad
This diff is collapsed.
This diff is collapsed.
...@@ -76,14 +76,14 @@ btr_pcur_store_position( ...@@ -76,14 +76,14 @@ btr_pcur_store_position(
{ {
page_cur_t* page_cursor; page_cur_t* page_cursor;
rec_t* rec; rec_t* rec;
dict_tree_t* tree; dict_index_t* index;
page_t* page; page_t* page;
ulint offs; ulint offs;
ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
tree = btr_cur_get_tree(btr_pcur_get_btr_cur(cursor)); index = btr_cur_get_index(btr_pcur_get_btr_cur(cursor));
page_cursor = btr_pcur_get_page_cur(cursor); page_cursor = btr_pcur_get_page_cur(cursor);
...@@ -133,8 +133,8 @@ btr_pcur_store_position( ...@@ -133,8 +133,8 @@ btr_pcur_store_position(
} }
cursor->old_stored = BTR_PCUR_OLD_STORED; cursor->old_stored = BTR_PCUR_OLD_STORED;
cursor->old_rec = dict_tree_copy_rec_order_prefix cursor->old_rec = dict_index_copy_rec_order_prefix
(tree, rec, &cursor->old_n_fields, (index, rec, &cursor->old_n_fields,
&cursor->old_rec_buf, &cursor->buf_size); &cursor->old_rec_buf, &cursor->buf_size);
cursor->block_when_stored = buf_block_align(page); cursor->block_when_stored = buf_block_align(page);
...@@ -197,13 +197,15 @@ btr_pcur_restore_position( ...@@ -197,13 +197,15 @@ btr_pcur_restore_position(
btr_pcur_t* cursor, /* in: detached persistent cursor */ btr_pcur_t* cursor, /* in: detached persistent cursor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
dict_tree_t* tree; dict_index_t* index;
page_t* page; page_t* page;
dtuple_t* tuple; dtuple_t* tuple;
ulint mode; ulint mode;
ulint old_mode; ulint old_mode;
mem_heap_t* heap; mem_heap_t* heap;
index = btr_cur_get_index(btr_pcur_get_btr_cur(cursor));
if (UNIV_UNLIKELY(cursor->old_stored != BTR_PCUR_OLD_STORED) if (UNIV_UNLIKELY(cursor->old_stored != BTR_PCUR_OLD_STORED)
|| UNIV_UNLIKELY(cursor->pos_state != BTR_PCUR_WAS_POSITIONED || UNIV_UNLIKELY(cursor->pos_state != BTR_PCUR_WAS_POSITIONED
&& cursor->pos_state != BTR_PCUR_IS_POSITIONED)) { && cursor->pos_state != BTR_PCUR_IS_POSITIONED)) {
...@@ -224,8 +226,7 @@ btr_pcur_restore_position( ...@@ -224,8 +226,7 @@ btr_pcur_restore_position(
btr_cur_open_at_index_side btr_cur_open_at_index_side
(cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE, (cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE,
btr_pcur_get_btr_cur(cursor)->index, latch_mode, index, latch_mode, btr_pcur_get_btr_cur(cursor), mtr);
btr_pcur_get_btr_cur(cursor), mtr);
cursor->block_when_stored cursor->block_when_stored
= buf_block_align(btr_pcur_get_page(cursor)); = buf_block_align(btr_pcur_get_page(cursor));
...@@ -255,12 +256,10 @@ btr_pcur_restore_position( ...@@ -255,12 +256,10 @@ btr_pcur_restore_position(
rec_t* rec; rec_t* rec;
ulint* offsets1; ulint* offsets1;
ulint* offsets2; ulint* offsets2;
dict_index_t* index;
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
cursor->latch_mode = latch_mode; cursor->latch_mode = latch_mode;
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
rec = btr_pcur_get_rec(cursor); rec = btr_pcur_get_rec(cursor);
index = btr_pcur_get_btr_cur(cursor)->index;
heap = mem_heap_create(256); heap = mem_heap_create(256);
offsets1 = rec_get_offsets offsets1 = rec_get_offsets
...@@ -286,9 +285,8 @@ btr_pcur_restore_position( ...@@ -286,9 +285,8 @@ btr_pcur_restore_position(
heap = mem_heap_create(256); heap = mem_heap_create(256);
tree = btr_cur_get_tree(btr_pcur_get_btr_cur(cursor)); tuple = dict_index_build_data_tuple(index, cursor->old_rec,
tuple = dict_tree_build_data_tuple(tree, cursor->old_rec, cursor->old_n_fields, heap);
cursor->old_n_fields, heap);
/* Save the old search mode of the cursor */ /* Save the old search mode of the cursor */
old_mode = cursor->search_mode; old_mode = cursor->search_mode;
...@@ -302,8 +300,8 @@ btr_pcur_restore_position( ...@@ -302,8 +300,8 @@ btr_pcur_restore_position(
mode = PAGE_CUR_L; mode = PAGE_CUR_L;
} }
btr_pcur_open_with_no_init(btr_pcur_get_btr_cur(cursor)->index, tuple, btr_pcur_open_with_no_init(index, tuple, mode, latch_mode,
mode, latch_mode, cursor, 0, mtr); cursor, 0, mtr);
/* Restore the old search mode */ /* Restore the old search mode */
cursor->search_mode = old_mode; cursor->search_mode = old_mode;
...@@ -312,8 +310,7 @@ btr_pcur_restore_position( ...@@ -312,8 +310,7 @@ btr_pcur_restore_position(
&& btr_pcur_is_on_user_rec(cursor, mtr) && btr_pcur_is_on_user_rec(cursor, mtr)
&& 0 == cmp_dtuple_rec(tuple, btr_pcur_get_rec(cursor), && 0 == cmp_dtuple_rec(tuple, btr_pcur_get_rec(cursor),
rec_get_offsets rec_get_offsets
(btr_pcur_get_rec(cursor), (btr_pcur_get_rec(cursor), index,
btr_pcur_get_btr_cur(cursor)->index,
NULL, ULINT_UNDEFINED, &heap))) { NULL, ULINT_UNDEFINED, &heap))) {
/* We have to store the NEW value for the modify clock, since /* We have to store the NEW value for the modify clock, since
......
...@@ -401,7 +401,7 @@ btr_search_update_hash_ref( ...@@ -401,7 +401,7 @@ btr_search_update_hash_ref(
{ {
ulint fold; ulint fold;
rec_t* rec; rec_t* rec;
dulint tree_id; dulint index_id;
ut_ad(cursor->flag == BTR_CUR_HASH_FAIL); ut_ad(cursor->flag == BTR_CUR_HASH_FAIL);
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
...@@ -428,12 +428,12 @@ btr_search_update_hash_ref( ...@@ -428,12 +428,12 @@ btr_search_update_hash_ref(
return; return;
} }
tree_id = ((cursor->index)->tree)->id; index_id = cursor->index->id;
fold = rec_fold(rec, fold = rec_fold(rec,
rec_get_offsets(rec, cursor->index, offsets_, rec_get_offsets(rec, cursor->index, offsets_,
ULINT_UNDEFINED, &heap), ULINT_UNDEFINED, &heap),
block->curr_n_fields, block->curr_n_fields,
block->curr_n_bytes, tree_id); block->curr_n_bytes, index_id);
if (UNIV_LIKELY_NULL(heap)) { if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap); mem_heap_free(heap);
} }
...@@ -699,7 +699,7 @@ btr_search_guess_on_hash( ...@@ -699,7 +699,7 @@ btr_search_guess_on_hash(
page_t* page; page_t* page;
ulint fold; ulint fold;
ulint tuple_n_fields; ulint tuple_n_fields;
dulint tree_id; dulint index_id;
ibool can_only_compare_to_cursor_rec = TRUE; ibool can_only_compare_to_cursor_rec = TRUE;
#ifdef notdefined #ifdef notdefined
btr_cur_t cursor2; btr_cur_t cursor2;
...@@ -733,12 +733,12 @@ btr_search_guess_on_hash( ...@@ -733,12 +733,12 @@ btr_search_guess_on_hash(
return(FALSE); return(FALSE);
} }
tree_id = (index->tree)->id; index_id = index->id;
#ifdef UNIV_SEARCH_PERF_STAT #ifdef UNIV_SEARCH_PERF_STAT
info->n_hash_succ++; info->n_hash_succ++;
#endif #endif
fold = dtuple_fold(tuple, cursor->n_fields, cursor->n_bytes, tree_id); fold = dtuple_fold(tuple, cursor->n_fields, cursor->n_bytes, index_id);
cursor->fold = fold; cursor->fold = fold;
cursor->flag = BTR_CUR_HASH; cursor->flag = BTR_CUR_HASH;
...@@ -798,7 +798,8 @@ btr_search_guess_on_hash( ...@@ -798,7 +798,8 @@ btr_search_guess_on_hash(
is positioned on. We cannot look at the next of the previous is positioned on. We cannot look at the next of the previous
record to determine if our guess for the cursor position is record to determine if our guess for the cursor position is
right. */ right. */
if (UNIV_EXPECT(ut_dulint_cmp(tree_id, btr_page_get_index_id(page)), 0) if (UNIV_EXPECT
(ut_dulint_cmp(index_id, btr_page_get_index_id(page)), 0)
|| !btr_search_check_guess(cursor, || !btr_search_check_guess(cursor,
can_only_compare_to_cursor_rec, can_only_compare_to_cursor_rec,
tuple, mode, mtr)) { tuple, mode, mtr)) {
...@@ -901,7 +902,7 @@ btr_search_drop_page_hash_index( ...@@ -901,7 +902,7 @@ btr_search_drop_page_hash_index(
rec_t* rec; rec_t* rec;
ulint fold; ulint fold;
ulint prev_fold; ulint prev_fold;
dulint tree_id; dulint index_id;
ulint n_cached; ulint n_cached;
ulint n_recs; ulint n_recs;
ulint* folds; ulint* folds;
...@@ -958,9 +959,9 @@ btr_search_drop_page_hash_index( ...@@ -958,9 +959,9 @@ btr_search_drop_page_hash_index(
rec = page_get_infimum_rec(page); rec = page_get_infimum_rec(page);
rec = page_rec_get_next(rec); rec = page_rec_get_next(rec);
tree_id = btr_page_get_index_id(page); index_id = btr_page_get_index_id(page);
ut_a(0 == ut_dulint_cmp(tree_id, index->id)); ut_a(0 == ut_dulint_cmp(index_id, index->id));
prev_fold = 0; prev_fold = 0;
...@@ -971,7 +972,7 @@ btr_search_drop_page_hash_index( ...@@ -971,7 +972,7 @@ btr_search_drop_page_hash_index(
offsets = rec_get_offsets(rec, index, offsets, offsets = rec_get_offsets(rec, index, offsets,
n_fields + (n_bytes > 0), &heap); n_fields + (n_bytes > 0), &heap);
ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0)); ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0));
fold = rec_fold(rec, offsets, n_fields, n_bytes, tree_id); fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id);
if (fold == prev_fold && prev_fold != 0) { if (fold == prev_fold && prev_fold != 0) {
...@@ -1104,7 +1105,7 @@ btr_search_build_page_hash_index( ...@@ -1104,7 +1105,7 @@ btr_search_build_page_hash_index(
rec_t* next_rec; rec_t* next_rec;
ulint fold; ulint fold;
ulint next_fold; ulint next_fold;
dulint tree_id; dulint index_id;
ulint n_cached; ulint n_cached;
ulint n_recs; ulint n_recs;
ulint* folds; ulint* folds;
...@@ -1167,7 +1168,7 @@ btr_search_build_page_hash_index( ...@@ -1167,7 +1168,7 @@ btr_search_build_page_hash_index(
n_cached = 0; n_cached = 0;
tree_id = btr_page_get_index_id(page); index_id = btr_page_get_index_id(page);
rec = page_get_infimum_rec(page); rec = page_get_infimum_rec(page);
rec = page_rec_get_next(rec); rec = page_rec_get_next(rec);
...@@ -1183,7 +1184,7 @@ btr_search_build_page_hash_index( ...@@ -1183,7 +1184,7 @@ btr_search_build_page_hash_index(
} }
} }
fold = rec_fold(rec, offsets, n_fields, n_bytes, tree_id); fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id);
if (left_side) { if (left_side) {
...@@ -1210,7 +1211,7 @@ btr_search_build_page_hash_index( ...@@ -1210,7 +1211,7 @@ btr_search_build_page_hash_index(
offsets = rec_get_offsets(next_rec, index, offsets, offsets = rec_get_offsets(next_rec, index, offsets,
n_fields + (n_bytes > 0), &heap); n_fields + (n_bytes > 0), &heap);
next_fold = rec_fold(next_rec, offsets, n_fields, next_fold = rec_fold(next_rec, offsets, n_fields,
n_bytes, tree_id); n_bytes, index_id);
if (fold != next_fold) { if (fold != next_fold) {
/* Insert an entry into the hash index */ /* Insert an entry into the hash index */
...@@ -1350,7 +1351,7 @@ btr_search_update_hash_on_delete( ...@@ -1350,7 +1351,7 @@ btr_search_update_hash_on_delete(
buf_block_t* block; buf_block_t* block;
rec_t* rec; rec_t* rec;
ulint fold; ulint fold;
dulint tree_id; dulint index_id;
ibool found; ibool found;
ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint offsets_[REC_OFFS_NORMAL_SIZE];
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
...@@ -1374,10 +1375,10 @@ btr_search_update_hash_on_delete( ...@@ -1374,10 +1375,10 @@ btr_search_update_hash_on_delete(
table = btr_search_sys->hash_index; table = btr_search_sys->hash_index;
tree_id = cursor->index->tree->id; index_id = cursor->index->id;
fold = rec_fold(rec, rec_get_offsets(rec, cursor->index, offsets_, fold = rec_fold(rec, rec_get_offsets(rec, cursor->index, offsets_,
ULINT_UNDEFINED, &heap), ULINT_UNDEFINED, &heap),
block->curr_n_fields, block->curr_n_bytes, tree_id); block->curr_n_fields, block->curr_n_bytes, index_id);
if (UNIV_LIKELY_NULL(heap)) { if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap); mem_heap_free(heap);
} }
...@@ -1454,7 +1455,7 @@ btr_search_update_hash_on_insert( ...@@ -1454,7 +1455,7 @@ btr_search_update_hash_on_insert(
rec_t* rec; rec_t* rec;
rec_t* ins_rec; rec_t* ins_rec;
rec_t* next_rec; rec_t* next_rec;
dulint tree_id; dulint index_id;
ulint fold; ulint fold;
ulint ins_fold; ulint ins_fold;
ulint next_fold = 0; /* remove warning (??? bug ???) */ ulint next_fold = 0; /* remove warning (??? bug ???) */
...@@ -1486,7 +1487,7 @@ btr_search_update_hash_on_insert( ...@@ -1486,7 +1487,7 @@ btr_search_update_hash_on_insert(
ut_a(block->index == cursor->index); ut_a(block->index == cursor->index);
tree_id = ((cursor->index)->tree)->id; index_id = cursor->index->id;
n_fields = block->curr_n_fields; n_fields = block->curr_n_fields;
n_bytes = block->curr_n_bytes; n_bytes = block->curr_n_bytes;
...@@ -1497,19 +1498,19 @@ btr_search_update_hash_on_insert( ...@@ -1497,19 +1498,19 @@ btr_search_update_hash_on_insert(
offsets = rec_get_offsets(ins_rec, cursor->index, offsets, offsets = rec_get_offsets(ins_rec, cursor->index, offsets,
ULINT_UNDEFINED, &heap); ULINT_UNDEFINED, &heap);
ins_fold = rec_fold(ins_rec, offsets, n_fields, n_bytes, tree_id); ins_fold = rec_fold(ins_rec, offsets, n_fields, n_bytes, index_id);
if (!page_rec_is_supremum(next_rec)) { if (!page_rec_is_supremum(next_rec)) {
offsets = rec_get_offsets(next_rec, cursor->index, offsets, offsets = rec_get_offsets(next_rec, cursor->index, offsets,
n_fields + (n_bytes > 0), &heap); n_fields + (n_bytes > 0), &heap);
next_fold = rec_fold(next_rec, offsets, n_fields, next_fold = rec_fold(next_rec, offsets, n_fields,
n_bytes, tree_id); n_bytes, index_id);
} }
if (!page_rec_is_infimum(rec)) { if (!page_rec_is_infimum(rec)) {
offsets = rec_get_offsets(rec, cursor->index, offsets, offsets = rec_get_offsets(rec, cursor->index, offsets,
n_fields + (n_bytes > 0), &heap); n_fields + (n_bytes > 0), &heap);
fold = rec_fold(rec, offsets, n_fields, n_bytes, tree_id); fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id);
} else { } else {
if (left_side) { if (left_side) {
......
...@@ -798,7 +798,7 @@ dict_truncate_index_tree( ...@@ -798,7 +798,7 @@ dict_truncate_index_tree(
root_page_no = btr_create(type, space, index_id, comp, mtr); root_page_no = btr_create(type, space, index_id, comp, mtr);
if (index) { if (index) {
index->tree->page = root_page_no; index->page = root_page_no;
} else { } else {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
......
...@@ -945,7 +945,7 @@ dict_index_find_on_id_low( ...@@ -945,7 +945,7 @@ dict_index_find_on_id_low(
index = dict_table_get_first_index(table); index = dict_table_get_first_index(table);
while (index) { while (index) {
if (0 == ut_dulint_cmp(id, index->tree->id)) { if (0 == ut_dulint_cmp(id, index->id)) {
/* Found */ /* Found */
return(index); return(index);
...@@ -1316,7 +1316,6 @@ dict_index_add_to_cache( ...@@ -1316,7 +1316,6 @@ dict_index_add_to_cache(
ulint page_no)/* in: root page number of the index */ ulint page_no)/* in: root page number of the index */
{ {
dict_index_t* new_index; dict_index_t* new_index;
dict_tree_t* tree;
dict_field_t* field; dict_field_t* field;
ulint n_ord; ulint n_ord;
ulint i; ulint i;
...@@ -1385,11 +1384,8 @@ dict_index_add_to_cache( ...@@ -1385,11 +1384,8 @@ dict_index_add_to_cache(
dict_field_get_col(field)->ord_part = 1; dict_field_get_col(field)->ord_part = 1;
} }
/* Create an index tree memory object for the index */ new_index->page = page_no;
tree = dict_tree_create(new_index, page_no); rw_lock_create(&new_index->lock, SYNC_INDEX_TREE);
ut_ad(tree);
new_index->tree = tree;
if (!UNIV_UNLIKELY(new_index->type & DICT_UNIVERSAL)) { if (!UNIV_UNLIKELY(new_index->type & DICT_UNIVERSAL)) {
...@@ -1406,9 +1402,6 @@ dict_index_add_to_cache( ...@@ -1406,9 +1402,6 @@ dict_index_add_to_cache(
} }
} }
/* Add the index to the list of indexes stored in the tree */
tree->tree_index = new_index;
dict_sys->size += mem_heap_get_size(new_index->heap); dict_sys->size += mem_heap_get_size(new_index->heap);
dict_mem_index_free(index); dict_mem_index_free(index);
...@@ -1432,8 +1425,7 @@ dict_index_remove_from_cache( ...@@ -1432,8 +1425,7 @@ dict_index_remove_from_cache(
ut_ad(mutex_own(&(dict_sys->mutex))); ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
ut_ad(index->tree->tree_index); rw_lock_free(&index->lock);
dict_tree_free(index->tree);
/* Remove the index from the list of indexes of the table */ /* Remove the index from the list of indexes of the table */
UT_LIST_REMOVE(indexes, table->indexes, index); UT_LIST_REMOVE(indexes, table->indexes, index);
...@@ -3536,68 +3528,18 @@ dict_index_get_if_in_cache( ...@@ -3536,68 +3528,18 @@ dict_index_get_if_in_cache(
return(index); return(index);
} }
/**************************************************************************
Creates an index tree struct. */
dict_tree_t*
dict_tree_create(
/*=============*/
/* out, own: created tree */
dict_index_t* index, /* in: the index for which to create */
ulint page_no)/* in: root page number of the index */
{
dict_tree_t* tree;
tree = mem_alloc(sizeof(dict_tree_t));
/* Inherit info from the index */
tree->type = index->type;
tree->space = index->space;
tree->page = page_no;
tree->id = index->id;
tree->tree_index = NULL;
#ifdef UNIV_DEBUG
tree->magic_n = DICT_TREE_MAGIC_N;
#endif /* UNIV_DEBUG */
rw_lock_create(&tree->lock, SYNC_INDEX_TREE);
return(tree);
}
/**************************************************************************
Frees an index tree struct. */
void
dict_tree_free(
/*===========*/
dict_tree_t* tree) /* in, own: index tree */
{
ut_a(tree);
ut_ad(tree->magic_n == DICT_TREE_MAGIC_N);
rw_lock_free(&(tree->lock));
mem_free(tree);
}
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
/************************************************************************** /**************************************************************************
Checks that a tuple has n_fields_cmp value in a sensible range, so that Checks that a tuple has n_fields_cmp value in a sensible range, so that
no comparison can occur with the page number field in a node pointer. */ no comparison can occur with the page number field in a node pointer. */
ibool ibool
dict_tree_check_search_tuple( dict_index_check_search_tuple(
/*=========================*/ /*==========================*/
/* out: TRUE if ok */ /* out: TRUE if ok */
dict_tree_t* tree, /* in: index tree */ dict_index_t* index, /* in: index tree */
dtuple_t* tuple) /* in: tuple used in a search */ dtuple_t* tuple) /* in: tuple used in a search */
{ {
dict_index_t* index = tree->tree_index;
ut_a(index); ut_a(index);
ut_a(dtuple_get_n_fields_cmp(tuple) ut_a(dtuple_get_n_fields_cmp(tuple)
<= dict_index_get_n_unique_in_tree(index)); <= dict_index_get_n_unique_in_tree(index));
...@@ -3609,10 +3551,10 @@ dict_tree_check_search_tuple( ...@@ -3609,10 +3551,10 @@ dict_tree_check_search_tuple(
Builds a node pointer out of a physical record and a page number. */ Builds a node pointer out of a physical record and a page number. */
dtuple_t* dtuple_t*
dict_tree_build_node_ptr( dict_index_build_node_ptr(
/*=====================*/ /*======================*/
/* out, own: node pointer */ /* out, own: node pointer */
dict_tree_t* tree, /* in: index tree */ dict_index_t* index, /* in: index tree */
rec_t* rec, /* in: record for which to build node rec_t* rec, /* in: record for which to build node
pointer */ pointer */
ulint page_no,/* in: page number to put in node pointer */ ulint page_no,/* in: page number to put in node pointer */
...@@ -3621,20 +3563,17 @@ dict_tree_build_node_ptr( ...@@ -3621,20 +3563,17 @@ dict_tree_build_node_ptr(
level */ level */
{ {
dtuple_t* tuple; dtuple_t* tuple;
dict_index_t* ind;
dfield_t* field; dfield_t* field;
byte* buf; byte* buf;
ulint n_unique; ulint n_unique;
ind = tree->tree_index; if (UNIV_UNLIKELY(index->type & DICT_UNIVERSAL)) {
if (UNIV_UNLIKELY(tree->type & DICT_UNIVERSAL)) {
/* In a universal index tree, we take the whole record as /* In a universal index tree, we take the whole record as
the node pointer if the reord is on the leaf level, the node pointer if the reord is on the leaf level,
on non-leaf levels we remove the last field, which on non-leaf levels we remove the last field, which
contains the page number of the child page */ contains the page number of the child page */
ut_a(!dict_table_is_comp(ind->table)); ut_a(!dict_table_is_comp(index->table));
n_unique = rec_get_n_fields_old(rec); n_unique = rec_get_n_fields_old(rec);
if (level > 0) { if (level > 0) {
...@@ -3642,7 +3581,7 @@ dict_tree_build_node_ptr( ...@@ -3642,7 +3581,7 @@ dict_tree_build_node_ptr(
n_unique--; n_unique--;
} }
} else { } else {
n_unique = dict_index_get_n_unique_in_tree(ind); n_unique = dict_index_get_n_unique_in_tree(index);
} }
tuple = dtuple_create(heap, n_unique + 1); tuple = dtuple_create(heap, n_unique + 1);
...@@ -3655,7 +3594,7 @@ dict_tree_build_node_ptr( ...@@ -3655,7 +3594,7 @@ dict_tree_build_node_ptr(
dtuple_set_n_fields_cmp(tuple, n_unique); dtuple_set_n_fields_cmp(tuple, n_unique);
dict_index_copy_types(tuple, ind, n_unique); dict_index_copy_types(tuple, index, n_unique);
buf = mem_heap_alloc(heap, 4); buf = mem_heap_alloc(heap, 4);
...@@ -3666,7 +3605,7 @@ dict_tree_build_node_ptr( ...@@ -3666,7 +3605,7 @@ dict_tree_build_node_ptr(
dtype_set(dfield_get_type(field), DATA_SYS_CHILD, DATA_NOT_NULL, 4); dtype_set(dfield_get_type(field), DATA_SYS_CHILD, DATA_NOT_NULL, 4);
rec_copy_prefix_to_dtuple(tuple, rec, ind, n_unique, heap); rec_copy_prefix_to_dtuple(tuple, rec, index, n_unique, heap);
dtuple_set_info_bits(tuple, dtuple_get_info_bits(tuple) dtuple_set_info_bits(tuple, dtuple_get_info_bits(tuple)
| REC_STATUS_NODE_PTR); | REC_STATUS_NODE_PTR);
...@@ -3680,23 +3619,21 @@ Copies an initial segment of a physical record, long enough to specify an ...@@ -3680,23 +3619,21 @@ Copies an initial segment of a physical record, long enough to specify an
index entry uniquely. */ index entry uniquely. */
rec_t* rec_t*
dict_tree_copy_rec_order_prefix( dict_index_copy_rec_order_prefix(
/*============================*/ /*=============================*/
/* out: pointer to the prefix record */ /* out: pointer to the prefix record */
dict_tree_t* tree, /* in: index tree */ dict_index_t* index, /* in: index tree */
rec_t* rec, /* in: record for which to copy prefix */ rec_t* rec, /* in: record for which to copy prefix */
ulint* n_fields,/* out: number of fields copied */ ulint* n_fields,/* out: number of fields copied */
byte** buf, /* in/out: memory buffer for the copied prefix, byte** buf, /* in/out: memory buffer for the copied prefix,
or NULL */ or NULL */
ulint* buf_size)/* in/out: buffer size */ ulint* buf_size)/* in/out: buffer size */
{ {
dict_index_t* index;
ulint n; ulint n;
UNIV_PREFETCH_R(rec); UNIV_PREFETCH_R(rec);
index = tree->tree_index;
if (UNIV_UNLIKELY(tree->type & DICT_UNIVERSAL)) { if (UNIV_UNLIKELY(index->type & DICT_UNIVERSAL)) {
ut_a(!dict_table_is_comp(index->table)); ut_a(!dict_table_is_comp(index->table));
n = rec_get_n_fields_old(rec); n = rec_get_n_fields_old(rec);
} else { } else {
...@@ -3711,27 +3648,24 @@ dict_tree_copy_rec_order_prefix( ...@@ -3711,27 +3648,24 @@ dict_tree_copy_rec_order_prefix(
Builds a typed data tuple out of a physical record. */ Builds a typed data tuple out of a physical record. */
dtuple_t* dtuple_t*
dict_tree_build_data_tuple( dict_index_build_data_tuple(
/*=======================*/ /*========================*/
/* out, own: data tuple */ /* out, own: data tuple */
dict_tree_t* tree, /* in: index tree */ dict_index_t* index, /* in: index tree */
rec_t* rec, /* in: record for which to build data tuple */ rec_t* rec, /* in: record for which to build data tuple */
ulint n_fields,/* in: number of data fields */ ulint n_fields,/* in: number of data fields */
mem_heap_t* heap) /* in: memory heap where tuple created */ mem_heap_t* heap) /* in: memory heap where tuple created */
{ {
dtuple_t* tuple; dtuple_t* tuple;
dict_index_t* ind;
ind = tree->tree_index; ut_ad(dict_table_is_comp(index->table)
ut_ad(dict_table_is_comp(ind->table)
|| n_fields <= rec_get_n_fields_old(rec)); || n_fields <= rec_get_n_fields_old(rec));
tuple = dtuple_create(heap, n_fields); tuple = dtuple_create(heap, n_fields);
dict_index_copy_types(tuple, ind, n_fields); dict_index_copy_types(tuple, index, n_fields);
rec_copy_prefix_to_dtuple(tuple, rec, ind, n_fields, heap); rec_copy_prefix_to_dtuple(tuple, rec, index, n_fields, heap);
ut_ad(dtuple_check_typed(tuple)); ut_ad(dtuple_check_typed(tuple));
...@@ -4045,7 +3979,6 @@ dict_index_print_low( ...@@ -4045,7 +3979,6 @@ dict_index_print_low(
/*=================*/ /*=================*/
dict_index_t* index) /* in: index */ dict_index_t* index) /* in: index */
{ {
dict_tree_t* tree;
ib_longlong n_vals; ib_longlong n_vals;
ulint i; ulint i;
...@@ -4053,8 +3986,6 @@ dict_index_print_low( ...@@ -4053,8 +3986,6 @@ dict_index_print_low(
ut_ad(mutex_own(&(dict_sys->mutex))); ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
tree = index->tree;
if (index->n_user_defined_cols > 0) { if (index->n_user_defined_cols > 0) {
n_vals = index->stat_n_diff_key_vals n_vals = index->stat_n_diff_key_vals
[index->n_user_defined_cols]; [index->n_user_defined_cols];
...@@ -4069,13 +4000,13 @@ dict_index_print_low( ...@@ -4069,13 +4000,13 @@ dict_index_print_low(
" leaf pages %lu, size pages %lu\n" " leaf pages %lu, size pages %lu\n"
" FIELDS: ", " FIELDS: ",
index->name, index->name,
(ulong) ut_dulint_get_high(tree->id), (ulong) ut_dulint_get_high(index->id),
(ulong) ut_dulint_get_low(tree->id), (ulong) ut_dulint_get_low(index->id),
(ulong) index->n_user_defined_cols, (ulong) index->n_user_defined_cols,
(ulong) index->n_fields, (ulong) index->n_fields,
(ulong) index->n_uniq, (ulong) index->n_uniq,
(ulong) index->type, (ulong) index->type,
(ulong) tree->page, (ulong) index->page,
(ulong) n_vals, (ulong) n_vals,
(ulong) index->stat_n_leaf_pages, (ulong) index->stat_n_leaf_pages,
(ulong) index->stat_index_size); (ulong) index->stat_index_size);
...@@ -4087,9 +4018,9 @@ dict_index_print_low( ...@@ -4087,9 +4018,9 @@ dict_index_print_low(
putc('\n', stderr); putc('\n', stderr);
#ifdef UNIV_BTR_PRINT #ifdef UNIV_BTR_PRINT
btr_print_size(tree); btr_print_size(index);
btr_print_tree(tree, 7); btr_print_index(index, 7);
#endif /* UNIV_BTR_PRINT */ #endif /* UNIV_BTR_PRINT */
} }
......
...@@ -169,6 +169,7 @@ dict_mem_index_create( ...@@ -169,6 +169,7 @@ dict_mem_index_create(
index->type = type; index->type = type;
index->space = space; index->space = space;
index->page = 0;
index->name = mem_heap_strdup(heap, index_name); index->name = mem_heap_strdup(heap, index_name);
index->table_name = table_name; index->table_name = table_name;
index->table = NULL; index->table = NULL;
...@@ -181,6 +182,7 @@ dict_mem_index_create( ...@@ -181,6 +182,7 @@ dict_mem_index_create(
index->stat_n_diff_key_vals = NULL; index->stat_n_diff_key_vals = NULL;
index->cached = FALSE; index->cached = FALSE;
memset(&index->lock, 0, sizeof index->lock);
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
index->magic_n = DICT_INDEX_MAGIC_N; index->magic_n = DICT_INDEX_MAGIC_N;
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
......
...@@ -305,7 +305,7 @@ ibuf_tree_root_get( ...@@ -305,7 +305,7 @@ ibuf_tree_root_get(
ut_a(space == 0); ut_a(space == 0);
ut_ad(ibuf_inside()); ut_ad(ibuf_inside());
mtr_x_lock(dict_tree_get_lock((data->index)->tree), mtr); mtr_x_lock(dict_index_get_lock(data->index), mtr);
page = buf_page_get(space, FSP_IBUF_TREE_ROOT_PAGE_NO, RW_X_LATCH, page = buf_page_get(space, FSP_IBUF_TREE_ROOT_PAGE_NO, RW_X_LATCH,
mtr); mtr);
...@@ -2994,7 +2994,7 @@ ibuf_delete_rec( ...@@ -2994,7 +2994,7 @@ ibuf_delete_rec(
btr_pcur_commit_specify_mtr(pcur, mtr); btr_pcur_commit_specify_mtr(pcur, mtr);
fputs("InnoDB: Validating insert buffer tree:\n", stderr); fputs("InnoDB: Validating insert buffer tree:\n", stderr);
if (!btr_validate_tree(ibuf_data->index->tree, NULL)) { if (!btr_validate_index(ibuf_data->index, NULL)) {
ut_error; ut_error;
} }
......
...@@ -52,7 +52,7 @@ page_t* ...@@ -52,7 +52,7 @@ page_t*
btr_root_get( btr_root_get(
/*=========*/ /*=========*/
/* out: root page, x-latched */ /* out: root page, x-latched */
dict_tree_t* tree, /* in: index tree */ dict_index_t* index, /* in: index tree */
mtr_t* mtr); /* in: mtr */ mtr_t* mtr); /* in: mtr */
/****************************************************************** /******************************************************************
Gets a buffer page and declares its latching order level. */ Gets a buffer page and declares its latching order level. */
...@@ -255,7 +255,7 @@ that mtr holds an x-latch on the tree. */ ...@@ -255,7 +255,7 @@ that mtr holds an x-latch on the tree. */
void void
btr_insert_on_non_leaf_level( btr_insert_on_non_leaf_level(
/*=========================*/ /*=========================*/
dict_tree_t* tree, /* in: tree */ dict_index_t* index, /* in: index */
ulint level, /* in: level, must be > 0 */ ulint level, /* in: level, must be > 0 */
dtuple_t* tuple, /* in: the record to be inserted */ dtuple_t* tuple, /* in: the record to be inserted */
mtr_t* mtr); /* in: mtr */ mtr_t* mtr); /* in: mtr */
...@@ -274,7 +274,7 @@ Deletes on the upper level the node pointer to a page. */ ...@@ -274,7 +274,7 @@ Deletes on the upper level the node pointer to a page. */
void void
btr_node_ptr_delete( btr_node_ptr_delete(
/*================*/ /*================*/
dict_tree_t* tree, /* in: index tree */ dict_index_t* index, /* in: index tree */
page_t* page, /* in: page whose node pointer is deleted */ page_t* page, /* in: page whose node pointer is deleted */
mtr_t* mtr); /* in: mtr */ mtr_t* mtr); /* in: mtr */
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
...@@ -285,7 +285,7 @@ ibool ...@@ -285,7 +285,7 @@ ibool
btr_check_node_ptr( btr_check_node_ptr(
/*===============*/ /*===============*/
/* out: TRUE */ /* out: TRUE */
dict_tree_t* tree, /* in: index tree */ dict_index_t* index, /* in: index tree */
page_t* page, /* in: index page */ page_t* page, /* in: index page */
mtr_t* mtr); /* in: mtr */ mtr_t* mtr); /* in: mtr */
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
...@@ -361,7 +361,7 @@ btr_page_alloc( ...@@ -361,7 +361,7 @@ btr_page_alloc(
/*===========*/ /*===========*/
/* out: new allocated page, x-latched; /* out: new allocated page, x-latched;
NULL if out of space */ NULL if out of space */
dict_tree_t* tree, /* in: index tree */ dict_index_t* index, /* in: index tree */
ulint hint_page_no, /* in: hint of a good page */ ulint hint_page_no, /* in: hint of a good page */
byte file_direction, /* in: direction where a possible byte file_direction, /* in: direction where a possible
page split is made */ page split is made */
...@@ -375,7 +375,7 @@ storage pages because the page must contain info on its level. */ ...@@ -375,7 +375,7 @@ storage pages because the page must contain info on its level. */
void void
btr_page_free( btr_page_free(
/*==========*/ /*==========*/
dict_tree_t* tree, /* in: index tree */ dict_index_t* index, /* in: index tree */
page_t* page, /* in: page to be freed, x-latched */ page_t* page, /* in: page to be freed, x-latched */
mtr_t* mtr); /* in: mtr */ mtr_t* mtr); /* in: mtr */
/****************************************************************** /******************************************************************
...@@ -386,7 +386,7 @@ argument. */ ...@@ -386,7 +386,7 @@ argument. */
void void
btr_page_free_low( btr_page_free_low(
/*==============*/ /*==============*/
dict_tree_t* tree, /* in: index tree */ dict_index_t* index, /* in: index tree */
page_t* page, /* in: page to be freed, x-latched */ page_t* page, /* in: page to be freed, x-latched */
ulint level, /* in: page level */ ulint level, /* in: page level */
mtr_t* mtr); /* in: mtr */ mtr_t* mtr); /* in: mtr */
...@@ -397,14 +397,14 @@ Prints size info of a B-tree. */ ...@@ -397,14 +397,14 @@ Prints size info of a B-tree. */
void void
btr_print_size( btr_print_size(
/*===========*/ /*===========*/
dict_tree_t* tree); /* in: index tree */ dict_index_t* index); /* in: index tree */
/****************************************************************** /******************************************************************
Prints directories and other info of all nodes in the tree. */ Prints directories and other info of all nodes in the index. */
void void
btr_print_tree( btr_print_index(
/*===========*/ /*============*/
dict_tree_t* tree, /* in: tree */ dict_index_t* index, /* in: index */
ulint width); /* in: print this many entries from start ulint width); /* in: print this many entries from start
and end */ and end */
#endif /* UNIV_BTR_PRINT */ #endif /* UNIV_BTR_PRINT */
...@@ -425,10 +425,10 @@ btr_index_rec_validate( ...@@ -425,10 +425,10 @@ btr_index_rec_validate(
Checks the consistency of an index tree. */ Checks the consistency of an index tree. */
ibool ibool
btr_validate_tree( btr_validate_index(
/*==============*/ /*===============*/
/* out: TRUE if ok */ /* out: TRUE if ok */
dict_tree_t* tree, /* in: tree */ dict_index_t* index, /* in: index */
trx_t* trx); /* in: transaction or NULL */ trx_t* trx); /* in: transaction or NULL */
#define BTR_N_LEAF_PAGES 1 #define BTR_N_LEAF_PAGES 1
......
...@@ -59,13 +59,13 @@ btr_cur_get_page( ...@@ -59,13 +59,13 @@ btr_cur_get_page(
/* out: pointer to page */ /* out: pointer to page */
btr_cur_t* cursor);/* in: tree cursor */ btr_cur_t* cursor);/* in: tree cursor */
/************************************************************* /*************************************************************
Returns the tree of a cursor. */ Returns the index of a cursor. */
UNIV_INLINE UNIV_INLINE
dict_tree_t* dict_index_t*
btr_cur_get_tree( btr_cur_get_index(
/*=============*/ /*==============*/
/* out: tree */ /* out: index */
btr_cur_t* cursor);/* in: tree cursor */ btr_cur_t* cursor);/* in: B-tree cursor */
/************************************************************* /*************************************************************
Positions a tree cursor at a given record. */ Positions a tree cursor at a given record. */
UNIV_INLINE UNIV_INLINE
......
...@@ -56,15 +56,15 @@ btr_cur_get_page( ...@@ -56,15 +56,15 @@ btr_cur_get_page(
} }
/************************************************************* /*************************************************************
Returns the tree of a cursor. */ Returns the index of a cursor. */
UNIV_INLINE UNIV_INLINE
dict_tree_t* dict_index_t*
btr_cur_get_tree( btr_cur_get_index(
/*=============*/ /*==============*/
/* out: tree */ /* out: index */
btr_cur_t* cursor) /* in: tree cursor */ btr_cur_t* cursor) /* in: B-tree cursor */
{ {
return((cursor->index)->tree); return(cursor->index);
} }
/************************************************************* /*************************************************************
...@@ -109,15 +109,8 @@ btr_cur_compress_recommendation( ...@@ -109,15 +109,8 @@ btr_cur_compress_recommendation(
one page: we recommend compression if this is not the one page: we recommend compression if this is not the
root page. */ root page. */
if (dict_tree_get_page((cursor->index)->tree) return(dict_index_get_page(cursor->index)
== buf_frame_get_page_no(page)) { != buf_frame_get_page_no(page));
/* It is the root page */
return(FALSE);
}
return(TRUE);
} }
return(FALSE); return(FALSE);
...@@ -153,15 +146,8 @@ btr_cur_can_delete_without_compress( ...@@ -153,15 +146,8 @@ btr_cur_can_delete_without_compress(
one page, OR the page will become empty: we recommend one page, OR the page will become empty: we recommend
compression if this is not the root page. */ compression if this is not the root page. */
if (dict_tree_get_page((cursor->index)->tree) return(dict_index_get_page(cursor->index)
== buf_frame_get_page_no(page)) { == buf_frame_get_page_no(page));
/* It is the root page */
return(TRUE);
}
return(FALSE);
} }
return(TRUE); return(TRUE);
......
...@@ -706,14 +706,6 @@ dict_index_copy_types( ...@@ -706,14 +706,6 @@ dict_index_copy_types(
dict_index_t* index, /* in: index */ dict_index_t* index, /* in: index */
ulint n_fields); /* in: number of field types to copy */ ulint n_fields); /* in: number of field types to copy */
/************************************************************************* /*************************************************************************
Gets the index tree where the index is stored. */
UNIV_INLINE
dict_tree_t*
dict_index_get_tree(
/*================*/
/* out: index tree */
dict_index_t* index); /* in: index */
/*************************************************************************
Gets the field column. */ Gets the field column. */
UNIV_INLINE UNIV_INLINE
dict_col_t* dict_col_t*
...@@ -721,22 +713,6 @@ dict_field_get_col( ...@@ -721,22 +713,6 @@ dict_field_get_col(
/*===============*/ /*===============*/
dict_field_t* field); dict_field_t* field);
/************************************************************************** /**************************************************************************
Creates an index tree struct. */
dict_tree_t*
dict_tree_create(
/*=============*/
/* out, own: created tree */
dict_index_t* index, /* in: the index for which to create */
ulint page_no);/* in: root page number of the index */
/**************************************************************************
Frees an index tree struct. */
void
dict_tree_free(
/*===========*/
dict_tree_t* tree); /* in, own: index tree */
/**************************************************************************
In an index tree, finds the index corresponding to a record in the tree. */ In an index tree, finds the index corresponding to a record in the tree. */
/************************************************************************** /**************************************************************************
...@@ -753,20 +729,20 @@ Checks that a tuple has n_fields_cmp value in a sensible range, so that ...@@ -753,20 +729,20 @@ Checks that a tuple has n_fields_cmp value in a sensible range, so that
no comparison can occur with the page number field in a node pointer. */ no comparison can occur with the page number field in a node pointer. */
ibool ibool
dict_tree_check_search_tuple( dict_index_check_search_tuple(
/*=========================*/ /*==========================*/
/* out: TRUE if ok */ /* out: TRUE if ok */
dict_tree_t* tree, /* in: index tree */ dict_index_t* index, /* in: index */
dtuple_t* tuple); /* in: tuple used in a search */ dtuple_t* tuple); /* in: tuple used in a search */
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
/************************************************************************** /**************************************************************************
Builds a node pointer out of a physical record and a page number. */ Builds a node pointer out of a physical record and a page number. */
dtuple_t* dtuple_t*
dict_tree_build_node_ptr( dict_index_build_node_ptr(
/*=====================*/ /*======================*/
/* out, own: node pointer */ /* out, own: node pointer */
dict_tree_t* tree, /* in: index tree */ dict_index_t* index, /* in: index */
rec_t* rec, /* in: record for which to build node rec_t* rec, /* in: record for which to build node
pointer */ pointer */
ulint page_no,/* in: page number to put in node pointer */ ulint page_no,/* in: page number to put in node pointer */
...@@ -778,10 +754,10 @@ Copies an initial segment of a physical record, long enough to specify an ...@@ -778,10 +754,10 @@ Copies an initial segment of a physical record, long enough to specify an
index entry uniquely. */ index entry uniquely. */
rec_t* rec_t*
dict_tree_copy_rec_order_prefix( dict_index_copy_rec_order_prefix(
/*============================*/ /*=============================*/
/* out: pointer to the prefix record */ /* out: pointer to the prefix record */
dict_tree_t* tree, /* in: index tree */ dict_index_t* index, /* in: index */
rec_t* rec, /* in: record for which to copy prefix */ rec_t* rec, /* in: record for which to copy prefix */
ulint* n_fields,/* out: number of fields copied */ ulint* n_fields,/* out: number of fields copied */
byte** buf, /* in/out: memory buffer for the copied prefix, byte** buf, /* in/out: memory buffer for the copied prefix,
...@@ -791,10 +767,10 @@ dict_tree_copy_rec_order_prefix( ...@@ -791,10 +767,10 @@ dict_tree_copy_rec_order_prefix(
Builds a typed data tuple out of a physical record. */ Builds a typed data tuple out of a physical record. */
dtuple_t* dtuple_t*
dict_tree_build_data_tuple( dict_index_build_data_tuple(
/*=======================*/ /*========================*/
/* out, own: data tuple */ /* out, own: data tuple */
dict_tree_t* tree, /* in: index tree */ dict_index_t* index, /* in: index */
rec_t* rec, /* in: record for which to build data tuple */ rec_t* rec, /* in: record for which to build data tuple */
ulint n_fields,/* in: number of data fields */ ulint n_fields,/* in: number of data fields */
mem_heap_t* heap); /* in: memory heap where tuple created */ mem_heap_t* heap); /* in: memory heap where tuple created */
...@@ -802,61 +778,60 @@ dict_tree_build_data_tuple( ...@@ -802,61 +778,60 @@ dict_tree_build_data_tuple(
Gets the space id of the root of the index tree. */ Gets the space id of the root of the index tree. */
UNIV_INLINE UNIV_INLINE
ulint ulint
dict_tree_get_space( dict_index_get_space(
/*================*/ /*=================*/
/* out: space id */ /* out: space id */
dict_tree_t* tree); /* in: tree */ dict_index_t* index); /* in: index */
/************************************************************************* /*************************************************************************
Sets the space id of the root of the index tree. */ Sets the space id of the root of the index tree. */
UNIV_INLINE UNIV_INLINE
void void
dict_tree_set_space( dict_index_set_space(
/*================*/ /*=================*/
dict_tree_t* tree, /* in: tree */ dict_index_t* index, /* in: index */
ulint space); /* in: space id */ ulint space); /* in: space id */
/************************************************************************* /*************************************************************************
Gets the page number of the root of the index tree. */ Gets the page number of the root of the index tree. */
UNIV_INLINE UNIV_INLINE
ulint ulint
dict_tree_get_page( dict_index_get_page(
/*===============*/ /*================*/
/* out: page number */ /* out: page number */
dict_tree_t* tree); /* in: tree */ dict_index_t* tree); /* in: index */
/************************************************************************* /*************************************************************************
Sets the page number of the root of index tree. */ Sets the page number of the root of index tree. */
UNIV_INLINE UNIV_INLINE
void void
dict_tree_set_page( dict_index_set_page(
/*===============*/ /*================*/
dict_tree_t* tree, /* in: tree */ dict_index_t* index, /* in: index */
ulint page); /* in: page number */ ulint page); /* in: page number */
/************************************************************************* /*************************************************************************
Gets the type of the index tree. */ Gets the type of the index tree. */
UNIV_INLINE UNIV_INLINE
ulint ulint
dict_tree_get_type( dict_index_get_type(
/*===============*/ /*================*/
/* out: type */ /* out: type */
dict_tree_t* tree); /* in: tree */ dict_index_t* index); /* in: index */
/************************************************************************* /*************************************************************************
Gets the read-write lock of the index tree. */ Gets the read-write lock of the index tree. */
UNIV_INLINE UNIV_INLINE
rw_lock_t* rw_lock_t*
dict_tree_get_lock( dict_index_get_lock(
/*===============*/ /*================*/
/* out: read-write lock */ /* out: read-write lock */
dict_tree_t* tree); /* in: tree */ dict_index_t* index); /* in: index */
/************************************************************************ /************************************************************************
Returns free space reserved for future updates of records. This is Returns free space reserved for future updates of records. This is
relevant only in the case of many consecutive inserts, as updates relevant only in the case of many consecutive inserts, as updates
which make the records bigger might fragment the index. */ which make the records bigger might fragment the index. */
UNIV_INLINE UNIV_INLINE
ulint ulint
dict_tree_get_space_reserve( dict_index_get_space_reserve(void);
/*========================*/ /*==============================*/
/* out: number of free bytes on page, /* out: number of free bytes on page,
reserved for updates */ reserved for updates */
dict_tree_t* tree); /* in: a tree */
/************************************************************************* /*************************************************************************
Calculates the minimum record length in an index. */ Calculates the minimum record length in an index. */
......
...@@ -341,21 +341,6 @@ dict_index_get_sys_col_pos( ...@@ -341,21 +341,6 @@ dict_index_get_sys_col_pos(
(index, dict_table_get_sys_col_no(index->table, type))); (index, dict_table_get_sys_col_no(index->table, type)));
} }
/*************************************************************************
Gets the index tree where the index is stored. */
UNIV_INLINE
dict_tree_t*
dict_index_get_tree(
/*================*/
/* out: index tree */
dict_index_t* index) /* in: index */
{
ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
return(index->tree);
}
/************************************************************************* /*************************************************************************
Gets the field column. */ Gets the field column. */
UNIV_INLINE UNIV_INLINE
...@@ -401,90 +386,90 @@ dict_index_get_nth_col_no( ...@@ -401,90 +386,90 @@ dict_index_get_nth_col_no(
Gets the space id of the root of the index tree. */ Gets the space id of the root of the index tree. */
UNIV_INLINE UNIV_INLINE
ulint ulint
dict_tree_get_space( dict_index_get_space(
/*================*/ /*=================*/
/* out: space id */ /* out: space id */
dict_tree_t* tree) /* in: tree */ dict_index_t* index) /* in: index */
{ {
ut_ad(tree); ut_ad(index);
ut_ad(tree->magic_n == DICT_TREE_MAGIC_N); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
return(tree->space); return(index->space);
} }
/************************************************************************* /*************************************************************************
Sets the space id of the root of the index tree. */ Sets the space id of the root of the index tree. */
UNIV_INLINE UNIV_INLINE
void void
dict_tree_set_space( dict_index_set_space(
/*================*/ /*=================*/
dict_tree_t* tree, /* in: tree */ dict_index_t* index, /* in: index */
ulint space) /* in: space id */ ulint space) /* in: space id */
{ {
ut_ad(tree); ut_ad(index);
ut_ad(tree->magic_n == DICT_TREE_MAGIC_N); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
tree->space = space; index->space = space;
} }
/************************************************************************* /*************************************************************************
Gets the page number of the root of the index tree. */ Gets the page number of the root of the index tree. */
UNIV_INLINE UNIV_INLINE
ulint ulint
dict_tree_get_page( dict_index_get_page(
/*===============*/ /*================*/
/* out: page number */ /* out: page number */
dict_tree_t* tree) /* in: tree */ dict_index_t* index) /* in: index */
{ {
ut_ad(tree); ut_ad(index);
ut_ad(tree->magic_n == DICT_TREE_MAGIC_N); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
return(tree->page); return(index->page);
} }
/************************************************************************* /*************************************************************************
Sets the page number of the root of index tree. */ Sets the page number of the root of index tree. */
UNIV_INLINE UNIV_INLINE
void void
dict_tree_set_page( dict_index_set_page(
/*===============*/ /*================*/
dict_tree_t* tree, /* in: tree */ dict_index_t* index, /* in: index */
ulint page) /* in: page number */ ulint page) /* in: page number */
{ {
ut_ad(tree); ut_ad(index);
ut_ad(tree->magic_n == DICT_TREE_MAGIC_N); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
tree->page = page; index->page = page;
} }
/************************************************************************* /*************************************************************************
Gets the type of the index tree. */ Gets the type of the index tree. */
UNIV_INLINE UNIV_INLINE
ulint ulint
dict_tree_get_type( dict_index_get_type(
/*===============*/ /*================*/
/* out: type */ /* out: type */
dict_tree_t* tree) /* in: tree */ dict_index_t* index) /* in: index */
{ {
ut_ad(tree); ut_ad(index);
ut_ad(tree->magic_n == DICT_TREE_MAGIC_N); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
return(tree->type); return(index->type);
} }
/************************************************************************* /*************************************************************************
Gets the read-write lock of the index tree. */ Gets the read-write lock of the index tree. */
UNIV_INLINE UNIV_INLINE
rw_lock_t* rw_lock_t*
dict_tree_get_lock( dict_index_get_lock(
/*===============*/ /*================*/
/* out: read-write lock */ /* out: read-write lock */
dict_tree_t* tree) /* in: tree */ dict_index_t* index) /* in: index */
{ {
ut_ad(tree); ut_ad(index);
ut_ad(tree->magic_n == DICT_TREE_MAGIC_N); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
return(&(tree->lock)); return(&(index->lock));
} }
/************************************************************************ /************************************************************************
...@@ -493,16 +478,11 @@ relevant only in the case of many consecutive inserts, as updates ...@@ -493,16 +478,11 @@ relevant only in the case of many consecutive inserts, as updates
which make the records bigger might fragment the index. */ which make the records bigger might fragment the index. */
UNIV_INLINE UNIV_INLINE
ulint ulint
dict_tree_get_space_reserve( dict_index_get_space_reserve(void)
/*========================*/ /*==============================*/
/* out: number of free bytes on page, /* out: number of free bytes on page,
reserved for updates */ reserved for updates */
dict_tree_t* tree) /* in: a tree */
{ {
ut_ad(tree);
UT_NOT_USED(tree);
return(UNIV_PAGE_SIZE / 16); return(UNIV_PAGE_SIZE / 16);
} }
......
...@@ -152,22 +152,6 @@ struct dict_field_struct{ ...@@ -152,22 +152,6 @@ struct dict_field_struct{
DICT_MAX_INDEX_COL_LEN */ DICT_MAX_INDEX_COL_LEN */
}; };
/* Data structure for an index tree */
struct dict_tree_struct{
ulint type; /* tree type */
dulint id; /* id of the index stored in the tree */
ulint space; /* space of index tree */
ulint page; /* index tree root page number */
rw_lock_t lock; /* read-write lock protecting the upper levels
of the index tree */
dict_index_t* tree_index; /* the index stored in the
index tree */
#ifdef UNIV_DEBUG
ulint magic_n;/* magic number */
# define DICT_TREE_MAGIC_N 7545676
#endif /* UNIV_DEBUG */
};
/* Data structure for an index */ /* Data structure for an index */
struct dict_index_struct{ struct dict_index_struct{
dulint id; /* id of the index */ dulint id; /* id of the index */
...@@ -176,27 +160,28 @@ struct dict_index_struct{ ...@@ -176,27 +160,28 @@ struct dict_index_struct{
const char* name; /* index name */ const char* name; /* index name */
const char* table_name; /* table name */ const char* table_name; /* table name */
dict_table_t* table; /* back pointer to table */ dict_table_t* table; /* back pointer to table */
ulint space; /* space where the index tree is placed */ unsigned space:32;
ulint trx_id_offset:10;/* position of the the trx id column /* space where the index tree is placed */
unsigned page:32;/* index tree root page number */
unsigned trx_id_offset:10;/* position of the the trx id column
in a clustered index record, if the fields in a clustered index record, if the fields
before it are known to be of a fixed size, before it are known to be of a fixed size,
0 otherwise */ 0 otherwise */
ulint n_user_defined_cols:10; unsigned n_user_defined_cols:10;
/* number of columns the user defined to /* number of columns the user defined to
be in the index: in the internal be in the index: in the internal
representation we add more columns */ representation we add more columns */
ulint n_uniq:10;/* number of fields from the beginning unsigned n_uniq:10;/* number of fields from the beginning
which are enough to determine an index which are enough to determine an index
entry uniquely */ entry uniquely */
ulint n_def:10;/* number of fields defined so far */ unsigned n_def:10;/* number of fields defined so far */
ulint n_fields:10;/* number of fields in the index */ unsigned n_fields:10;/* number of fields in the index */
ulint n_nullable:10;/* number of nullable fields */ unsigned n_nullable:10;/* number of nullable fields */
ibool cached:1;/* TRUE if the index object is in the unsigned cached:1;/* TRUE if the index object is in the
dictionary cache */ dictionary cache */
dict_field_t* fields; /* array of field descriptions */ dict_field_t* fields; /* array of field descriptions */
UT_LIST_NODE_T(dict_index_t) UT_LIST_NODE_T(dict_index_t)
indexes;/* list of indexes of the table */ indexes;/* list of indexes of the table */
dict_tree_t* tree; /* index tree struct */
btr_search_t* search_info; /* info used in optimistic searches */ btr_search_t* search_info; /* info used in optimistic searches */
/*----------------------*/ /*----------------------*/
ib_longlong* stat_n_diff_key_vals; ib_longlong* stat_n_diff_key_vals;
...@@ -209,6 +194,8 @@ struct dict_index_struct{ ...@@ -209,6 +194,8 @@ struct dict_index_struct{
ulint stat_n_leaf_pages; ulint stat_n_leaf_pages;
/* approximate number of leaf pages in the /* approximate number of leaf pages in the
index tree */ index tree */
rw_lock_t lock; /* read-write lock protecting the upper levels
of the index tree */
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
ulint magic_n;/* magic number */ ulint magic_n;/* magic number */
# define DICT_INDEX_MAGIC_N 76789786 # define DICT_INDEX_MAGIC_N 76789786
......
...@@ -13,7 +13,6 @@ typedef struct dict_sys_struct dict_sys_t; ...@@ -13,7 +13,6 @@ typedef struct dict_sys_struct dict_sys_t;
typedef struct dict_col_struct dict_col_t; typedef struct dict_col_struct dict_col_t;
typedef struct dict_field_struct dict_field_t; typedef struct dict_field_struct dict_field_t;
typedef struct dict_index_struct dict_index_t; typedef struct dict_index_struct dict_index_t;
typedef struct dict_tree_struct dict_tree_t;
typedef struct dict_table_struct dict_table_t; typedef struct dict_table_struct dict_table_t;
typedef struct dict_foreign_struct dict_foreign_t; typedef struct dict_foreign_struct dict_foreign_t;
......
...@@ -4004,7 +4004,7 @@ row_check_table_for_mysql( ...@@ -4004,7 +4004,7 @@ row_check_table_for_mysql(
ut_print_name(stderr, trx, FALSE, index->name); ut_print_name(stderr, trx, FALSE, index->name);
putc('\n', stderr); */ putc('\n', stderr); */
if (!btr_validate_tree(index->tree, prebuilt->trx)) { if (!btr_validate_index(index, prebuilt->trx)) {
ret = DB_ERROR; ret = DB_ERROR;
} else { } else {
if (!row_scan_and_check_index(prebuilt, if (!row_scan_and_check_index(prebuilt,
......
...@@ -430,7 +430,7 @@ row_purge_upd_exist_or_extern( ...@@ -430,7 +430,7 @@ row_purge_upd_exist_or_extern(
index = dict_table_get_first_index(node->table); index = dict_table_get_first_index(node->table);
mtr_x_lock(dict_tree_get_lock(index->tree), &mtr); mtr_x_lock(dict_index_get_lock(index), &mtr);
/* NOTE: we must also acquire an X-latch to the /* NOTE: we must also acquire an X-latch to the
root page of the tree. We will need it when we root page of the tree. We will need it when we
...@@ -441,7 +441,7 @@ row_purge_upd_exist_or_extern( ...@@ -441,7 +441,7 @@ row_purge_upd_exist_or_extern(
latching order if we would only later latch the latching order if we would only later latch the
root page of such a tree! */ root page of such a tree! */
btr_root_get(index->tree, &mtr); btr_root_get(index, &mtr);
/* We assume in purge of externally stored fields /* We assume in purge of externally stored fields
that the space id of the undo log record is 0! */ that the space id of the undo log record is 0! */
......
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