Commit dc9107df 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 7bb535bb
......@@ -77,16 +77,6 @@ make them consecutive on disk if possible. From the other file segment
we allocate pages for the non-leaf levels of the tree.
*/
/******************************************************************
Creates a new index page to the tree (not the root, and also not
used in page reorganization). */
static
void
btr_page_create(
/*============*/
page_t* page, /* in: page to be created */
dict_tree_t* tree, /* in: index tree */
mtr_t* mtr); /* in: mtr */
/****************************************************************
Returns the upper level node pointer to a page. It is assumed that
mtr holds an x-latch on the tree. */
......@@ -95,7 +85,7 @@ rec_t*
btr_page_get_father_node_ptr(
/*=========================*/
/* out: pointer to node pointer record */
dict_tree_t* tree, /* in: index tree */
dict_index_t* index, /* in: index tree */
page_t* page, /* in: page: must contain at least one
user record */
mtr_t* mtr); /* in: mtr */
......@@ -132,19 +122,18 @@ page_t*
btr_root_get(
/*=========*/
/* out: root page, x-latched */
dict_tree_t* tree, /* in: index tree */
dict_index_t* index, /* in: index tree */
mtr_t* mtr) /* in: mtr */
{
ulint space;
ulint root_page_no;
page_t* root;
space = dict_tree_get_space(tree);
root_page_no = dict_tree_get_page(tree);
space = dict_index_get_space(index);
root_page_no = dict_index_get_page(index);
root = btr_page_get(space, root_page_no, RW_X_LATCH, mtr);
ut_a((ibool)!!page_is_comp(root)
== dict_table_is_comp(tree->tree_index->table));
ut_a((ibool)!!page_is_comp(root) == dict_table_is_comp(index->table));
return(root);
}
......@@ -254,23 +243,22 @@ btr_get_next_user_rec(
}
/******************************************************************
Creates a new index page to the tree (not the root, and also not used in
page reorganization). */
Creates a new index page (not the root, and also not
used in page reorganization). */
static
void
btr_page_create(
/*============*/
page_t* page, /* in: page to be created */
dict_tree_t* tree, /* in: index tree */
dict_index_t* index, /* in: index */
mtr_t* mtr) /* in: mtr */
{
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX));
page_create(page, mtr,
dict_table_is_comp(tree->tree_index->table));
page_create(page, mtr, dict_table_is_comp(index->table));
buf_block_align(page)->check_index_page_at_flush = TRUE;
btr_page_set_index_id(page, tree->id, mtr);
btr_page_set_index_id(page, index->id, mtr);
}
/******************************************************************
......@@ -281,20 +269,20 @@ page_t*
btr_page_alloc_for_ibuf(
/*====================*/
/* out: new allocated page, x-latched */
dict_tree_t* tree, /* in: index tree */
dict_index_t* index, /* in: index tree */
mtr_t* mtr) /* in: mtr */
{
fil_addr_t node_addr;
page_t* root;
page_t* new_page;
root = btr_root_get(tree, mtr);
root = btr_root_get(index, mtr);
node_addr = flst_get_first(root + PAGE_HEADER
+ PAGE_BTR_IBUF_FREE_LIST, mtr);
ut_a(node_addr.page != FIL_NULL);
new_page = buf_page_get(dict_tree_get_space(tree), node_addr.page,
new_page = buf_page_get(dict_index_get_space(index), node_addr.page,
RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(new_page, SYNC_TREE_NODE_NEW);
......@@ -318,7 +306,7 @@ btr_page_alloc(
/*===========*/
/* out: new allocated page, x-latched;
NULL if out of space */
dict_tree_t* tree, /* in: index tree */
dict_index_t* index, /* in: index */
ulint hint_page_no, /* in: hint of a good page */
byte file_direction, /* in: direction where a possible
page split is made */
......@@ -331,12 +319,12 @@ btr_page_alloc(
page_t* new_page;
ulint new_page_no;
if (tree->type & DICT_IBUF) {
if (index->type & DICT_IBUF) {
return(btr_page_alloc_for_ibuf(tree, mtr));
return(btr_page_alloc_for_ibuf(index, mtr));
}
root = btr_root_get(tree, mtr);
root = btr_root_get(index, mtr);
if (level == 0) {
seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF;
......@@ -355,7 +343,7 @@ btr_page_alloc(
return(NULL);
}
new_page = buf_page_get(dict_tree_get_space(tree), new_page_no,
new_page = buf_page_get(dict_index_get_space(index), new_page_no,
RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(new_page, SYNC_TREE_NODE_NEW);
......@@ -382,9 +370,9 @@ btr_get_size(
mtr_start(&mtr);
mtr_s_lock(dict_tree_get_lock(index->tree), &mtr);
mtr_s_lock(dict_index_get_lock(index), &mtr);
root = btr_root_get(index->tree, &mtr);
root = btr_root_get(index, &mtr);
if (flag == BTR_N_LEAF_PAGES) {
seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF;
......@@ -415,7 +403,7 @@ static
void
btr_page_free_for_ibuf(
/*===================*/
dict_tree_t* tree, /* in: index tree */
dict_index_t* index, /* in: index tree */
page_t* page, /* in: page to be freed, x-latched */
mtr_t* mtr) /* in: mtr */
{
......@@ -423,7 +411,7 @@ btr_page_free_for_ibuf(
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX));
root = btr_root_get(tree, mtr);
root = btr_root_get(index, mtr);
flst_add_first(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST,
page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, mtr);
......@@ -440,7 +428,7 @@ argument. */
void
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 */
ulint level, /* in: page level */
mtr_t* mtr) /* in: mtr */
......@@ -457,14 +445,14 @@ btr_page_free_low(
buf_frame_modify_clock_inc(page);
if (tree->type & DICT_IBUF) {
if (index->type & DICT_IBUF) {
btr_page_free_for_ibuf(tree, page, mtr);
btr_page_free_for_ibuf(index, page, mtr);
return;
}
root = btr_root_get(tree, mtr);
root = btr_root_get(index, mtr);
if (level == 0) {
seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF;
......@@ -485,7 +473,7 @@ storage pages because the page must contain info on its level. */
void
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 */
mtr_t* mtr) /* in: mtr */
{
......@@ -495,7 +483,7 @@ btr_page_free(
MTR_MEMO_PAGE_X_FIX));
level = btr_page_get_level(page, mtr);
btr_page_free_low(tree, page, level, mtr);
btr_page_free_low(index, page, level, mtr);
}
/******************************************************************
......@@ -558,7 +546,7 @@ btr_page_get_father_for_rec(
/*========================*/
/* out: pointer to node pointer record,
its page x-latched */
dict_tree_t* tree, /* in: index tree */
dict_index_t* index, /* in: index tree */
page_t* page, /* in: page: must contain at least one
user record */
rec_t* user_rec,/* in: user_record on page */
......@@ -568,22 +556,20 @@ btr_page_get_father_for_rec(
dtuple_t* tuple;
btr_cur_t cursor;
rec_t* node_ptr;
dict_index_t* index;
ulint offsets_[REC_OFFS_NORMAL_SIZE];
ulint* offsets = offsets_;
*offsets_ = (sizeof offsets_) / sizeof *offsets_;
ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(tree),
ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
ut_a(page_rec_is_user_rec(user_rec));
ut_ad(dict_tree_get_page(tree) != buf_frame_get_page_no(page));
ut_ad(dict_index_get_page(index) != buf_frame_get_page_no(page));
heap = mem_heap_create(100);
tuple = dict_tree_build_node_ptr(tree, user_rec, 0, heap,
btr_page_get_level(page, mtr));
index = tree->tree_index;
tuple = dict_index_build_node_ptr(index, user_rec, 0, heap,
btr_page_get_level(page, mtr));
/* In the following, we choose just any index from the tree as the
first parameter for btr_cur_search_to_nth_level. */
......@@ -647,13 +633,13 @@ rec_t*
btr_page_get_father_node_ptr(
/*=========================*/
/* out: pointer to node pointer record */
dict_tree_t* tree, /* in: index tree */
dict_index_t* index, /* in: index tree */
page_t* page, /* in: page: must contain at least one
user record */
mtr_t* mtr) /* in: mtr */
{
return(btr_page_get_father_for_rec
(tree, page,
(index, page,
page_rec_get_next(page_get_infimum_rec(page)), mtr));
}
......@@ -1000,7 +986,7 @@ btr_root_raise_and_insert(
dtuple_t* tuple, /* in: tuple to insert */
mtr_t* mtr) /* in: mtr */
{
dict_tree_t* tree;
dict_index_t* index;
page_t* root;
page_t* new_page;
ulint new_page_no;
......@@ -1012,10 +998,10 @@ btr_root_raise_and_insert(
page_cur_t* page_cursor;
root = btr_cur_get_page(cursor);
tree = btr_cur_get_tree(cursor);
index = btr_cur_get_index(cursor);
ut_ad(dict_tree_get_page(tree) == buf_frame_get_page_no(root));
ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(tree),
ut_ad(dict_index_get_page(index) == buf_frame_get_page_no(root));
ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(mtr, buf_block_align(root),
MTR_MEMO_PAGE_X_FIX));
......@@ -1025,10 +1011,10 @@ btr_root_raise_and_insert(
moving the root records to the new page, emptying the root, putting
a node pointer to the new page, and then splitting the new page. */
new_page = btr_page_alloc(tree, 0, FSP_NO_DIR,
new_page = btr_page_alloc(index, 0, FSP_NO_DIR,
btr_page_get_level(root, mtr), mtr);
btr_page_create(new_page, tree, mtr);
btr_page_create(new_page, index, mtr);
level = btr_page_get_level(root, mtr);
......@@ -1043,7 +1029,7 @@ btr_root_raise_and_insert(
/* Move the records from root to the new page */
page_move_rec_list_end(new_page, root, page_get_infimum_rec(root),
cursor->index, mtr);
index, mtr);
/* If this is a pessimistic insert which is actually done to
perform a pessimistic update then we have stored the lock
information of the record to be inserted on the infimum of the
......@@ -1060,10 +1046,10 @@ btr_root_raise_and_insert(
/* Build the node pointer (= node key and page address) for the
child */
node_ptr = dict_tree_build_node_ptr(tree, rec, new_page_no, heap,
level);
node_ptr = dict_index_build_node_ptr(index, rec, new_page_no, heap,
level);
/* Reorganize the root to get free space */
btr_page_reorganize(root, cursor->index, mtr);
btr_page_reorganize(root, index, mtr);
page_cursor = btr_cur_get_page_cur(cursor);
......@@ -1072,7 +1058,7 @@ btr_root_raise_and_insert(
page_cur_set_before_first(root, page_cursor);
node_ptr_rec = page_cur_tuple_insert(page_cursor, node_ptr,
cursor->index, mtr);
index, mtr);
ut_ad(node_ptr_rec);
......@@ -1092,9 +1078,9 @@ btr_root_raise_and_insert(
buf_frame_get_page_no(new_page));
#endif
ibuf_reset_free_bits(tree->tree_index, new_page);
ibuf_reset_free_bits(index, new_page);
/* Reposition the cursor to the child node */
page_cur_search(new_page, cursor->index, tuple,
page_cur_search(new_page, index, tuple,
PAGE_CUR_LE, page_cursor);
/* Split the child and insert tuple */
......@@ -1419,7 +1405,7 @@ that mtr holds an x-latch on the tree. */
void
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 */
dtuple_t* tuple, /* in: the record to be inserted */
mtr_t* mtr) /* in: mtr */
......@@ -1431,11 +1417,7 @@ btr_insert_on_non_leaf_level(
ut_ad(level > 0);
/* In the following, choose just any index from the tree as the
first parameter for btr_cur_search_to_nth_level. */
btr_cur_search_to_nth_level(tree->tree_index,
level, tuple, PAGE_CUR_LE,
btr_cur_search_to_nth_level(index, level, tuple, PAGE_CUR_LE,
BTR_CONT_MODIFY_TREE,
&cursor, 0, mtr);
......@@ -1454,7 +1436,7 @@ static
void
btr_attach_half_pages(
/*==================*/
dict_tree_t* tree, /* in: the index tree */
dict_index_t* index, /* in: the index tree */
page_t* page, /* in: page to be split */
rec_t* split_rec, /* in: first record on upper
half page */
......@@ -1493,14 +1475,14 @@ btr_attach_half_pages(
lower_page = new_page;
upper_page = page;
/* Look from the tree for the node pointer to page */
node_ptr = btr_page_get_father_node_ptr(tree, page, mtr);
/* Look up the index for the node pointer to page */
node_ptr = btr_page_get_father_node_ptr(index, page, mtr);
/* Replace the address of the old child node (= page) with the
address of the new lower half */
btr_node_ptr_set_child_page_no(node_ptr, rec_get_offsets
(node_ptr, tree->tree_index,
(node_ptr, index,
NULL, ULINT_UNDEFINED, &heap),
lower_page_no, mtr);
mem_heap_empty(heap);
......@@ -1517,13 +1499,13 @@ btr_attach_half_pages(
/* Build the node pointer (= node key and page address) for the upper
half */
node_ptr_upper = dict_tree_build_node_ptr(tree, split_rec,
upper_page_no, heap, level);
node_ptr_upper = dict_index_build_node_ptr(index, split_rec,
upper_page_no, heap, level);
/* Insert it next to the pointer to the lower half. Note that this
may generate recursion leading to a split on the higher level. */
btr_insert_on_non_leaf_level(tree, level + 1, node_ptr_upper, mtr);
btr_insert_on_non_leaf_level(index, level + 1, node_ptr_upper, mtr);
/* Free the memory heap */
mem_heap_free(heap);
......@@ -1585,7 +1567,6 @@ btr_page_split_and_insert(
dtuple_t* tuple, /* in: tuple to insert */
mtr_t* mtr) /* in: mtr */
{
dict_tree_t* tree;
page_t* page;
ulint page_no;
byte direction;
......@@ -1611,12 +1592,11 @@ btr_page_split_and_insert(
func_start:
mem_heap_empty(heap);
offsets = NULL;
tree = btr_cur_get_tree(cursor);
ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(tree),
ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(cursor->index),
MTR_MEMO_X_LOCK));
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(dict_tree_get_lock(tree), RW_LOCK_EX));
ut_ad(rw_lock_own(dict_index_get_lock(cursor->index), RW_LOCK_EX));
#endif /* UNIV_SYNC_DEBUG */
page = btr_cur_get_page(cursor);
......@@ -1649,10 +1629,10 @@ btr_page_split_and_insert(
split_rec = page_get_middle_rec(page);
}
/* 2. Allocate a new page to the tree */
new_page = btr_page_alloc(tree, hint_page_no, direction,
/* 2. Allocate a new page to the index */
new_page = btr_page_alloc(cursor->index, hint_page_no, direction,
btr_page_get_level(page, mtr), mtr);
btr_page_create(new_page, tree, mtr);
btr_page_create(new_page, cursor->index, mtr);
/* 3. Calculate the first record on the upper half-page, and the
first record (move_limit) on original page which ends up on the
......@@ -1671,7 +1651,8 @@ btr_page_split_and_insert(
/* 4. Do first the modifications in the tree structure */
btr_attach_half_pages(tree, page, first_rec, new_page, direction, mtr);
btr_attach_half_pages(cursor->index, page, first_rec,
new_page, direction, mtr);
if (split_rec == NULL) {
mem_free(buf);
......@@ -1697,7 +1678,7 @@ btr_page_split_and_insert(
if (insert_will_fit && (btr_page_get_level(page, mtr) == 0)) {
mtr_memo_release(mtr, dict_tree_get_lock(tree),
mtr_memo_release(mtr, dict_index_get_lock(cursor->index),
MTR_MEMO_X_LOCK);
}
......@@ -1797,8 +1778,8 @@ btr_page_split_and_insert(
buf_frame_get_page_no(right_page));
#endif
ut_ad(page_validate(left_page, tree->tree_index));
ut_ad(page_validate(right_page, tree->tree_index));
ut_ad(page_validate(left_page, cursor->index));
ut_ad(page_validate(right_page, cursor->index));
mem_heap_free(heap);
return(rec);
......@@ -1810,7 +1791,6 @@ static
void
btr_level_list_remove(
/*==================*/
dict_tree_t* tree __attribute__((unused)), /* in: index tree */
page_t* page, /* in: page to remove */
mtr_t* mtr) /* in: mtr */
{
......@@ -1820,7 +1800,7 @@ btr_level_list_remove(
ulint next_page_no;
page_t* next_page;
ut_ad(tree && page && mtr);
ut_ad(page && mtr);
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX));
/* Get the previous and next page numbers of page */
......@@ -1932,7 +1912,7 @@ Deletes on the upper level the node pointer to a page. */
void
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 */
mtr_t* mtr) /* in: mtr */
{
......@@ -1945,9 +1925,9 @@ btr_node_ptr_delete(
MTR_MEMO_PAGE_X_FIX));
/* Delete node pointer on father page */
node_ptr = btr_page_get_father_node_ptr(tree, page, mtr);
node_ptr = btr_page_get_father_node_ptr(index, page, mtr);
btr_cur_position(tree->tree_index, node_ptr, &cursor);
btr_cur_position(index, node_ptr, &cursor);
compressed = btr_cur_pessimistic_delete(&err, TRUE, &cursor, FALSE,
mtr);
ut_a(err == DB_SUCCESS);
......@@ -1964,7 +1944,7 @@ static
void
btr_lift_page_up(
/*=============*/
dict_tree_t* tree, /* in: index tree */
dict_index_t* index, /* in: index tree */
page_t* page, /* in: page which is the only on its level;
must not be empty: use
btr_discard_only_page_on_level if the last
......@@ -1973,17 +1953,15 @@ btr_lift_page_up(
{
page_t* father_page;
ulint page_level;
dict_index_t* index;
ut_ad(btr_page_get_prev(page, mtr) == FIL_NULL);
ut_ad(btr_page_get_next(page, mtr) == FIL_NULL);
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX));
father_page = buf_frame_align
(btr_page_get_father_node_ptr(tree, page, mtr));
(btr_page_get_father_node_ptr(index, page, mtr));
page_level = btr_page_get_level(page, mtr);
index = tree->tree_index;
btr_search_drop_page_hash_index(page);
......@@ -1998,12 +1976,12 @@ btr_lift_page_up(
btr_page_set_level(father_page, page_level, mtr);
/* Free the file page */
btr_page_free(tree, page, mtr);
btr_page_free(index, page, mtr);
/* We play safe and reset the free bits for the father */
ibuf_reset_free_bits(index, father_page);
ut_ad(page_validate(father_page, index));
ut_ad(btr_check_node_ptr(tree, father_page, mtr));
ut_ad(btr_check_node_ptr(index, father_page, mtr));
}
/*****************************************************************
......@@ -2026,7 +2004,7 @@ btr_compress(
empty */
mtr_t* mtr) /* in: mtr */
{
dict_tree_t* tree;
dict_index_t* index;
ulint space;
ulint left_page_no;
ulint right_page_no;
......@@ -2045,16 +2023,16 @@ btr_compress(
ulint comp;
page = btr_cur_get_page(cursor);
tree = btr_cur_get_tree(cursor);
index = btr_cur_get_index(cursor);
comp = page_is_comp(page);
ut_a((ibool)!!comp == dict_table_is_comp(cursor->index->table));
ut_a((ibool)!!comp == dict_table_is_comp(index->table));
ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(tree),
ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX));
level = btr_page_get_level(page, mtr);
space = dict_tree_get_space(tree);
space = dict_index_get_space(index);
left_page_no = btr_page_get_prev(page, mtr);
right_page_no = btr_page_get_next(page, mtr);
......@@ -2064,7 +2042,7 @@ btr_compress(
left_page_no, right_page_no);
#endif
node_ptr = btr_page_get_father_node_ptr(tree, page, mtr);
node_ptr = btr_page_get_father_node_ptr(index, page, mtr);
ut_ad(!comp || rec_get_status(node_ptr) == REC_STATUS_NODE_PTR);
father_page = buf_frame_align(node_ptr);
ut_a(comp == page_is_comp(father_page));
......@@ -2093,7 +2071,7 @@ btr_compress(
} else {
/* The page is the only one on the level, lift the records
to the father */
btr_lift_page_up(tree, page, mtr);
btr_lift_page_up(index, page, mtr);
return;
}
......@@ -2111,7 +2089,7 @@ btr_compress(
return;
}
ut_ad(page_validate(merge_page, cursor->index));
ut_ad(page_validate(merge_page, index));
max_ins_size = page_get_max_insert_size(merge_page, n_recs);
......@@ -2119,11 +2097,11 @@ btr_compress(
/* We have to reorganize merge_page */
btr_page_reorganize(merge_page, cursor->index, mtr);
btr_page_reorganize(merge_page, index, mtr);
max_ins_size = page_get_max_insert_size(merge_page, n_recs);
ut_ad(page_validate(merge_page, cursor->index));
ut_ad(page_validate(merge_page, index));
ut_ad(page_get_max_insert_size(merge_page, n_recs)
== max_ins_size_reorg);
}
......@@ -2138,10 +2116,10 @@ btr_compress(
btr_search_drop_page_hash_index(page);
/* Remove the page from the level list */
btr_level_list_remove(tree, page, mtr);
btr_level_list_remove(page, mtr);
if (is_left) {
btr_node_ptr_delete(tree, page, mtr);
btr_node_ptr_delete(index, page, mtr);
} else {
mem_heap_t* heap = NULL;
ulint offsets_[REC_OFFS_NORMAL_SIZE];
......@@ -2150,14 +2128,14 @@ btr_compress(
address of the merge page to the right */
btr_node_ptr_set_child_page_no(node_ptr, rec_get_offsets
(node_ptr, cursor->index,
(node_ptr, index,
offsets_, ULINT_UNDEFINED,
&heap),
right_page_no, mtr);
if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap);
}
btr_node_ptr_delete(tree, merge_page, mtr);
btr_node_ptr_delete(index, merge_page, mtr);
}
/* Move records to the merge page */
......@@ -2166,7 +2144,7 @@ btr_compress(
(page_get_supremum_rec(merge_page));
page_copy_rec_list_start(merge_page, page,
page_get_supremum_rec(page),
cursor->index, mtr);
index, mtr);
lock_update_merge_left(merge_page, orig_pred, page);
} else {
......@@ -2174,21 +2152,21 @@ btr_compress(
(page_get_infimum_rec(merge_page));
page_copy_rec_list_end(merge_page, page,
page_get_infimum_rec(page),
cursor->index, mtr);
index, mtr);
lock_update_merge_right(orig_succ, page);
}
/* We have added new records to merge_page: update its free bits */
ibuf_update_free_bits_if_full(cursor->index, merge_page,
ibuf_update_free_bits_if_full(index, merge_page,
UNIV_PAGE_SIZE, ULINT_UNDEFINED);
ut_ad(page_validate(merge_page, cursor->index));
ut_ad(page_validate(merge_page, index));
/* Free the file page */
btr_page_free(tree, page, mtr);
btr_page_free(index, page, mtr);
ut_ad(btr_check_node_ptr(tree, merge_page, mtr));
ut_ad(btr_check_node_ptr(index, merge_page, mtr));
}
/*****************************************************************
......@@ -2197,7 +2175,7 @@ static
void
btr_discard_only_page_on_level(
/*===========================*/
dict_tree_t* tree, /* in: index tree */
dict_index_t* index, /* in: index tree */
page_t* page, /* in: page which is the only on its level */
mtr_t* mtr) /* in: mtr */
{
......@@ -2211,7 +2189,7 @@ btr_discard_only_page_on_level(
MTR_MEMO_PAGE_X_FIX));
btr_search_drop_page_hash_index(page);
node_ptr = btr_page_get_father_node_ptr(tree, page, mtr);
node_ptr = btr_page_get_father_node_ptr(index, page, mtr);
father_page = buf_frame_align(node_ptr);
page_level = btr_page_get_level(page, mtr);
......@@ -2221,19 +2199,19 @@ btr_discard_only_page_on_level(
btr_page_set_level(father_page, page_level, mtr);
/* Free the file page */
btr_page_free(tree, page, mtr);
btr_page_free(index, page, mtr);
if (buf_frame_get_page_no(father_page) == dict_tree_get_page(tree)) {
if (buf_frame_get_page_no(father_page) == dict_index_get_page(index)) {
/* The father is the root page */
btr_page_empty(father_page, mtr);
/* We play safe and reset the free bits for the father */
ibuf_reset_free_bits(tree->tree_index, father_page);
ibuf_reset_free_bits(index, father_page);
} else {
ut_ad(page_get_n_recs(father_page) == 1);
btr_discard_only_page_on_level(tree, father_page, mtr);
btr_discard_only_page_on_level(index, father_page, mtr);
}
}
......@@ -2249,7 +2227,7 @@ btr_discard_page(
the root page */
mtr_t* mtr) /* in: mtr */
{
dict_tree_t* tree;
dict_index_t* index;
ulint space;
ulint left_page_no;
ulint right_page_no;
......@@ -2258,14 +2236,14 @@ btr_discard_page(
rec_t* node_ptr;
page = btr_cur_get_page(cursor);
tree = btr_cur_get_tree(cursor);
index = btr_cur_get_index(cursor);
ut_ad(dict_tree_get_page(tree) != buf_frame_get_page_no(page));
ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(tree),
ut_ad(dict_index_get_page(index) != buf_frame_get_page_no(page));
ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX));
space = dict_tree_get_space(tree);
space = dict_index_get_space(index);
/* Decide the page which will inherit the locks */
......@@ -2287,7 +2265,7 @@ btr_discard_page(
== buf_frame_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
} else {
btr_discard_only_page_on_level(tree, page, mtr);
btr_discard_only_page_on_level(index, page, mtr);
return;
}
......@@ -2307,10 +2285,10 @@ btr_discard_page(
btr_set_min_rec_mark(node_ptr, page_is_comp(merge_page), mtr);
}
btr_node_ptr_delete(tree, page, mtr);
btr_node_ptr_delete(index, page, mtr);
/* Remove the page from the level list */
btr_level_list_remove(tree, page, mtr);
btr_level_list_remove(page, mtr);
if (left_page_no != FIL_NULL) {
lock_update_discard(page_get_supremum_rec(merge_page), page);
......@@ -2320,9 +2298,9 @@ btr_discard_page(
}
/* Free the file page */
btr_page_free(tree, page, mtr);
btr_page_free(index, page, mtr);
ut_ad(btr_check_node_ptr(tree, merge_page, mtr));
ut_ad(btr_check_node_ptr(index, merge_page, mtr));
}
#ifdef UNIV_BTR_PRINT
......@@ -2332,13 +2310,13 @@ Prints size info of a B-tree. */
void
btr_print_size(
/*===========*/
dict_tree_t* tree) /* in: index tree */
dict_index_t* index) /* in: index tree */
{
page_t* root;
fseg_header_t* seg;
mtr_t mtr;
if (tree->type & DICT_IBUF) {
if (index->type & DICT_IBUF) {
fputs("Sorry, cannot print info of an ibuf tree:"
" use ibuf functions\n", stderr);
......@@ -2347,14 +2325,14 @@ btr_print_size(
mtr_start(&mtr);
root = btr_root_get(tree, &mtr);
root = btr_root_get(index, &mtr);
seg = root + PAGE_HEADER + PAGE_BTR_SEG_TOP;
fputs("INFO OF THE NON-LEAF PAGE SEGMENT\n", stderr);
fseg_print(seg, &mtr);
if (!(tree->type & DICT_UNIVERSAL)) {
if (!(index->type & DICT_UNIVERSAL)) {
seg = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF;
......@@ -2371,7 +2349,7 @@ static
void
btr_print_recursive(
/*================*/
dict_tree_t* tree, /* in: index tree */
dict_index_t* index, /* in: index tree */
page_t* page, /* in: index page */
ulint width, /* in: print this many entries from start
and end */
......@@ -2385,7 +2363,6 @@ btr_print_recursive(
mtr_t mtr2;
rec_t* node_ptr;
page_t* child;
dict_index_t* index;
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX));
......@@ -2393,7 +2370,6 @@ btr_print_recursive(
(ulong) btr_page_get_level(page, mtr),
(ulong) buf_frame_get_page_no(page));
index = tree->tree_index;
page_print(page, index, width, width);
n_recs = page_get_n_recs(page);
......@@ -2417,7 +2393,7 @@ btr_print_recursive(
ULINT_UNDEFINED, heap);
child = btr_node_ptr_get_child(node_ptr,
*offsets, &mtr2);
btr_print_recursive(tree, child, width,
btr_print_recursive(index, child, width,
heap, offsets, &mtr2);
mtr_commit(&mtr2);
}
......@@ -2431,9 +2407,9 @@ btr_print_recursive(
Prints directories and other info of all nodes in the tree. */
void
btr_print_tree(
/*===========*/
dict_tree_t* tree, /* in: tree */
btr_print_index(
/*============*/
dict_index_t* index, /* in: index */
ulint width) /* in: print this many entries from start
and end */
{
......@@ -2449,16 +2425,16 @@ btr_print_tree(
mtr_start(&mtr);
root = btr_root_get(tree, &mtr);
root = btr_root_get(index, &mtr);
btr_print_recursive(tree, root, width, &heap, &offsets, &mtr);
btr_print_recursive(index, root, width, &heap, &offsets, &mtr);
if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap);
}
mtr_commit(&mtr);
btr_validate_tree(tree, NULL);
btr_validate_index(index, NULL);
}
#endif /* UNIV_BTR_PRINT */
......@@ -2470,7 +2446,7 @@ ibool
btr_check_node_ptr(
/*===============*/
/* out: TRUE */
dict_tree_t* tree, /* in: index tree */
dict_index_t* index, /* in: index tree */
page_t* page, /* in: index page */
mtr_t* mtr) /* in: mtr */
{
......@@ -2480,12 +2456,12 @@ btr_check_node_ptr(
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX));
if (dict_tree_get_page(tree) == buf_frame_get_page_no(page)) {
if (dict_index_get_page(index) == buf_frame_get_page_no(page)) {
return(TRUE);
}
node_ptr = btr_page_get_father_node_ptr(tree, page, mtr);
node_ptr = btr_page_get_father_node_ptr(index, page, mtr);
if (btr_page_get_level(page, mtr) == 0) {
......@@ -2494,12 +2470,12 @@ btr_check_node_ptr(
heap = mem_heap_create(256);
node_ptr_tuple = dict_tree_build_node_ptr
(tree, page_rec_get_next(page_get_infimum_rec(page)),
node_ptr_tuple = dict_index_build_node_ptr
(index, page_rec_get_next(page_get_infimum_rec(page)),
0, heap, btr_page_get_level(page, mtr));
ut_a(!cmp_dtuple_rec(node_ptr_tuple, node_ptr,
rec_get_offsets(node_ptr, tree->tree_index,
rec_get_offsets(node_ptr, index,
NULL, ULINT_UNDEFINED, &heap)));
mem_heap_free(heap);
......@@ -2670,6 +2646,7 @@ Report an error on one page of an index tree. */
static
void
btr_validate_report1(
/*=================*/
/* out: TRUE if ok */
dict_index_t* index, /* in: index */
ulint level, /* in: B-tree level */
......@@ -2689,6 +2666,7 @@ Report an error on two pages of an index tree. */
static
void
btr_validate_report2(
/*=================*/
/* out: TRUE if ok */
dict_index_t* index, /* in: index */
ulint level, /* in: B-tree level */
......@@ -2712,7 +2690,7 @@ ibool
btr_validate_level(
/*===============*/
/* out: TRUE if ok */
dict_tree_t* tree, /* in: index tree */
dict_index_t* index, /* in: index tree */
trx_t* trx, /* in: transaction or NULL */
ulint level) /* in: level number */
{
......@@ -2729,7 +2707,6 @@ btr_validate_level(
page_cur_t cursor;
dtuple_t* node_ptr_tuple;
ibool ret = TRUE;
dict_index_t* index;
mtr_t mtr;
mem_heap_t* heap = mem_heap_create(256);
ulint* offsets = NULL;
......@@ -2737,14 +2714,12 @@ btr_validate_level(
mtr_start(&mtr);
mtr_x_lock(dict_tree_get_lock(tree), &mtr);
mtr_x_lock(dict_index_get_lock(index), &mtr);
page = btr_root_get(tree, &mtr);
page = btr_root_get(index, &mtr);
space = buf_frame_get_space_id(page);
index = tree->tree_index;
while (level != btr_page_get_level(page, &mtr)) {
ut_a(btr_page_get_level(page, &mtr) > 0);
......@@ -2768,7 +2743,7 @@ btr_validate_level(
}
mem_heap_empty(heap);
offsets = offsets2 = NULL;
mtr_x_lock(dict_tree_get_lock(tree), &mtr);
mtr_x_lock(dict_index_get_lock(index), &mtr);
/* Check ordering etc. of records */
......@@ -2794,7 +2769,7 @@ btr_validate_level(
ut_a((page_get_n_recs(page) > 0)
|| ((level == 0)
&& (buf_frame_get_page_no(page)
== dict_tree_get_page(tree))));
== dict_index_get_page(index))));
if (right_page_no != FIL_NULL) {
rec_t* right_rec;
......@@ -2862,11 +2837,11 @@ btr_validate_level(
page_is_comp(page)));
}
if (buf_frame_get_page_no(page) != dict_tree_get_page(tree)) {
if (buf_frame_get_page_no(page) != dict_index_get_page(index)) {
/* Check father node pointers */
node_ptr = btr_page_get_father_node_ptr(tree, page, &mtr);
node_ptr = btr_page_get_father_node_ptr(index, page, &mtr);
father_page = buf_frame_align(node_ptr);
offsets = rec_get_offsets(node_ptr, index,
offsets, ULINT_UNDEFINED, &heap);
......@@ -2874,7 +2849,7 @@ btr_validate_level(
if (btr_node_ptr_get_child_page_no(node_ptr, offsets)
!= buf_frame_get_page_no(page)
|| node_ptr != btr_page_get_father_for_rec
(tree, page,
(index, page,
page_rec_get_prev(page_get_supremum_rec(page)), &mtr)) {
btr_validate_report1(index, level, page);
......@@ -2894,7 +2869,7 @@ btr_validate_level(
fputs("InnoDB: record on page ", stderr);
rec = btr_page_get_father_for_rec
(tree, page, page_rec_get_prev
(index, page, page_rec_get_prev
(page_get_supremum_rec(page)), &mtr);
rec_print(stderr, rec, index);
putc('\n', stderr);
......@@ -2908,8 +2883,8 @@ btr_validate_level(
offsets, ULINT_UNDEFINED,
&heap);
node_ptr_tuple = dict_tree_build_node_ptr
(tree,
node_ptr_tuple = dict_index_build_node_ptr
(index,
page_rec_get_next(page_get_infimum_rec(page)),
0, heap, btr_page_get_level(page, &mtr));
......@@ -2948,7 +2923,7 @@ btr_validate_level(
ut_a(btr_page_get_next(father_page, &mtr) == FIL_NULL);
} else {
right_node_ptr = btr_page_get_father_node_ptr
(tree, right_page, &mtr);
(index, right_page, &mtr);
if (page_rec_get_next(node_ptr)
!= page_get_supremum_rec(father_page)) {
......@@ -3029,10 +3004,10 @@ btr_validate_level(
Checks the consistency of an index tree. */
ibool
btr_validate_tree(
/*==============*/
btr_validate_index(
/*===============*/
/* out: TRUE if ok */
dict_tree_t* tree, /* in: tree */
dict_index_t* index, /* in: index */
trx_t* trx) /* in: transaction or NULL */
{
mtr_t mtr;
......@@ -3041,13 +3016,13 @@ btr_validate_tree(
ulint n;
mtr_start(&mtr);
mtr_x_lock(dict_tree_get_lock(tree), &mtr);
mtr_x_lock(dict_index_get_lock(index), &mtr);
root = btr_root_get(tree, &mtr);
root = btr_root_get(index, &mtr);
n = btr_page_get_level(root, &mtr);
for (i = 0; i <= n && !trx_is_interrupted(trx); i++) {
if (!btr_validate_level(tree, trx, n - i)) {
if (!btr_validate_level(index, trx, n - i)) {
mtr_commit(&mtr);
......
......@@ -272,7 +272,6 @@ btr_cur_search_to_nth_level(
RW_S_LATCH, or 0 */
mtr_t* mtr) /* in: mtr */
{
dict_tree_t* tree;
page_cur_t* page_cursor;
page_t* page;
page_t* guess;
......@@ -303,7 +302,7 @@ btr_cur_search_to_nth_level(
ending to upper levels */
ut_ad(level == 0 || mode == PAGE_CUR_LE);
ut_ad(dict_tree_check_search_tuple(index->tree, tuple));
ut_ad(dict_index_check_search_tuple(index, tuple));
ut_ad(!(index->type & DICT_IBUF) || ibuf_inside());
ut_ad(dtuple_check_typed(tuple));
......@@ -374,23 +373,21 @@ btr_cur_search_to_nth_level(
savepoint = mtr_set_savepoint(mtr);
tree = index->tree;
if (latch_mode == BTR_MODIFY_TREE) {
mtr_x_lock(dict_tree_get_lock(tree), mtr);
mtr_x_lock(dict_index_get_lock(index), mtr);
} else if (latch_mode == BTR_CONT_MODIFY_TREE) {
/* Do nothing */
ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(tree),
ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
} else {
mtr_s_lock(dict_tree_get_lock(tree), mtr);
mtr_s_lock(dict_index_get_lock(index), mtr);
}
page_cursor = btr_cur_get_page_cur(cursor);
space = dict_tree_get_space(tree);
page_no = dict_tree_get_page(tree);
space = dict_index_get_space(index);
page_no = dict_index_get_page(index);
up_match = 0;
up_bytes = 0;
......@@ -478,7 +475,7 @@ btr_cur_search_to_nth_level(
buf_page_dbg_add_level(page, SYNC_TREE_NODE);
}
#endif
ut_ad(0 == ut_dulint_cmp(tree->id,
ut_ad(0 == ut_dulint_cmp(index->id,
btr_page_get_index_id(page)));
if (height == ULINT_UNDEFINED) {
......@@ -509,7 +506,7 @@ btr_cur_search_to_nth_level(
mtr_release_s_latch_at_savepoint
(mtr, savepoint,
dict_tree_get_lock(tree));
dict_index_get_lock(index));
}
page_mode = mode;
......@@ -598,7 +595,6 @@ btr_cur_open_at_index_side(
mtr_t* mtr) /* in: mtr */
{
page_cur_t* page_cursor;
dict_tree_t* tree;
page_t* page;
ulint page_no;
ulint space;
......@@ -615,24 +611,22 @@ btr_cur_open_at_index_side(
estimate = latch_mode & BTR_ESTIMATE;
latch_mode = latch_mode & ~BTR_ESTIMATE;
tree = index->tree;
/* Store the position of the tree latch we push to mtr so that we
know how to release it when we have latched the leaf node */
savepoint = mtr_set_savepoint(mtr);
if (latch_mode == BTR_MODIFY_TREE) {
mtr_x_lock(dict_tree_get_lock(tree), mtr);
mtr_x_lock(dict_index_get_lock(index), mtr);
} else {
mtr_s_lock(dict_tree_get_lock(tree), mtr);
mtr_s_lock(dict_index_get_lock(index), mtr);
}
page_cursor = btr_cur_get_page_cur(cursor);
cursor->index = index;
space = dict_tree_get_space(tree);
page_no = dict_tree_get_page(tree);
space = dict_index_get_space(index);
page_no = dict_index_get_page(index);
height = ULINT_UNDEFINED;
......@@ -641,7 +635,7 @@ btr_cur_open_at_index_side(
BUF_GET,
__FILE__, __LINE__,
mtr);
ut_ad(0 == ut_dulint_cmp(tree->id,
ut_ad(0 == ut_dulint_cmp(index->id,
btr_page_get_index_id(page)));
buf_block_align(page)->check_index_page_at_flush = TRUE;
......@@ -670,7 +664,7 @@ btr_cur_open_at_index_side(
mtr_release_s_latch_at_savepoint
(mtr, savepoint,
dict_tree_get_lock(tree));
dict_index_get_lock(index));
}
}
......@@ -727,7 +721,6 @@ btr_cur_open_at_rnd_pos(
mtr_t* mtr) /* in: mtr */
{
page_cur_t* page_cursor;
dict_tree_t* tree;
page_t* page;
ulint page_no;
ulint space;
......@@ -738,19 +731,17 @@ btr_cur_open_at_rnd_pos(
ulint* offsets = offsets_;
*offsets_ = (sizeof offsets_) / sizeof *offsets_;
tree = index->tree;
if (latch_mode == BTR_MODIFY_TREE) {
mtr_x_lock(dict_tree_get_lock(tree), mtr);
mtr_x_lock(dict_index_get_lock(index), mtr);
} else {
mtr_s_lock(dict_tree_get_lock(tree), mtr);
mtr_s_lock(dict_index_get_lock(index), mtr);
}
page_cursor = btr_cur_get_page_cur(cursor);
cursor->index = index;
space = dict_tree_get_space(tree);
page_no = dict_tree_get_page(tree);
space = dict_index_get_space(index);
page_no = dict_index_get_page(index);
height = ULINT_UNDEFINED;
......@@ -759,7 +750,7 @@ btr_cur_open_at_rnd_pos(
BUF_GET,
__FILE__, __LINE__,
mtr);
ut_ad(0 == ut_dulint_cmp(tree->id,
ut_ad(0 == ut_dulint_cmp(index->id,
btr_page_get_index_id(page)));
if (height == ULINT_UNDEFINED) {
......@@ -1017,7 +1008,7 @@ btr_cur_optimistic_insert(
type = index->type;
if ((type & DICT_CLUSTERED)
&& (dict_tree_get_space_reserve(index->tree) + rec_size > max_size)
&& (dict_index_get_space_reserve() + rec_size > max_size)
&& (page_get_n_recs(page) >= 2)
&& (0 == level)
&& (btr_page_get_split_rec_to_right(cursor, &dummy_rec)
......@@ -1156,7 +1147,7 @@ btr_cur_pessimistic_insert(
page = btr_cur_get_page(cursor);
ut_ad(mtr_memo_contains(mtr,
dict_tree_get_lock(btr_cur_get_tree(cursor)),
dict_index_get_lock(btr_cur_get_index(cursor)),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX));
......@@ -1218,8 +1209,7 @@ btr_cur_pessimistic_insert(
}
}
if (dict_tree_get_page(index->tree)
== buf_frame_get_page_no(page)) {
if (dict_index_get_page(index) == buf_frame_get_page_no(page)) {
/* The page is the root page */
*rec = btr_root_raise_and_insert(cursor, entry, mtr);
......@@ -1798,7 +1788,6 @@ btr_cur_pessimistic_update(
big_rec_t* dummy_big_rec;
dict_index_t* index;
page_t* page;
dict_tree_t* tree;
rec_t* rec;
page_cur_t* page_cursor;
dtuple_t* new_entry;
......@@ -1822,9 +1811,8 @@ btr_cur_pessimistic_update(
page = btr_cur_get_page(cursor);
rec = btr_cur_get_rec(cursor);
index = cursor->index;
tree = index->tree;
ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(tree),
ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX));
......@@ -2401,7 +2389,7 @@ btr_cur_compress(
mtr_t* mtr) /* in: mtr */
{
ut_ad(mtr_memo_contains(mtr,
dict_tree_get_lock(btr_cur_get_tree(cursor)),
dict_index_get_lock(btr_cur_get_index(cursor)),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(mtr, buf_block_align(btr_cur_get_rec(cursor)),
MTR_MEMO_PAGE_X_FIX));
......@@ -2427,7 +2415,7 @@ btr_cur_compress_if_useful(
mtr_t* mtr) /* in: mtr */
{
ut_ad(mtr_memo_contains(mtr,
dict_tree_get_lock(btr_cur_get_tree(cursor)),
dict_index_get_lock(btr_cur_get_index(cursor)),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(mtr, buf_block_align(btr_cur_get_rec(cursor)),
MTR_MEMO_PAGE_X_FIX));
......@@ -2534,7 +2522,7 @@ btr_cur_pessimistic_delete(
mtr_t* mtr) /* in: mtr */
{
page_t* page;
dict_tree_t* tree;
dict_index_t* index;
rec_t* rec;
dtuple_t* node_ptr;
ulint n_extents = 0;
......@@ -2546,9 +2534,9 @@ btr_cur_pessimistic_delete(
ulint* offsets;
page = btr_cur_get_page(cursor);
tree = btr_cur_get_tree(cursor);
index = btr_cur_get_index(cursor);
ut_ad(mtr_memo_contains(mtr, dict_tree_get_lock(tree),
ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX));
......@@ -2560,7 +2548,7 @@ btr_cur_pessimistic_delete(
n_extents = cursor->tree_height / 32 + 1;
success = fsp_reserve_free_extents(&n_reserved,
cursor->index->space,
index->space,
n_extents,
FSP_CLEANING, mtr);
if (!success) {
......@@ -2573,8 +2561,7 @@ btr_cur_pessimistic_delete(
heap = mem_heap_create(1024);
rec = btr_cur_get_rec(cursor);
offsets = rec_get_offsets(rec, cursor->index,
NULL, ULINT_UNDEFINED, &heap);
offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap);
/* Free externally stored fields if the record is neither
a node pointer nor in two-byte format.
......@@ -2582,13 +2569,13 @@ btr_cur_pessimistic_delete(
if (page_is_comp(page)
? !rec_get_node_ptr_flag(rec)
: !rec_get_1byte_offs_flag(rec)) {
btr_rec_free_externally_stored_fields(cursor->index,
btr_rec_free_externally_stored_fields(index,
rec, offsets,
in_rollback, mtr);
}
if (UNIV_UNLIKELY(page_get_n_recs(page) < 2)
&& UNIV_UNLIKELY(dict_tree_get_page(btr_cur_get_tree(cursor))
&& UNIV_UNLIKELY(dict_index_get_page(btr_cur_get_index(cursor))
!= buf_frame_get_page_no(page))) {
/* If there is only one record, drop the whole page in
......@@ -2625,23 +2612,22 @@ btr_cur_pessimistic_delete(
so that it is equal to the new leftmost node pointer
on the page */
btr_node_ptr_delete(tree, page, mtr);
btr_node_ptr_delete(index, page, mtr);
node_ptr = dict_tree_build_node_ptr
(tree, next_rec, buf_frame_get_page_no(page),
node_ptr = dict_index_build_node_ptr
(index, next_rec, buf_frame_get_page_no(page),
heap, level);
btr_insert_on_non_leaf_level(tree,
btr_insert_on_non_leaf_level(index,
level + 1, node_ptr, mtr);
}
}
btr_search_update_hash_on_delete(cursor);
page_cur_delete_rec(btr_cur_get_page_cur(cursor), cursor->index,
offsets, mtr);
page_cur_delete_rec(btr_cur_get_page_cur(cursor), index, offsets, mtr);
ut_ad(btr_check_node_ptr(tree, page, mtr));
ut_ad(btr_check_node_ptr(index, page, mtr));
*err = DB_SUCCESS;
......@@ -2653,8 +2639,7 @@ btr_cur_pessimistic_delete(
}
if (n_extents > 0) {
fil_space_release_free_extents(cursor->index->space,
n_reserved);
fil_space_release_free_extents(index->space, n_reserved);
}
return(ret);
......@@ -3386,7 +3371,7 @@ btr_store_big_rec_extern_fields(
mtr_t mtr;
ut_ad(rec_offs_validate(rec, index, offsets));
ut_ad(mtr_memo_contains(local_mtr, dict_tree_get_lock(index->tree),
ut_ad(mtr_memo_contains(local_mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(local_mtr, buf_block_align(rec),
MTR_MEMO_PAGE_X_FIX));
......@@ -3419,7 +3404,7 @@ btr_store_big_rec_extern_fields(
hint_page_no = prev_page_no + 1;
}
page = btr_page_alloc(index->tree, hint_page_no,
page = btr_page_alloc(index, hint_page_no,
FSP_NO_DIR, 0, &mtr);
if (page == NULL) {
......@@ -3560,7 +3545,7 @@ btr_free_externally_stored_field(
mtr_t mtr;
ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
ut_ad(mtr_memo_contains(local_mtr, dict_tree_get_lock(index->tree),
ut_ad(mtr_memo_contains(local_mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(local_mtr, buf_block_align(data),
MTR_MEMO_PAGE_X_FIX));
......@@ -3632,7 +3617,7 @@ btr_free_externally_stored_field(
because we did not store it on the page (we save the space
overhead from an index page header. */
btr_page_free_low(index->tree, page, 0, &mtr);
btr_page_free_low(index, page, 0, &mtr);
mlog_write_ulint(data + local_len + BTR_EXTERN_PAGE_NO,
next_page_no,
......
......@@ -76,14 +76,14 @@ btr_pcur_store_position(
{
page_cur_t* page_cursor;
rec_t* rec;
dict_tree_t* tree;
dict_index_t* index;
page_t* page;
ulint offs;
ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
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);
......@@ -133,8 +133,8 @@ btr_pcur_store_position(
}
cursor->old_stored = BTR_PCUR_OLD_STORED;
cursor->old_rec = dict_tree_copy_rec_order_prefix
(tree, rec, &cursor->old_n_fields,
cursor->old_rec = dict_index_copy_rec_order_prefix
(index, rec, &cursor->old_n_fields,
&cursor->old_rec_buf, &cursor->buf_size);
cursor->block_when_stored = buf_block_align(page);
......@@ -197,13 +197,15 @@ btr_pcur_restore_position(
btr_pcur_t* cursor, /* in: detached persistent cursor */
mtr_t* mtr) /* in: mtr */
{
dict_tree_t* tree;
dict_index_t* index;
page_t* page;
dtuple_t* tuple;
ulint mode;
ulint old_mode;
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)
|| UNIV_UNLIKELY(cursor->pos_state != BTR_PCUR_WAS_POSITIONED
&& cursor->pos_state != BTR_PCUR_IS_POSITIONED)) {
......@@ -224,8 +226,7 @@ btr_pcur_restore_position(
btr_cur_open_at_index_side
(cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE,
btr_pcur_get_btr_cur(cursor)->index, latch_mode,
btr_pcur_get_btr_cur(cursor), mtr);
index, latch_mode, btr_pcur_get_btr_cur(cursor), mtr);
cursor->block_when_stored
= buf_block_align(btr_pcur_get_page(cursor));
......@@ -255,12 +256,10 @@ btr_pcur_restore_position(
rec_t* rec;
ulint* offsets1;
ulint* offsets2;
dict_index_t* index;
#endif /* UNIV_DEBUG */
cursor->latch_mode = latch_mode;
#ifdef UNIV_DEBUG
rec = btr_pcur_get_rec(cursor);
index = btr_pcur_get_btr_cur(cursor)->index;
heap = mem_heap_create(256);
offsets1 = rec_get_offsets
......@@ -286,9 +285,8 @@ btr_pcur_restore_position(
heap = mem_heap_create(256);
tree = btr_cur_get_tree(btr_pcur_get_btr_cur(cursor));
tuple = dict_tree_build_data_tuple(tree, cursor->old_rec,
cursor->old_n_fields, heap);
tuple = dict_index_build_data_tuple(index, cursor->old_rec,
cursor->old_n_fields, heap);
/* Save the old search mode of the cursor */
old_mode = cursor->search_mode;
......@@ -302,8 +300,8 @@ btr_pcur_restore_position(
mode = PAGE_CUR_L;
}
btr_pcur_open_with_no_init(btr_pcur_get_btr_cur(cursor)->index, tuple,
mode, latch_mode, cursor, 0, mtr);
btr_pcur_open_with_no_init(index, tuple, mode, latch_mode,
cursor, 0, mtr);
/* Restore the old search mode */
cursor->search_mode = old_mode;
......@@ -312,8 +310,7 @@ btr_pcur_restore_position(
&& btr_pcur_is_on_user_rec(cursor, mtr)
&& 0 == cmp_dtuple_rec(tuple, btr_pcur_get_rec(cursor),
rec_get_offsets
(btr_pcur_get_rec(cursor),
btr_pcur_get_btr_cur(cursor)->index,
(btr_pcur_get_rec(cursor), index,
NULL, ULINT_UNDEFINED, &heap))) {
/* We have to store the NEW value for the modify clock, since
......
......@@ -401,7 +401,7 @@ btr_search_update_hash_ref(
{
ulint fold;
rec_t* rec;
dulint tree_id;
dulint index_id;
ut_ad(cursor->flag == BTR_CUR_HASH_FAIL);
#ifdef UNIV_SYNC_DEBUG
......@@ -428,12 +428,12 @@ btr_search_update_hash_ref(
return;
}
tree_id = ((cursor->index)->tree)->id;
index_id = cursor->index->id;
fold = rec_fold(rec,
rec_get_offsets(rec, cursor->index, offsets_,
ULINT_UNDEFINED, &heap),
block->curr_n_fields,
block->curr_n_bytes, tree_id);
block->curr_n_bytes, index_id);
if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap);
}
......@@ -699,7 +699,7 @@ btr_search_guess_on_hash(
page_t* page;
ulint fold;
ulint tuple_n_fields;
dulint tree_id;
dulint index_id;
ibool can_only_compare_to_cursor_rec = TRUE;
#ifdef notdefined
btr_cur_t cursor2;
......@@ -733,12 +733,12 @@ btr_search_guess_on_hash(
return(FALSE);
}
tree_id = (index->tree)->id;
index_id = index->id;
#ifdef UNIV_SEARCH_PERF_STAT
info->n_hash_succ++;
#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->flag = BTR_CUR_HASH;
......@@ -798,7 +798,8 @@ btr_search_guess_on_hash(
is positioned on. We cannot look at the next of the previous
record to determine if our guess for the cursor position is
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,
can_only_compare_to_cursor_rec,
tuple, mode, mtr)) {
......@@ -901,7 +902,7 @@ btr_search_drop_page_hash_index(
rec_t* rec;
ulint fold;
ulint prev_fold;
dulint tree_id;
dulint index_id;
ulint n_cached;
ulint n_recs;
ulint* folds;
......@@ -958,9 +959,9 @@ btr_search_drop_page_hash_index(
rec = page_get_infimum_rec(page);
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;
......@@ -971,7 +972,7 @@ btr_search_drop_page_hash_index(
offsets = rec_get_offsets(rec, index, offsets,
n_fields + (n_bytes > 0), &heap);
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) {
......@@ -1104,7 +1105,7 @@ btr_search_build_page_hash_index(
rec_t* next_rec;
ulint fold;
ulint next_fold;
dulint tree_id;
dulint index_id;
ulint n_cached;
ulint n_recs;
ulint* folds;
......@@ -1167,7 +1168,7 @@ btr_search_build_page_hash_index(
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_rec_get_next(rec);
......@@ -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) {
......@@ -1210,7 +1211,7 @@ btr_search_build_page_hash_index(
offsets = rec_get_offsets(next_rec, index, offsets,
n_fields + (n_bytes > 0), &heap);
next_fold = rec_fold(next_rec, offsets, n_fields,
n_bytes, tree_id);
n_bytes, index_id);
if (fold != next_fold) {
/* Insert an entry into the hash index */
......@@ -1350,7 +1351,7 @@ btr_search_update_hash_on_delete(
buf_block_t* block;
rec_t* rec;
ulint fold;
dulint tree_id;
dulint index_id;
ibool found;
ulint offsets_[REC_OFFS_NORMAL_SIZE];
mem_heap_t* heap = NULL;
......@@ -1374,10 +1375,10 @@ btr_search_update_hash_on_delete(
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_,
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)) {
mem_heap_free(heap);
}
......@@ -1454,7 +1455,7 @@ btr_search_update_hash_on_insert(
rec_t* rec;
rec_t* ins_rec;
rec_t* next_rec;
dulint tree_id;
dulint index_id;
ulint fold;
ulint ins_fold;
ulint next_fold = 0; /* remove warning (??? bug ???) */
......@@ -1486,7 +1487,7 @@ btr_search_update_hash_on_insert(
ut_a(block->index == cursor->index);
tree_id = ((cursor->index)->tree)->id;
index_id = cursor->index->id;
n_fields = block->curr_n_fields;
n_bytes = block->curr_n_bytes;
......@@ -1497,19 +1498,19 @@ btr_search_update_hash_on_insert(
offsets = rec_get_offsets(ins_rec, cursor->index, offsets,
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)) {
offsets = rec_get_offsets(next_rec, cursor->index, offsets,
n_fields + (n_bytes > 0), &heap);
next_fold = rec_fold(next_rec, offsets, n_fields,
n_bytes, tree_id);
n_bytes, index_id);
}
if (!page_rec_is_infimum(rec)) {
offsets = rec_get_offsets(rec, cursor->index, offsets,
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 {
if (left_side) {
......
......@@ -798,7 +798,7 @@ dict_truncate_index_tree(
root_page_no = btr_create(type, space, index_id, comp, mtr);
if (index) {
index->tree->page = root_page_no;
index->page = root_page_no;
} else {
ut_print_timestamp(stderr);
fprintf(stderr,
......
......@@ -945,7 +945,7 @@ dict_index_find_on_id_low(
index = dict_table_get_first_index(table);
while (index) {
if (0 == ut_dulint_cmp(id, index->tree->id)) {
if (0 == ut_dulint_cmp(id, index->id)) {
/* Found */
return(index);
......@@ -1316,7 +1316,6 @@ dict_index_add_to_cache(
ulint page_no)/* in: root page number of the index */
{
dict_index_t* new_index;
dict_tree_t* tree;
dict_field_t* field;
ulint n_ord;
ulint i;
......@@ -1385,11 +1384,8 @@ dict_index_add_to_cache(
dict_field_get_col(field)->ord_part = 1;
}
/* Create an index tree memory object for the index */
tree = dict_tree_create(new_index, page_no);
ut_ad(tree);
new_index->tree = tree;
new_index->page = page_no;
rw_lock_create(&new_index->lock, SYNC_INDEX_TREE);
if (!UNIV_UNLIKELY(new_index->type & DICT_UNIVERSAL)) {
......@@ -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_mem_index_free(index);
......@@ -1432,8 +1425,7 @@ dict_index_remove_from_cache(
ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */
ut_ad(index->tree->tree_index);
dict_tree_free(index->tree);
rw_lock_free(&index->lock);
/* Remove the index from the list of indexes of the table */
UT_LIST_REMOVE(indexes, table->indexes, index);
......@@ -3536,68 +3528,18 @@ dict_index_get_if_in_cache(
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
/**************************************************************************
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. */
ibool
dict_tree_check_search_tuple(
/*=========================*/
dict_index_check_search_tuple(
/*==========================*/
/* 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 */
{
dict_index_t* index = tree->tree_index;
ut_a(index);
ut_a(dtuple_get_n_fields_cmp(tuple)
<= dict_index_get_n_unique_in_tree(index));
......@@ -3609,10 +3551,10 @@ dict_tree_check_search_tuple(
Builds a node pointer out of a physical record and a page number. */
dtuple_t*
dict_tree_build_node_ptr(
/*=====================*/
dict_index_build_node_ptr(
/*======================*/
/* 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
pointer */
ulint page_no,/* in: page number to put in node pointer */
......@@ -3621,20 +3563,17 @@ dict_tree_build_node_ptr(
level */
{
dtuple_t* tuple;
dict_index_t* ind;
dfield_t* field;
byte* buf;
ulint n_unique;
ind = tree->tree_index;
if (UNIV_UNLIKELY(tree->type & DICT_UNIVERSAL)) {
if (UNIV_UNLIKELY(index->type & DICT_UNIVERSAL)) {
/* In a universal index tree, we take the whole record as
the node pointer if the reord is on the leaf level,
on non-leaf levels we remove the last field, which
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);
if (level > 0) {
......@@ -3642,7 +3581,7 @@ dict_tree_build_node_ptr(
n_unique--;
}
} 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);
......@@ -3655,7 +3594,7 @@ dict_tree_build_node_ptr(
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);
......@@ -3666,7 +3605,7 @@ dict_tree_build_node_ptr(
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)
| REC_STATUS_NODE_PTR);
......@@ -3680,23 +3619,21 @@ Copies an initial segment of a physical record, long enough to specify an
index entry uniquely. */
rec_t*
dict_tree_copy_rec_order_prefix(
/*============================*/
dict_index_copy_rec_order_prefix(
/*=============================*/
/* 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 */
ulint* n_fields,/* out: number of fields copied */
byte** buf, /* in/out: memory buffer for the copied prefix,
or NULL */
ulint* buf_size)/* in/out: buffer size */
{
dict_index_t* index;
ulint n;
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));
n = rec_get_n_fields_old(rec);
} else {
......@@ -3711,27 +3648,24 @@ dict_tree_copy_rec_order_prefix(
Builds a typed data tuple out of a physical record. */
dtuple_t*
dict_tree_build_data_tuple(
/*=======================*/
dict_index_build_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 */
ulint n_fields,/* in: number of data fields */
mem_heap_t* heap) /* in: memory heap where tuple created */
{
dtuple_t* tuple;
dict_index_t* ind;
ind = tree->tree_index;
ut_ad(dict_table_is_comp(ind->table)
ut_ad(dict_table_is_comp(index->table)
|| n_fields <= rec_get_n_fields_old(rec));
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));
......@@ -4045,7 +3979,6 @@ dict_index_print_low(
/*=================*/
dict_index_t* index) /* in: index */
{
dict_tree_t* tree;
ib_longlong n_vals;
ulint i;
......@@ -4053,8 +3986,6 @@ dict_index_print_low(
ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */
tree = index->tree;
if (index->n_user_defined_cols > 0) {
n_vals = index->stat_n_diff_key_vals
[index->n_user_defined_cols];
......@@ -4069,13 +4000,13 @@ dict_index_print_low(
" leaf pages %lu, size pages %lu\n"
" FIELDS: ",
index->name,
(ulong) ut_dulint_get_high(tree->id),
(ulong) ut_dulint_get_low(tree->id),
(ulong) ut_dulint_get_high(index->id),
(ulong) ut_dulint_get_low(index->id),
(ulong) index->n_user_defined_cols,
(ulong) index->n_fields,
(ulong) index->n_uniq,
(ulong) index->type,
(ulong) tree->page,
(ulong) index->page,
(ulong) n_vals,
(ulong) index->stat_n_leaf_pages,
(ulong) index->stat_index_size);
......@@ -4087,9 +4018,9 @@ dict_index_print_low(
putc('\n', stderr);
#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 */
}
......
......@@ -169,6 +169,7 @@ dict_mem_index_create(
index->type = type;
index->space = space;
index->page = 0;
index->name = mem_heap_strdup(heap, index_name);
index->table_name = table_name;
index->table = NULL;
......@@ -181,6 +182,7 @@ dict_mem_index_create(
index->stat_n_diff_key_vals = NULL;
index->cached = FALSE;
memset(&index->lock, 0, sizeof index->lock);
#ifdef UNIV_DEBUG
index->magic_n = DICT_INDEX_MAGIC_N;
#endif /* UNIV_DEBUG */
......
......@@ -305,7 +305,7 @@ ibuf_tree_root_get(
ut_a(space == 0);
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,
mtr);
......@@ -2994,7 +2994,7 @@ ibuf_delete_rec(
btr_pcur_commit_specify_mtr(pcur, mtr);
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;
}
......
......@@ -52,7 +52,7 @@ page_t*
btr_root_get(
/*=========*/
/* out: root page, x-latched */
dict_tree_t* tree, /* in: index tree */
dict_index_t* index, /* in: index tree */
mtr_t* mtr); /* in: mtr */
/******************************************************************
Gets a buffer page and declares its latching order level. */
......@@ -255,7 +255,7 @@ that mtr holds an x-latch on the tree. */
void
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 */
dtuple_t* tuple, /* in: the record to be inserted */
mtr_t* mtr); /* in: mtr */
......@@ -274,7 +274,7 @@ Deletes on the upper level the node pointer to a page. */
void
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 */
mtr_t* mtr); /* in: mtr */
#ifdef UNIV_DEBUG
......@@ -285,7 +285,7 @@ ibool
btr_check_node_ptr(
/*===============*/
/* out: TRUE */
dict_tree_t* tree, /* in: index tree */
dict_index_t* index, /* in: index tree */
page_t* page, /* in: index page */
mtr_t* mtr); /* in: mtr */
#endif /* UNIV_DEBUG */
......@@ -361,7 +361,7 @@ btr_page_alloc(
/*===========*/
/* out: new allocated page, x-latched;
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 */
byte file_direction, /* in: direction where a possible
page split is made */
......@@ -375,7 +375,7 @@ storage pages because the page must contain info on its level. */
void
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 */
mtr_t* mtr); /* in: mtr */
/******************************************************************
......@@ -386,7 +386,7 @@ argument. */
void
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 */
ulint level, /* in: page level */
mtr_t* mtr); /* in: mtr */
......@@ -397,14 +397,14 @@ Prints size info of a B-tree. */
void
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
btr_print_tree(
/*===========*/
dict_tree_t* tree, /* in: tree */
btr_print_index(
/*============*/
dict_index_t* index, /* in: index */
ulint width); /* in: print this many entries from start
and end */
#endif /* UNIV_BTR_PRINT */
......@@ -425,10 +425,10 @@ btr_index_rec_validate(
Checks the consistency of an index tree. */
ibool
btr_validate_tree(
/*==============*/
btr_validate_index(
/*===============*/
/* out: TRUE if ok */
dict_tree_t* tree, /* in: tree */
dict_index_t* index, /* in: index */
trx_t* trx); /* in: transaction or NULL */
#define BTR_N_LEAF_PAGES 1
......
......@@ -59,13 +59,13 @@ btr_cur_get_page(
/* out: pointer to page */
btr_cur_t* cursor);/* in: tree cursor */
/*************************************************************
Returns the tree of a cursor. */
Returns the index of a cursor. */
UNIV_INLINE
dict_tree_t*
btr_cur_get_tree(
/*=============*/
/* out: tree */
btr_cur_t* cursor);/* in: tree cursor */
dict_index_t*
btr_cur_get_index(
/*==============*/
/* out: index */
btr_cur_t* cursor);/* in: B-tree cursor */
/*************************************************************
Positions a tree cursor at a given record. */
UNIV_INLINE
......
......@@ -56,15 +56,15 @@ btr_cur_get_page(
}
/*************************************************************
Returns the tree of a cursor. */
Returns the index of a cursor. */
UNIV_INLINE
dict_tree_t*
btr_cur_get_tree(
/*=============*/
/* out: tree */
btr_cur_t* cursor) /* in: tree cursor */
dict_index_t*
btr_cur_get_index(
/*==============*/
/* out: index */
btr_cur_t* cursor) /* in: B-tree cursor */
{
return((cursor->index)->tree);
return(cursor->index);
}
/*************************************************************
......@@ -109,15 +109,8 @@ btr_cur_compress_recommendation(
one page: we recommend compression if this is not the
root page. */
if (dict_tree_get_page((cursor->index)->tree)
== buf_frame_get_page_no(page)) {
/* It is the root page */
return(FALSE);
}
return(TRUE);
return(dict_index_get_page(cursor->index)
!= buf_frame_get_page_no(page));
}
return(FALSE);
......@@ -153,15 +146,8 @@ btr_cur_can_delete_without_compress(
one page, OR the page will become empty: we recommend
compression if this is not the root page. */
if (dict_tree_get_page((cursor->index)->tree)
== buf_frame_get_page_no(page)) {
/* It is the root page */
return(TRUE);
}
return(FALSE);
return(dict_index_get_page(cursor->index)
== buf_frame_get_page_no(page));
}
return(TRUE);
......
......@@ -706,14 +706,6 @@ dict_index_copy_types(
dict_index_t* index, /* in: index */
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. */
UNIV_INLINE
dict_col_t*
......@@ -721,22 +713,6 @@ dict_field_get_col(
/*===============*/
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. */
/**************************************************************************
......@@ -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. */
ibool
dict_tree_check_search_tuple(
/*=========================*/
dict_index_check_search_tuple(
/*==========================*/
/* 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 */
#endif /* UNIV_DEBUG */
/**************************************************************************
Builds a node pointer out of a physical record and a page number. */
dtuple_t*
dict_tree_build_node_ptr(
/*=====================*/
dict_index_build_node_ptr(
/*======================*/
/* 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
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
index entry uniquely. */
rec_t*
dict_tree_copy_rec_order_prefix(
/*============================*/
dict_index_copy_rec_order_prefix(
/*=============================*/
/* 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 */
ulint* n_fields,/* out: number of fields copied */
byte** buf, /* in/out: memory buffer for the copied prefix,
......@@ -791,10 +767,10 @@ dict_tree_copy_rec_order_prefix(
Builds a typed data tuple out of a physical record. */
dtuple_t*
dict_tree_build_data_tuple(
/*=======================*/
dict_index_build_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 */
ulint n_fields,/* in: number of data fields */
mem_heap_t* heap); /* in: memory heap where tuple created */
......@@ -802,61 +778,60 @@ dict_tree_build_data_tuple(
Gets the space id of the root of the index tree. */
UNIV_INLINE
ulint
dict_tree_get_space(
/*================*/
dict_index_get_space(
/*=================*/
/* 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. */
UNIV_INLINE
void
dict_tree_set_space(
/*================*/
dict_tree_t* tree, /* in: tree */
dict_index_set_space(
/*=================*/
dict_index_t* index, /* in: index */
ulint space); /* in: space id */
/*************************************************************************
Gets the page number of the root of the index tree. */
UNIV_INLINE
ulint
dict_tree_get_page(
/*===============*/
dict_index_get_page(
/*================*/
/* 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. */
UNIV_INLINE
void
dict_tree_set_page(
/*===============*/
dict_tree_t* tree, /* in: tree */
dict_index_set_page(
/*================*/
dict_index_t* index, /* in: index */
ulint page); /* in: page number */
/*************************************************************************
Gets the type of the index tree. */
UNIV_INLINE
ulint
dict_tree_get_type(
/*===============*/
dict_index_get_type(
/*================*/
/* out: type */
dict_tree_t* tree); /* in: tree */
dict_index_t* index); /* in: index */
/*************************************************************************
Gets the read-write lock of the index tree. */
UNIV_INLINE
rw_lock_t*
dict_tree_get_lock(
/*===============*/
dict_index_get_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
relevant only in the case of many consecutive inserts, as updates
which make the records bigger might fragment the index. */
UNIV_INLINE
ulint
dict_tree_get_space_reserve(
/*========================*/
dict_index_get_space_reserve(void);
/*==============================*/
/* out: number of free bytes on page,
reserved for updates */
dict_tree_t* tree); /* in: a tree */
/*************************************************************************
Calculates the minimum record length in an index. */
......
......@@ -341,21 +341,6 @@ dict_index_get_sys_col_pos(
(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. */
UNIV_INLINE
......@@ -401,90 +386,90 @@ dict_index_get_nth_col_no(
Gets the space id of the root of the index tree. */
UNIV_INLINE
ulint
dict_tree_get_space(
/*================*/
dict_index_get_space(
/*=================*/
/* out: space id */
dict_tree_t* tree) /* in: tree */
dict_index_t* index) /* in: index */
{
ut_ad(tree);
ut_ad(tree->magic_n == DICT_TREE_MAGIC_N);
ut_ad(index);
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. */
UNIV_INLINE
void
dict_tree_set_space(
/*================*/
dict_tree_t* tree, /* in: tree */
dict_index_set_space(
/*=================*/
dict_index_t* index, /* in: index */
ulint space) /* in: space id */
{
ut_ad(tree);
ut_ad(tree->magic_n == DICT_TREE_MAGIC_N);
ut_ad(index);
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. */
UNIV_INLINE
ulint
dict_tree_get_page(
/*===============*/
dict_index_get_page(
/*================*/
/* out: page number */
dict_tree_t* tree) /* in: tree */
dict_index_t* index) /* in: index */
{
ut_ad(tree);
ut_ad(tree->magic_n == DICT_TREE_MAGIC_N);
ut_ad(index);
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. */
UNIV_INLINE
void
dict_tree_set_page(
/*===============*/
dict_tree_t* tree, /* in: tree */
dict_index_set_page(
/*================*/
dict_index_t* index, /* in: index */
ulint page) /* in: page number */
{
ut_ad(tree);
ut_ad(tree->magic_n == DICT_TREE_MAGIC_N);
ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
tree->page = page;
index->page = page;
}
/*************************************************************************
Gets the type of the index tree. */
UNIV_INLINE
ulint
dict_tree_get_type(
/*===============*/
dict_index_get_type(
/*================*/
/* out: type */
dict_tree_t* tree) /* in: tree */
dict_index_t* index) /* in: index */
{
ut_ad(tree);
ut_ad(tree->magic_n == DICT_TREE_MAGIC_N);
ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
return(tree->type);
return(index->type);
}
/*************************************************************************
Gets the read-write lock of the index tree. */
UNIV_INLINE
rw_lock_t*
dict_tree_get_lock(
/*===============*/
dict_index_get_lock(
/*================*/
/* out: read-write lock */
dict_tree_t* tree) /* in: tree */
dict_index_t* index) /* in: index */
{
ut_ad(tree);
ut_ad(tree->magic_n == DICT_TREE_MAGIC_N);
ut_ad(index);
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
which make the records bigger might fragment the index. */
UNIV_INLINE
ulint
dict_tree_get_space_reserve(
/*========================*/
dict_index_get_space_reserve(void)
/*==============================*/
/* out: number of free bytes on page,
reserved for updates */
dict_tree_t* tree) /* in: a tree */
{
ut_ad(tree);
UT_NOT_USED(tree);
return(UNIV_PAGE_SIZE / 16);
}
......
......@@ -152,22 +152,6 @@ struct dict_field_struct{
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 */
struct dict_index_struct{
dulint id; /* id of the index */
......@@ -176,27 +160,28 @@ struct dict_index_struct{
const char* name; /* index name */
const char* table_name; /* table name */
dict_table_t* table; /* back pointer to table */
ulint space; /* space where the index tree is placed */
ulint trx_id_offset:10;/* position of the the trx id column
unsigned space:32;
/* 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
before it are known to be of a fixed size,
0 otherwise */
ulint n_user_defined_cols:10;
unsigned n_user_defined_cols:10;
/* number of columns the user defined to
be in the index: in the internal
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
entry uniquely */
ulint n_def:10;/* number of fields defined so far */
ulint n_fields:10;/* number of fields in the index */
ulint n_nullable:10;/* number of nullable fields */
ibool cached:1;/* TRUE if the index object is in the
unsigned n_def:10;/* number of fields defined so far */
unsigned n_fields:10;/* number of fields in the index */
unsigned n_nullable:10;/* number of nullable fields */
unsigned cached:1;/* TRUE if the index object is in the
dictionary cache */
dict_field_t* fields; /* array of field descriptions */
UT_LIST_NODE_T(dict_index_t)
indexes;/* list of indexes of the table */
dict_tree_t* tree; /* index tree struct */
btr_search_t* search_info; /* info used in optimistic searches */
/*----------------------*/
ib_longlong* stat_n_diff_key_vals;
......@@ -209,6 +194,8 @@ struct dict_index_struct{
ulint stat_n_leaf_pages;
/* approximate number of leaf pages in the
index tree */
rw_lock_t lock; /* read-write lock protecting the upper levels
of the index tree */
#ifdef UNIV_DEBUG
ulint magic_n;/* magic number */
# define DICT_INDEX_MAGIC_N 76789786
......
......@@ -13,7 +13,6 @@ typedef struct dict_sys_struct dict_sys_t;
typedef struct dict_col_struct dict_col_t;
typedef struct dict_field_struct dict_field_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_foreign_struct dict_foreign_t;
......
......@@ -4004,7 +4004,7 @@ row_check_table_for_mysql(
ut_print_name(stderr, trx, FALSE, index->name);
putc('\n', stderr); */
if (!btr_validate_tree(index->tree, prebuilt->trx)) {
if (!btr_validate_index(index, prebuilt->trx)) {
ret = DB_ERROR;
} else {
if (!row_scan_and_check_index(prebuilt,
......
......@@ -430,7 +430,7 @@ row_purge_upd_exist_or_extern(
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
root page of the tree. We will need it when we
......@@ -441,7 +441,7 @@ row_purge_upd_exist_or_extern(
latching order if we would only later latch the
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
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