Commit d583b180 authored by marko's avatar marko

branches/zip: Eliminate many buf_block_align() calls.

Replace page_t* or page_zip_des_t* parameters in some functions with
buf_block_t*.

buf_frame_get_page_zip(): Disable unless #ifdef UNIV_DEBUG || UNIV_ZIP_DEBUG.

btr_cur_t: Add buf_block_t* page_block.

btr_pcur_get_block(), btr_cur_get_block(), btr_cur_get_page_zip():
New functions.

btr_cur_position(): Add the parameter block.
parent 8f077940
...@@ -78,18 +78,29 @@ make them consecutive on disk if possible. From the other file segment ...@@ -78,18 +78,29 @@ make them consecutive on disk if possible. From the other file segment
we allocate pages for the non-leaf levels of the tree. we allocate pages for the non-leaf levels of the tree.
*/ */
/**************************************************************** /******************************************************************
Returns the upper level node pointer to a page. It is assumed that Gets the root node of a tree and x-latches it. */
mtr holds an x-latch on the tree. */
static static
rec_t* buf_block_t*
btr_page_get_father_node_ptr( btr_root_block_get(
/*=========================*/ /*===============*/
/* out: pointer to node pointer record */ /* out: root page, x-latched */
dict_index_t* index, /* in: index tree */ dict_index_t* index, /* in: index tree */
page_t* page, /* in: page: must contain at least one mtr_t* mtr) /* in: mtr */
user record */ {
mtr_t* mtr); /* in: mtr */ ulint space;
ulint root_page_no;
buf_block_t* block;
space = dict_index_get_space(index);
root_page_no = dict_index_get_page(index);
block = btr_block_get(space, root_page_no, RW_X_LATCH, mtr);
ut_a((ibool)!!page_is_comp(buf_block_get_frame(block))
== dict_table_is_comp(index->table));
return(block);
}
/****************************************************************** /******************************************************************
Gets the root node of a tree and x-latches it. */ Gets the root node of a tree and x-latches it. */
...@@ -101,17 +112,7 @@ btr_root_get( ...@@ -101,17 +112,7 @@ btr_root_get(
dict_index_t* index, /* in: index tree */ dict_index_t* index, /* in: index tree */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
ulint space; return(buf_block_get_frame(btr_root_block_get(index, mtr)));
ulint root_page_no;
page_t* root;
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(index->table));
return(root);
} }
/***************************************************************** /*****************************************************************
...@@ -511,7 +512,7 @@ btr_node_ptr_set_child_page_no( ...@@ -511,7 +512,7 @@ btr_node_ptr_set_child_page_no(
/**************************************************************** /****************************************************************
Returns the child page of a node pointer and x-latches it. */ Returns the child page of a node pointer and x-latches it. */
static static
page_t* buf_block_t*
btr_node_ptr_get_child( btr_node_ptr_get_child(
/*===================*/ /*===================*/
/* out: child page, x-latched */ /* out: child page, x-latched */
...@@ -526,60 +527,59 @@ btr_node_ptr_get_child( ...@@ -526,60 +527,59 @@ btr_node_ptr_get_child(
space = page_get_space_id(page_align(node_ptr)); space = page_get_space_id(page_align(node_ptr));
page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets); page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets);
return(btr_page_get(space, page_no, RW_X_LATCH, mtr)); return(btr_block_get(space, page_no, RW_X_LATCH, mtr));
} }
/**************************************************************** /****************************************************************
Returns the upper level node pointer to a page. It is assumed that mtr holds Returns the upper level node pointer to a page. It is assumed that mtr holds
an x-latch on the tree. */ an x-latch on the tree. */
static static
rec_t* ulint*
btr_page_get_father_for_rec( btr_page_get_father_node_ptr(
/*========================*/ /*=========================*/
/* out: pointer to node pointer record, /* out: rec_get_offsets() of the
node pointer record */
ulint* offsets,/* in: work area for the return value */
mem_heap_t* heap, /* in: memory heap to use */
btr_cur_t* cursor, /* in: cursor pointing to user record,
out: cursor on node pointer record,
its page x-latched */ its page x-latched */
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 */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
mem_heap_t* heap;
dtuple_t* tuple; dtuple_t* tuple;
btr_cur_t cursor; rec_t* user_rec;
rec_t* node_ptr; rec_t* node_ptr;
ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint level;
ulint* offsets = offsets_; ulint page_no;
*offsets_ = (sizeof offsets_) / sizeof *offsets_; dict_index_t* index;
page_no = buf_block_get_page_no(btr_cur_get_block(cursor));
index = btr_cur_get_index(cursor);
ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index), ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK)); MTR_MEMO_X_LOCK));
ut_a(page_rec_is_user_rec(user_rec));
ut_ad(dict_index_get_page(index) != page_get_page_no(page));
heap = mem_heap_create(100); ut_ad(dict_index_get_page(index) != page_no);
tuple = dict_index_build_node_ptr(index, user_rec, 0, heap, level = btr_page_get_level(btr_cur_get_page(cursor), mtr);
btr_page_get_level(page, mtr)); user_rec = btr_cur_get_rec(cursor);
ut_a(page_rec_is_user_rec(user_rec));
/* In the following, we choose just any index from the tree as the tuple = dict_index_build_node_ptr(index, user_rec, 0, heap, level);
first parameter for btr_cur_search_to_nth_level. */
btr_cur_search_to_nth_level(index, btr_cur_search_to_nth_level(index, level + 1, tuple, PAGE_CUR_LE,
btr_page_get_level(page, mtr) + 1, BTR_CONT_MODIFY_TREE, cursor, 0, mtr);
tuple, PAGE_CUR_LE,
BTR_CONT_MODIFY_TREE, &cursor, 0, mtr);
node_ptr = btr_cur_get_rec(&cursor); node_ptr = btr_cur_get_rec(cursor);
ut_ad(!page_rec_is_comp(node_ptr)
|| rec_get_status(node_ptr) == REC_STATUS_NODE_PTR);
offsets = rec_get_offsets(node_ptr, index, offsets, offsets = rec_get_offsets(node_ptr, index, offsets,
ULINT_UNDEFINED, &heap); ULINT_UNDEFINED, &heap);
if (UNIV_UNLIKELY(btr_node_ptr_get_child_page_no(node_ptr, offsets) if (UNIV_UNLIKELY(btr_node_ptr_get_child_page_no(node_ptr, offsets)
!= page_get_page_no(page))) { != page_no)) {
rec_t* print_rec; rec_t* print_rec;
fputs("InnoDB: Dump of the child page:\n", stderr); fputs("InnoDB: Dump of the child page:\n", stderr);
buf_page_print(page_align(page), 0); buf_page_print(page_align(user_rec), 0);
fputs("InnoDB: Dump of the parent page:\n", stderr); fputs("InnoDB: Dump of the parent page:\n", stderr);
buf_page_print(page_align(node_ptr), 0); buf_page_print(page_align(node_ptr), 0);
...@@ -591,8 +591,9 @@ btr_page_get_father_for_rec( ...@@ -591,8 +591,9 @@ btr_page_get_father_for_rec(
"InnoDB: father ptr page no %lu, child page no %lu\n", "InnoDB: father ptr page no %lu, child page no %lu\n",
(ulong) (ulong)
btr_node_ptr_get_child_page_no(node_ptr, offsets), btr_node_ptr_get_child_page_no(node_ptr, offsets),
(ulong) page_get_page_no(page)); (ulong) page_no);
print_rec = page_rec_get_next(page_get_infimum_rec(page)); print_rec = page_rec_get_next(
page_get_infimum_rec(page_align(user_rec)));
offsets = rec_get_offsets(print_rec, index, offsets = rec_get_offsets(print_rec, index,
offsets, ULINT_UNDEFINED, &heap); offsets, ULINT_UNDEFINED, &heap);
page_rec_print(print_rec, offsets); page_rec_print(print_rec, offsets);
...@@ -612,27 +613,55 @@ btr_page_get_father_for_rec( ...@@ -612,27 +613,55 @@ btr_page_get_father_for_rec(
ut_error; ut_error;
} }
mem_heap_free(heap); return(offsets);
}
return(node_ptr); /****************************************************************
Returns the upper level node pointer to a page. It is assumed that mtr holds
an x-latch on the tree. */
static
ulint*
btr_page_get_father_block(
/*======================*/
/* out: rec_get_offsets() of the
node pointer record */
ulint* offsets,/* in: work area for the return value */
mem_heap_t* heap, /* in: memory heap to use */
dict_index_t* index, /* in: b-tree index */
buf_block_t* block, /* in: child page in the index */
mtr_t* mtr, /* in: mtr */
btr_cur_t* cursor) /* out: cursor on node pointer record,
its page x-latched */
{
rec_t* rec
= page_rec_get_next(page_get_infimum_rec(buf_block_get_frame(
block)));
btr_cur_position(index, rec, block, cursor);
return(btr_page_get_father_node_ptr(offsets, heap, cursor, mtr));
} }
/**************************************************************** /****************************************************************
Returns the upper level node pointer to a page. It is assumed that Seeks to the upper level node pointer to a page.
mtr holds an x-latch on the tree. */ It is assumed that mtr holds an x-latch on the tree. */
static static
rec_t* void
btr_page_get_father_node_ptr( btr_page_get_father(
/*=========================*/ /*================*/
/* out: pointer to node pointer record */ dict_index_t* index, /* in: b-tree index */
dict_index_t* index, /* in: index tree */ buf_block_t* block, /* in: child page in the index */
page_t* page, /* in: page: must contain at least one mtr_t* mtr, /* in: mtr */
user record */ btr_cur_t* cursor) /* out: cursor on node pointer record,
mtr_t* mtr) /* in: mtr */ its page x-latched */
{ {
return(btr_page_get_father_for_rec( mem_heap_t* heap;
index, page, rec_t* rec
page_rec_get_next(page_get_infimum_rec(page)), mtr)); = page_rec_get_next(page_get_infimum_rec(buf_block_get_frame(
block)));
btr_cur_position(index, rec, block, cursor);
heap = mem_heap_create(100);
btr_page_get_father_node_ptr(NULL, heap, cursor, mtr);
mem_heap_free(heap);
} }
/**************************************************************** /****************************************************************
...@@ -832,12 +861,12 @@ btr_page_reorganize_low( ...@@ -832,12 +861,12 @@ btr_page_reorganize_low(
there cannot exist locks on the there cannot exist locks on the
page, and a hash index should not be page, and a hash index should not be
dropped: it cannot exist */ dropped: it cannot exist */
page_t* page, /* in/out: page to be reorganized */ buf_block_t* block, /* in: page to be reorganized */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
buf_block_t* block; page_t* page = buf_block_get_frame(block);
page_zip_des_t* page_zip = buf_block_get_page_zip(block);
buf_block_t* temp_block; buf_block_t* temp_block;
page_t* temp_page; page_t* temp_page;
ulint log_mode; ulint log_mode;
...@@ -845,9 +874,8 @@ btr_page_reorganize_low( ...@@ -845,9 +874,8 @@ btr_page_reorganize_low(
ulint data_size2; ulint data_size2;
ulint max_ins_size1; ulint max_ins_size1;
ulint max_ins_size2; ulint max_ins_size2;
ibool success = FALSE; ibool success = FALSE;
block = buf_block_align(page);
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
ut_ad(!!page_is_comp(page) == dict_table_is_comp(index->table)); ut_ad(!!page_is_comp(page) == dict_table_is_comp(index->table));
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
...@@ -944,13 +972,11 @@ ibool ...@@ -944,13 +972,11 @@ ibool
btr_page_reorganize( btr_page_reorganize(
/*================*/ /*================*/
/* out: TRUE on success, FALSE on failure */ /* out: TRUE on success, FALSE on failure */
page_t* page, /* in: page to be reorganized */ buf_block_t* block, /* in: page to be reorganized */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
return(btr_page_reorganize_low(FALSE, page, return(btr_page_reorganize_low(FALSE, block, index, mtr));
buf_frame_get_page_zip(page),
index, mtr));
} }
/*************************************************************** /***************************************************************
...@@ -964,16 +990,15 @@ btr_parse_page_reorganize( ...@@ -964,16 +990,15 @@ btr_parse_page_reorganize(
byte* end_ptr __attribute__((unused)), byte* end_ptr __attribute__((unused)),
/* in: buffer end */ /* in: buffer end */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
page_t* page, /* in/out: page to be reorganized, or NULL */ buf_block_t* block, /* in: page to be reorganized, or NULL */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
mtr_t* mtr) /* in: mtr or NULL */ mtr_t* mtr) /* in: mtr or NULL */
{ {
ut_ad(ptr && end_ptr); ut_ad(ptr && end_ptr);
/* The record is empty, except for the record initial part */ /* The record is empty, except for the record initial part */
if (UNIV_LIKELY(page != NULL)) { if (UNIV_LIKELY(block != NULL)) {
btr_page_reorganize_low(TRUE, page, page_zip, index, mtr); btr_page_reorganize_low(TRUE, block, index, mtr);
} }
return(ptr); return(ptr);
...@@ -1048,7 +1073,7 @@ btr_root_raise_and_insert( ...@@ -1048,7 +1073,7 @@ btr_root_raise_and_insert(
buf_block_t* new_block; buf_block_t* new_block;
root = btr_cur_get_page(cursor); root = btr_cur_get_page(cursor);
root_block = buf_block_align(root); root_block = btr_cur_get_block(cursor);
root_page_zip = buf_block_get_page_zip(root_block); root_page_zip = buf_block_get_page_zip(root_block);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!root_page_zip || page_zip_validate(root_page_zip, root)); ut_a(!root_page_zip || page_zip_validate(root_page_zip, root));
...@@ -1082,7 +1107,7 @@ btr_root_raise_and_insert( ...@@ -1082,7 +1107,7 @@ btr_root_raise_and_insert(
/* Copy the records from root to the new page one by one. */ /* Copy the records from root to the new page one by one. */
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!page_copy_rec_list_end(new_page, new_page_zip, (!page_copy_rec_list_end(new_block,
page_get_infimum_rec(root), page_get_infimum_rec(root),
index, mtr))) { index, mtr))) {
ut_a(new_page_zip); ut_a(new_page_zip);
...@@ -1139,6 +1164,7 @@ btr_root_raise_and_insert( ...@@ -1139,6 +1164,7 @@ btr_root_raise_and_insert(
/* Insert node pointer to the root */ /* Insert node pointer to the root */
ut_ad(buf_block_get_frame(btr_cur_get_block(cursor)) == root);
page_cur_set_before_first(root, page_cursor); page_cur_set_before_first(root, page_cursor);
node_ptr_rec = page_cur_tuple_insert(page_cursor, root_page_zip, node_ptr_rec = page_cur_tuple_insert(page_cursor, root_page_zip,
...@@ -1160,6 +1186,7 @@ btr_root_raise_and_insert( ...@@ -1160,6 +1186,7 @@ btr_root_raise_and_insert(
ibuf_reset_free_bits_with_type(index->type, new_block); ibuf_reset_free_bits_with_type(index->type, new_block);
/* Reposition the cursor to the child node */ /* Reposition the cursor to the child node */
cursor->page_block = new_block;
page_cur_search(new_page, index, tuple, page_cur_search(new_page, index, tuple,
PAGE_CUR_LE, page_cursor); PAGE_CUR_LE, page_cursor);
...@@ -1307,7 +1334,7 @@ btr_page_get_sure_split_rec( ...@@ -1307,7 +1334,7 @@ btr_page_get_sure_split_rec(
insert_size = rec_get_converted_size(cursor->index, tuple, ext, n_ext); insert_size = rec_get_converted_size(cursor->index, tuple, ext, n_ext);
free_space = page_get_free_space_of_empty(page_is_comp(page)); free_space = page_get_free_space_of_empty(page_is_comp(page));
page_zip = buf_frame_get_page_zip(page); page_zip = btr_cur_get_page_zip(cursor);
if (UNIV_LIKELY_NULL(page_zip)) { if (UNIV_LIKELY_NULL(page_zip)) {
/* Estimate the free space of an empty compressed page. */ /* Estimate the free space of an empty compressed page. */
ulint free_space_zip = page_zip_empty_size( ulint free_space_zip = page_zip_empty_size(
...@@ -1530,21 +1557,18 @@ void ...@@ -1530,21 +1557,18 @@ void
btr_attach_half_pages( btr_attach_half_pages(
/*==================*/ /*==================*/
dict_index_t* index, /* in: the index tree */ dict_index_t* index, /* in: the index tree */
page_t* page, /* in/out: page to be split */ buf_block_t* block, /* in/out: page to be split */
page_zip_des_t* page_zip, /* in/out: compressed page, or NULL */
rec_t* split_rec, /* in: first record on upper rec_t* split_rec, /* in: first record on upper
half page */ half page */
page_t* new_page, /* in/out: the new half page */ buf_block_t* new_block, /* in/out: the new half page */
page_zip_des_t* new_page_zip, /* in/out: compressed new_page,
or NULL */
ulint direction, /* in: FSP_UP or FSP_DOWN */ ulint direction, /* in: FSP_UP or FSP_DOWN */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
ulint space; ulint space;
rec_t* node_ptr;
ulint prev_page_no; ulint prev_page_no;
ulint next_page_no; ulint next_page_no;
ulint level; ulint level;
page_t* page = buf_block_get_frame(block);
page_t* lower_page; page_t* lower_page;
page_t* upper_page; page_t* upper_page;
ulint lower_page_no; ulint lower_page_no;
...@@ -1554,9 +1578,8 @@ btr_attach_half_pages( ...@@ -1554,9 +1578,8 @@ btr_attach_half_pages(
dtuple_t* node_ptr_upper; dtuple_t* node_ptr_upper;
mem_heap_t* heap; mem_heap_t* heap;
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
ut_ad(mtr_memo_contains_page(mtr, new_page, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, new_block, MTR_MEMO_PAGE_X_FIX));
ut_a(page_is_comp(page) == page_is_comp(new_page));
/* Create a memory heap where the data tuple is stored */ /* Create a memory heap where the data tuple is stored */
heap = mem_heap_create(1024); heap = mem_heap_create(1024);
...@@ -1564,37 +1587,39 @@ btr_attach_half_pages( ...@@ -1564,37 +1587,39 @@ btr_attach_half_pages(
/* Based on split direction, decide upper and lower pages */ /* Based on split direction, decide upper and lower pages */
if (direction == FSP_DOWN) { if (direction == FSP_DOWN) {
lower_page_no = page_get_page_no(new_page); btr_cur_t cursor;
upper_page_no = page_get_page_no(page); ulint* offsets;
lower_page = new_page;
upper_page = page; lower_page = buf_block_get_frame(new_block);
lower_page_zip = new_page_zip; lower_page_no = buf_block_get_page_no(new_block);
upper_page_zip = page_zip; lower_page_zip = buf_block_get_page_zip(new_block);
upper_page = buf_block_get_frame(block);
upper_page_no = buf_block_get_page_no(block);
upper_page_zip = buf_block_get_page_zip(block);
/* Look up the index for the node pointer to page */ /* Look up the index for the node pointer to page */
node_ptr = btr_page_get_father_node_ptr(index, page, mtr); offsets = btr_page_get_father_block(NULL, heap, index,
block, mtr, &cursor);
/* Replace the address of the old child node (= page) with the /* Replace the address of the old child node (= page) with the
address of the new lower half */ address of the new lower half */
btr_node_ptr_set_child_page_no( btr_node_ptr_set_child_page_no(
node_ptr, btr_cur_get_rec(&cursor),
buf_frame_get_page_zip(node_ptr), btr_cur_get_page_zip(&cursor),
rec_get_offsets(node_ptr, index, NULL, offsets, lower_page_no, mtr);
ULINT_UNDEFINED, &heap),
lower_page_no, mtr);
mem_heap_empty(heap); mem_heap_empty(heap);
} else { } else {
lower_page_no = page_get_page_no(page); lower_page = buf_block_get_frame(block);
upper_page_no = page_get_page_no(new_page); lower_page_no = buf_block_get_page_no(block);
lower_page = page; lower_page_zip = buf_block_get_page_zip(block);
upper_page = new_page; upper_page = buf_block_get_frame(new_block);
lower_page_zip = page_zip; upper_page_no = buf_block_get_page_no(new_block);
upper_page_zip = new_page_zip; upper_page_zip = buf_block_get_page_zip(new_block);
} }
/* Get the level of the split pages */ /* Get the level of the split pages */
level = btr_page_get_level(page, mtr); level = btr_page_get_level(buf_block_get_frame(block), mtr);
/* Build the node pointer (= node key and page address) for the upper /* Build the node pointer (= node key and page address) for the upper
half */ half */
...@@ -1614,7 +1639,7 @@ btr_attach_half_pages( ...@@ -1614,7 +1639,7 @@ btr_attach_half_pages(
prev_page_no = btr_page_get_prev(page, mtr); prev_page_no = btr_page_get_prev(page, mtr);
next_page_no = btr_page_get_next(page, mtr); next_page_no = btr_page_get_next(page, mtr);
space = page_get_space_id(page); space = buf_block_get_space(block);
/* Update page links of the level */ /* Update page links of the level */
...@@ -1624,7 +1649,7 @@ btr_attach_half_pages( ...@@ -1624,7 +1649,7 @@ btr_attach_half_pages(
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(prev_block->frame) == page_is_comp(page)); ut_a(page_is_comp(prev_block->frame) == page_is_comp(page));
ut_a(btr_page_get_next(prev_block->frame, mtr) ut_a(btr_page_get_next(prev_block->frame, mtr)
== page_get_page_no(page)); == buf_block_get_page_no(block));
#endif /* UNIV_BTR_DEBUG */ #endif /* UNIV_BTR_DEBUG */
btr_page_set_next(buf_block_get_frame(prev_block), btr_page_set_next(buf_block_get_frame(prev_block),
...@@ -1716,14 +1741,14 @@ btr_page_split_and_insert( ...@@ -1716,14 +1741,14 @@ btr_page_split_and_insert(
ut_ad(rw_lock_own(dict_index_get_lock(cursor->index), RW_LOCK_EX)); ut_ad(rw_lock_own(dict_index_get_lock(cursor->index), RW_LOCK_EX));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
block = buf_block_align(btr_cur_get_rec(cursor)); block = btr_cur_get_block(cursor);
page = buf_block_get_frame(block); page = buf_block_get_frame(block);
page_zip = buf_block_get_page_zip(block); page_zip = buf_block_get_page_zip(block);
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
ut_ad(page_get_n_recs(page) >= 1); ut_ad(page_get_n_recs(page) >= 1);
page_no = page_get_page_no(page); page_no = buf_block_get_page_no(block);
/* 1. Decide the split record; split_rec == NULL means that the /* 1. Decide the split record; split_rec == NULL means that the
tuple to be inserted should be the first record on the upper tuple to be inserted should be the first record on the upper
...@@ -1750,7 +1775,7 @@ btr_page_split_and_insert( ...@@ -1750,7 +1775,7 @@ btr_page_split_and_insert(
/* 2. Allocate a new page to the index */ /* 2. Allocate a new page to the index */
new_block = btr_page_alloc(cursor->index, hint_page_no, direction, new_block = btr_page_alloc(cursor->index, hint_page_no, direction,
btr_page_get_level(page, mtr), mtr); btr_page_get_level(page, mtr), mtr);
new_page = buf_block_get_frame(new_block); new_page = buf_block_get_frame(new_block);
new_page_zip = buf_block_get_page_zip(new_block); new_page_zip = buf_block_get_page_zip(new_block);
btr_page_create(new_block, new_page_zip, cursor->index, btr_page_create(new_block, new_page_zip, cursor->index,
...@@ -1773,8 +1798,8 @@ btr_page_split_and_insert( ...@@ -1773,8 +1798,8 @@ btr_page_split_and_insert(
/* 4. Do first the modifications in the tree structure */ /* 4. Do first the modifications in the tree structure */
btr_attach_half_pages(cursor->index, page, page_zip, first_rec, btr_attach_half_pages(cursor->index, block,
new_page, new_page_zip, direction, mtr); first_rec, new_block, direction, mtr);
/* If the split is made on the leaf level and the insert will fit /* If the split is made on the leaf level and the insert will fit
on the appropriate half-page, we may release the tree x-latch. on the appropriate half-page, we may release the tree x-latch.
...@@ -1808,8 +1833,7 @@ btr_page_split_and_insert( ...@@ -1808,8 +1833,7 @@ btr_page_split_and_insert(
/* fputs("Split left\n", stderr); */ /* fputs("Split left\n", stderr); */
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!page_move_rec_list_start(new_page, new_page_zip, (!page_move_rec_list_start(new_block, move_limit, page_zip,
move_limit, page_zip,
cursor->index, mtr))) { cursor->index, mtr))) {
/* For some reason, compressing new_page failed, /* For some reason, compressing new_page failed,
even though it should contain fewer records than even though it should contain fewer records than
...@@ -1837,8 +1861,7 @@ btr_page_split_and_insert( ...@@ -1837,8 +1861,7 @@ btr_page_split_and_insert(
/* fputs("Split right\n", stderr); */ /* fputs("Split right\n", stderr); */
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!page_move_rec_list_end(new_page, new_page_zip, (!page_move_rec_list_end(new_block, move_limit, page_zip,
move_limit, page_zip,
cursor->index, mtr))) { cursor->index, mtr))) {
/* For some reason, compressing new_page failed, /* For some reason, compressing new_page failed,
even though it should contain fewer records than even though it should contain fewer records than
...@@ -1889,6 +1912,7 @@ btr_page_split_and_insert( ...@@ -1889,6 +1912,7 @@ btr_page_split_and_insert(
/* 7. Reposition the cursor for insert and try insertion */ /* 7. Reposition the cursor for insert and try insertion */
page_cursor = btr_cur_get_page_cur(cursor); page_cursor = btr_cur_get_page_cur(cursor);
cursor->page_block = insert_block;
page_cur_search(insert_page, cursor->index, tuple, page_cur_search(insert_page, cursor->index, tuple,
PAGE_CUR_LE, page_cursor); PAGE_CUR_LE, page_cursor);
...@@ -1917,11 +1941,12 @@ btr_page_split_and_insert( ...@@ -1917,11 +1941,12 @@ btr_page_split_and_insert(
/* 8. If insert did not fit, try page reorganization */ /* 8. If insert did not fit, try page reorganization */
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!btr_page_reorganize(insert_page, cursor->index, mtr))) { (!btr_page_reorganize(insert_block, cursor->index, mtr))) {
goto insert_failed; goto insert_failed;
} }
ut_ad(cursor->page_block == insert_block);
page_cur_search(insert_page, cursor->index, tuple, page_cur_search(insert_page, cursor->index, tuple,
PAGE_CUR_LE, page_cursor); PAGE_CUR_LE, page_cursor);
rec = page_cur_tuple_insert(page_cursor, insert_page_zip, rec = page_cur_tuple_insert(page_cursor, insert_page_zip,
...@@ -2099,20 +2124,18 @@ void ...@@ -2099,20 +2124,18 @@ void
btr_node_ptr_delete( btr_node_ptr_delete(
/*================*/ /*================*/
dict_index_t* index, /* in: index tree */ dict_index_t* index, /* in: index tree */
page_t* page, /* in: page whose node pointer is deleted */ buf_block_t* block, /* in: page whose node pointer is deleted */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
rec_t* node_ptr;
btr_cur_t cursor; btr_cur_t cursor;
ibool compressed; ibool compressed;
ulint err; ulint err;
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
/* Delete node pointer on father page */
node_ptr = btr_page_get_father_node_ptr(index, page, mtr); /* Delete node pointer on father page */
btr_page_get_father(index, block, mtr, &cursor);
btr_cur_position(index, node_ptr, &cursor);
compressed = btr_cur_pessimistic_delete(&err, TRUE, &cursor, FALSE, compressed = btr_cur_pessimistic_delete(&err, TRUE, &cursor, FALSE,
mtr); mtr);
ut_a(err == DB_SUCCESS); ut_a(err == DB_SUCCESS);
...@@ -2136,6 +2159,7 @@ btr_lift_page_up( ...@@ -2136,6 +2159,7 @@ btr_lift_page_up(
record from the page should be removed */ record from the page should be removed */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
btr_cur_t father_cursor;
buf_block_t* father_block; buf_block_t* father_block;
page_t* father_page; page_t* father_page;
ulint page_level; ulint page_level;
...@@ -2145,14 +2169,11 @@ btr_lift_page_up( ...@@ -2145,14 +2169,11 @@ btr_lift_page_up(
ut_ad(btr_page_get_prev(page, mtr) == FIL_NULL); ut_ad(btr_page_get_prev(page, mtr) == FIL_NULL);
ut_ad(btr_page_get_next(page, mtr) == FIL_NULL); ut_ad(btr_page_get_next(page, mtr) == FIL_NULL);
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
father_block = buf_block_align(
btr_page_get_father_node_ptr(index, page, mtr)); btr_page_get_father(index, block, mtr, &father_cursor);
father_block = btr_cur_get_block(&father_cursor);
father_page_zip = buf_block_get_page_zip(father_block); father_page_zip = buf_block_get_page_zip(father_block);
father_page = buf_block_get_frame(father_block); father_page = buf_block_get_frame(father_block);
#ifdef UNIV_ZIP_DEBUG
ut_a(!father_page_zip
|| page_zip_validate(father_page_zip, father_page));
#endif /* UNIV_ZIP_DEBUG */
page_level = btr_page_get_level(page, mtr); page_level = btr_page_get_level(page, mtr);
...@@ -2167,7 +2188,7 @@ btr_lift_page_up( ...@@ -2167,7 +2188,7 @@ btr_lift_page_up(
/* Copy the records to the father page one by one. */ /* Copy the records to the father page one by one. */
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!page_copy_rec_list_end(father_page, father_page_zip, (!page_copy_rec_list_end(father_block,
page_get_infimum_rec(page), page_get_infimum_rec(page),
index, mtr))) { index, mtr))) {
ut_a(father_page_zip); ut_a(father_page_zip);
...@@ -2219,21 +2240,23 @@ btr_compress( ...@@ -2219,21 +2240,23 @@ btr_compress(
ibool is_left; ibool is_left;
buf_block_t* block; buf_block_t* block;
page_t* page; page_t* page;
rec_t* node_ptr; btr_cur_t father_cursor;
mem_heap_t* heap;
ulint* offsets;
ulint data_size; ulint data_size;
ulint n_recs; ulint n_recs;
ulint max_ins_size; ulint max_ins_size;
ulint max_ins_size_reorg; ulint max_ins_size_reorg;
ulint level; ulint level;
block = buf_block_align(btr_cur_get_rec(cursor)); block = btr_cur_get_block(cursor);
page = buf_block_get_frame(block); page = buf_block_get_frame(block);
index = btr_cur_get_index(cursor); index = btr_cur_get_index(cursor);
ut_a((ibool) !!page_is_comp(page) == dict_table_is_comp(index->table)); ut_a((ibool) !!page_is_comp(page) == dict_table_is_comp(index->table));
ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index), ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK)); MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
level = btr_page_get_level(page, mtr); level = btr_page_get_level(page, mtr);
space = dict_index_get_space(index); space = dict_index_get_space(index);
...@@ -2245,10 +2268,9 @@ btr_compress( ...@@ -2245,10 +2268,9 @@ btr_compress(
left_page_no, right_page_no); left_page_no, right_page_no);
#endif #endif
node_ptr = btr_page_get_father_node_ptr(index, page, mtr); heap = mem_heap_create(100);
ut_ad(!page_is_comp(page) offsets = btr_page_get_father_block(NULL, heap, index, block, mtr,
|| rec_get_status(node_ptr) == REC_STATUS_NODE_PTR); &father_cursor);
ut_a(page_is_comp(page) == page_rec_is_comp(node_ptr));
/* Decide the page to which we try to merge and which will inherit /* Decide the page to which we try to merge and which will inherit
the locks */ the locks */
...@@ -2261,8 +2283,7 @@ btr_compress( ...@@ -2261,8 +2283,7 @@ btr_compress(
mtr); mtr);
merge_page = buf_block_get_frame(merge_block); merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(merge_page, mtr) ut_a(btr_page_get_next(merge_page, mtr) == block->offset);
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */ #endif /* UNIV_BTR_DEBUG */
} else if (right_page_no != FIL_NULL) { } else if (right_page_no != FIL_NULL) {
...@@ -2270,13 +2291,13 @@ btr_compress( ...@@ -2270,13 +2291,13 @@ btr_compress(
mtr); mtr);
merge_page = buf_block_get_frame(merge_block); merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(merge_page, mtr) ut_a(btr_page_get_prev(merge_page, mtr) == block->offset);
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */ #endif /* UNIV_BTR_DEBUG */
} else { } else {
/* The page is the only one on the level, lift the records /* The page is the only one on the level, lift the records
to the father */ to the father */
btr_lift_page_up(index, block, mtr); btr_lift_page_up(index, block, mtr);
mem_heap_free(heap);
return(TRUE); return(TRUE);
} }
...@@ -2291,7 +2312,8 @@ btr_compress( ...@@ -2291,7 +2312,8 @@ btr_compress(
if (data_size > max_ins_size_reorg) { if (data_size > max_ins_size_reorg) {
/* No space for merge */ /* No space for merge */
err_exit:
mem_heap_free(heap);
return(FALSE); return(FALSE);
} }
...@@ -2303,10 +2325,10 @@ btr_compress( ...@@ -2303,10 +2325,10 @@ btr_compress(
/* We have to reorganize merge_page */ /* We have to reorganize merge_page */
if (UNIV_UNLIKELY(!btr_page_reorganize(merge_page, if (UNIV_UNLIKELY(!btr_page_reorganize(merge_block,
index, mtr))) { index, mtr))) {
return(FALSE); goto err_exit;
} }
max_ins_size = page_get_max_insert_size(merge_page, n_recs); max_ins_size = page_get_max_insert_size(merge_page, n_recs);
...@@ -2319,7 +2341,7 @@ btr_compress( ...@@ -2319,7 +2341,7 @@ btr_compress(
/* Add fault tolerance, though this should /* Add fault tolerance, though this should
never happen */ never happen */
return(FALSE); goto err_exit;
} }
} }
...@@ -2327,35 +2349,31 @@ btr_compress( ...@@ -2327,35 +2349,31 @@ btr_compress(
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
if (UNIV_LIKELY_NULL(merge_page_zip)) { if (UNIV_LIKELY_NULL(merge_page_zip)) {
ut_a(page_zip_validate(merge_page_zip, merge_page)); ut_a(page_zip_validate(merge_page_zip, merge_page));
ut_a(page_zip_validate(buf_frame_get_page_zip(page), page)); ut_a(page_zip_validate(buf_block_get_page_zip(block), page));
} }
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
/* Move records to the merge page */ /* Move records to the merge page */
if (is_left) { if (is_left) {
rec_t* orig_pred = page_copy_rec_list_start( rec_t* orig_pred = page_copy_rec_list_start(
merge_page, merge_page_zip, merge_block, page_get_supremum_rec(page), index, mtr);
page_get_supremum_rec(page), index, mtr);
if (UNIV_UNLIKELY(!orig_pred)) { if (UNIV_UNLIKELY(!orig_pred)) {
return(FALSE); goto err_exit;
} }
btr_search_drop_page_hash_index(buf_block_align(page)); btr_search_drop_page_hash_index(block);
/* Remove the page from the level list */ /* Remove the page from the level list */
btr_level_list_remove(page, mtr); btr_level_list_remove(page, mtr);
btr_node_ptr_delete(index, page, mtr); btr_node_ptr_delete(index, block, mtr);
lock_update_merge_left(merge_page, orig_pred, page); lock_update_merge_left(merge_page, orig_pred, page);
} else { } else {
mem_heap_t* heap = NULL;
ulint offsets_[REC_OFFS_NORMAL_SIZE];
rec_t* orig_succ; rec_t* orig_succ;
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
byte fil_page_prev[4]; byte fil_page_prev[4];
#endif /* UNIV_BTR_DEBUG */ #endif /* UNIV_BTR_DEBUG */
*offsets_ = (sizeof offsets_) / sizeof *offsets_;
if (UNIV_LIKELY_NULL(merge_page_zip)) { if (UNIV_LIKELY_NULL(merge_page_zip)) {
/* The function page_zip_compress(), which will be /* The function page_zip_compress(), which will be
...@@ -2371,7 +2389,7 @@ btr_compress( ...@@ -2371,7 +2389,7 @@ btr_compress(
memset(merge_page + FIL_PAGE_PREV, 0xff, 4); memset(merge_page + FIL_PAGE_PREV, 0xff, 4);
} }
orig_succ = page_copy_rec_list_end(merge_page, merge_page_zip, orig_succ = page_copy_rec_list_end(merge_block,
page_get_infimum_rec(page), page_get_infimum_rec(page),
cursor->index, mtr); cursor->index, mtr);
...@@ -2380,10 +2398,10 @@ btr_compress( ...@@ -2380,10 +2398,10 @@ btr_compress(
/* FIL_PAGE_PREV was restored from merge_page_zip. */ /* FIL_PAGE_PREV was restored from merge_page_zip. */
ut_ad(!memcmp(fil_page_prev, ut_ad(!memcmp(fil_page_prev,
merge_page + FIL_PAGE_PREV, 4)); merge_page + FIL_PAGE_PREV, 4));
return(FALSE); goto err_exit;
} }
btr_search_drop_page_hash_index(buf_block_align(page)); btr_search_drop_page_hash_index(block);
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
if (UNIV_LIKELY_NULL(merge_page_zip)) { if (UNIV_LIKELY_NULL(merge_page_zip)) {
...@@ -2404,19 +2422,16 @@ btr_compress( ...@@ -2404,19 +2422,16 @@ btr_compress(
address of the merge page to the right */ address of the merge page to the right */
btr_node_ptr_set_child_page_no( btr_node_ptr_set_child_page_no(
node_ptr, btr_cur_get_rec(&father_cursor),
buf_frame_get_page_zip(node_ptr), btr_cur_get_page_zip(&father_cursor),
rec_get_offsets(node_ptr, index, offsets_, offsets, right_page_no, mtr);
ULINT_UNDEFINED, &heap), btr_node_ptr_delete(index, merge_block, mtr);
right_page_no, mtr);
if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap);
}
btr_node_ptr_delete(index, merge_page, mtr);
lock_update_merge_right(orig_succ, page); lock_update_merge_right(orig_succ, page);
} }
mem_heap_free(heap);
/* We have added new records to merge_page: update its free bits */ /* We have added new records to merge_page: update its free bits */
ibuf_update_free_bits_if_full(index, merge_block, ibuf_update_free_bits_if_full(index, merge_block,
UNIV_PAGE_SIZE, ULINT_UNDEFINED); UNIV_PAGE_SIZE, ULINT_UNDEFINED);
...@@ -2440,8 +2455,10 @@ btr_discard_only_page_on_level( ...@@ -2440,8 +2455,10 @@ btr_discard_only_page_on_level(
buf_block_t* block, /* in: page which is the only on its level */ buf_block_t* block, /* in: page which is the only on its level */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
btr_cur_t father_cursor;
buf_block_t* father_block; buf_block_t* father_block;
page_t* father_page; page_t* father_page;
page_zip_des_t* father_page_zip;
page_t* page = buf_block_get_frame(block); page_t* page = buf_block_get_frame(block);
ulint page_level; ulint page_level;
...@@ -2450,16 +2467,16 @@ btr_discard_only_page_on_level( ...@@ -2450,16 +2467,16 @@ btr_discard_only_page_on_level(
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
btr_search_drop_page_hash_index(block); btr_search_drop_page_hash_index(block);
father_block = buf_block_align( btr_page_get_father(index, block, mtr, &father_cursor);
btr_page_get_father_node_ptr(index, page, mtr)); father_block = btr_cur_get_block(&father_cursor);
father_page_zip = buf_block_get_page_zip(father_block);
father_page = buf_block_get_frame(father_block); father_page = buf_block_get_frame(father_block);
page_level = btr_page_get_level(page, mtr); page_level = btr_page_get_level(page, mtr);
lock_update_discard(page_get_supremum_rec(father_page), page); lock_update_discard(page_get_supremum_rec(father_page), page);
btr_page_set_level(father_page, buf_block_get_page_zip(father_block), btr_page_set_level(father_page, father_page_zip, page_level, mtr);
page_level, mtr);
/* Free the file page */ /* Free the file page */
btr_page_free(index, block, mtr); btr_page_free(index, block, mtr);
...@@ -2468,9 +2485,7 @@ btr_discard_only_page_on_level( ...@@ -2468,9 +2485,7 @@ btr_discard_only_page_on_level(
== dict_index_get_page(index))) { == dict_index_get_page(index))) {
/* The father is the root page */ /* The father is the root page */
btr_page_empty(father_block, btr_page_empty(father_block, father_page_zip, mtr, index);
buf_block_get_page_zip(father_block),
mtr, index);
/* We play safe and reset the free bits for the father */ /* We play safe and reset the free bits for the father */
ibuf_reset_free_bits_with_type(index->type, father_block); ibuf_reset_free_bits_with_type(index->type, father_block);
...@@ -2502,34 +2517,31 @@ btr_discard_page( ...@@ -2502,34 +2517,31 @@ btr_discard_page(
page_t* page; page_t* page;
rec_t* node_ptr; rec_t* node_ptr;
block = buf_block_align(btr_cur_get_rec(cursor)); block = btr_cur_get_block(cursor);
page = buf_block_get_frame(block);
index = btr_cur_get_index(cursor); index = btr_cur_get_index(cursor);
ut_ad(dict_index_get_page(index) != page_get_page_no(page)); ut_ad(dict_index_get_page(index) != block->offset);
ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index), ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK)); MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
space = dict_index_get_space(index); space = dict_index_get_space(index);
/* Decide the page which will inherit the locks */ /* Decide the page which will inherit the locks */
left_page_no = btr_page_get_prev(page, mtr); left_page_no = btr_page_get_prev(buf_block_get_frame(block), mtr);
right_page_no = btr_page_get_next(page, mtr); right_page_no = btr_page_get_next(buf_block_get_frame(block), mtr);
if (left_page_no != FIL_NULL) { if (left_page_no != FIL_NULL) {
merge_page = btr_page_get(space, left_page_no, RW_X_LATCH, merge_page = btr_page_get(space, left_page_no, RW_X_LATCH,
mtr); mtr);
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(merge_page, mtr) ut_a(btr_page_get_next(merge_page, mtr) == block->offset);
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */ #endif /* UNIV_BTR_DEBUG */
} else if (right_page_no != FIL_NULL) { } else if (right_page_no != FIL_NULL) {
merge_page = btr_page_get(space, right_page_no, RW_X_LATCH, merge_page = btr_page_get(space, right_page_no, RW_X_LATCH,
mtr); mtr);
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(merge_page, mtr) ut_a(btr_page_get_prev(merge_page, mtr) == block->offset);
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */ #endif /* UNIV_BTR_DEBUG */
} else { } else {
btr_discard_only_page_on_level(index, block, mtr); btr_discard_only_page_on_level(index, block, mtr);
...@@ -2537,8 +2549,9 @@ btr_discard_page( ...@@ -2537,8 +2549,9 @@ btr_discard_page(
return; return;
} }
page = buf_block_get_frame(block);
ut_a(page_is_comp(merge_page) == page_is_comp(page)); ut_a(page_is_comp(merge_page) == page_is_comp(page));
btr_search_drop_page_hash_index(buf_block_align(page)); btr_search_drop_page_hash_index(block);
if (left_page_no == FIL_NULL && !page_is_leaf(page)) { if (left_page_no == FIL_NULL && !page_is_leaf(page)) {
...@@ -2556,7 +2569,7 @@ btr_discard_page( ...@@ -2556,7 +2569,7 @@ btr_discard_page(
btr_set_min_rec_mark(node_ptr, mtr); btr_set_min_rec_mark(node_ptr, mtr);
} }
btr_node_ptr_delete(index, page, mtr); btr_node_ptr_delete(index, block, mtr);
/* Remove the page from the level list */ /* Remove the page from the level list */
btr_level_list_remove(page, mtr); btr_level_list_remove(page, mtr);
...@@ -2670,8 +2683,9 @@ btr_print_recursive( ...@@ -2670,8 +2683,9 @@ btr_print_recursive(
*offsets = rec_get_offsets(node_ptr, index, *offsets, *offsets = rec_get_offsets(node_ptr, index, *offsets,
ULINT_UNDEFINED, heap); ULINT_UNDEFINED, heap);
child = btr_node_ptr_get_child(node_ptr, child = buf_block_get_frame(
*offsets, &mtr2); btr_node_ptr_get_child(node_ptr,
*offsets, &mtr2));
btr_print_recursive(index, child, width, btr_print_recursive(index, child, width,
heap, offsets, &mtr2); heap, offsets, &mtr2);
mtr_commit(&mtr2); mtr_commit(&mtr2);
...@@ -2730,32 +2744,32 @@ btr_check_node_ptr( ...@@ -2730,32 +2744,32 @@ btr_check_node_ptr(
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
mem_heap_t* heap; mem_heap_t* heap;
rec_t* node_ptr; dtuple_t* tuple;
dtuple_t* node_ptr_tuple; ulint* offsets;
btr_cur_t cursor;
buf_block_t* block = buf_block_align(page);
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
if (dict_index_get_page(index) == page_get_page_no(page)) { if (dict_index_get_page(index) == block->offset) {
return(TRUE); return(TRUE);
} }
node_ptr = btr_page_get_father_node_ptr(index, page, mtr); heap = mem_heap_create(256);
offsets = btr_page_get_father_block(NULL, heap, index, block, mtr,
&cursor);
if (page_is_leaf(page)) { if (page_is_leaf(page)) {
return(TRUE); goto func_exit;
} }
heap = mem_heap_create(256); tuple = dict_index_build_node_ptr(
node_ptr_tuple = dict_index_build_node_ptr(
index, page_rec_get_next(page_get_infimum_rec(page)), 0, heap, index, page_rec_get_next(page_get_infimum_rec(page)), 0, heap,
btr_page_get_level(page, mtr)); btr_page_get_level(page, mtr));
ut_a(!cmp_dtuple_rec(node_ptr_tuple, node_ptr, ut_a(!cmp_dtuple_rec(tuple, btr_cur_get_rec(&cursor), offsets));
rec_get_offsets(node_ptr, index, func_exit:
NULL, ULINT_UNDEFINED, &heap)));
mem_heap_free(heap); mem_heap_free(heap);
return(TRUE); return(TRUE);
...@@ -2972,12 +2986,13 @@ btr_validate_level( ...@@ -2972,12 +2986,13 @@ btr_validate_level(
ulint level) /* in: level number */ ulint level) /* in: level number */
{ {
ulint space; ulint space;
buf_block_t* block;
page_t* page; page_t* page;
buf_block_t* right_block = 0; /* remove warning */
page_t* right_page = 0; /* remove warning */ page_t* right_page = 0; /* remove warning */
page_t* father_page; page_t* father_page;
page_t* right_father_page; btr_cur_t node_cur;
rec_t* node_ptr; btr_cur_t right_node_cur;
rec_t* right_node_ptr;
rec_t* rec; rec_t* rec;
ulint right_page_no; ulint right_page_no;
ulint left_page_no; ulint left_page_no;
...@@ -2996,13 +3011,16 @@ btr_validate_level( ...@@ -2996,13 +3011,16 @@ btr_validate_level(
mtr_x_lock(dict_index_get_lock(index), &mtr); mtr_x_lock(dict_index_get_lock(index), &mtr);
page = btr_root_get(index, &mtr); block = btr_root_block_get(index, &mtr);
page = buf_block_get_frame(block);
space = page_get_space_id(page); space = page_get_space_id(page);
while (level != btr_page_get_level(page, &mtr)) { while (level != btr_page_get_level(page, &mtr)) {
rec_t* node_ptr;
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
page_zip = buf_frame_get_page_zip(page); page_zip = buf_block_get_page_zip(block);
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
ut_a(!page_is_leaf(page)); ut_a(!page_is_leaf(page));
...@@ -3013,7 +3031,8 @@ btr_validate_level( ...@@ -3013,7 +3031,8 @@ btr_validate_level(
node_ptr = page_cur_get_rec(&cursor); node_ptr = page_cur_get_rec(&cursor);
offsets = rec_get_offsets(node_ptr, index, offsets, offsets = rec_get_offsets(node_ptr, index, offsets,
ULINT_UNDEFINED, &heap); ULINT_UNDEFINED, &heap);
page = btr_node_ptr_get_child(node_ptr, offsets, &mtr); block = btr_node_ptr_get_child(node_ptr, offsets, &mtr);
page = buf_block_get_frame(block);
} }
/* Now we are on the desired level. Loop through the pages on that /* Now we are on the desired level. Loop through the pages on that
...@@ -3029,7 +3048,7 @@ btr_validate_level( ...@@ -3029,7 +3048,7 @@ btr_validate_level(
mtr_x_lock(dict_index_get_lock(index), &mtr); mtr_x_lock(dict_index_get_lock(index), &mtr);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
page_zip = buf_frame_get_page_zip(page); page_zip = buf_block_get_page_zip(block);
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
...@@ -3060,8 +3079,9 @@ btr_validate_level( ...@@ -3060,8 +3079,9 @@ btr_validate_level(
if (right_page_no != FIL_NULL) { if (right_page_no != FIL_NULL) {
rec_t* right_rec; rec_t* right_rec;
right_page = btr_page_get(space, right_page_no, RW_X_LATCH, right_block = btr_block_get(space, right_page_no, RW_X_LATCH,
&mtr); &mtr);
right_page = buf_block_get_frame(right_block);
if (UNIV_UNLIKELY(btr_page_get_prev(right_page, &mtr) if (UNIV_UNLIKELY(btr_page_get_prev(right_page, &mtr)
!= page_get_page_no(page))) { != page_get_page_no(page))) {
btr_validate_report2(index, level, page, right_page); btr_validate_report2(index, level, page, right_page);
...@@ -3124,21 +3144,27 @@ btr_validate_level( ...@@ -3124,21 +3144,27 @@ btr_validate_level(
page_is_comp(page))); page_is_comp(page)));
} }
if (page_get_page_no(page) != dict_index_get_page(index)) { if (buf_block_get_page_no(block) != dict_index_get_page(index)) {
/* Check father node pointers */ /* Check father node pointers */
node_ptr = btr_page_get_father_node_ptr(index, page, &mtr); const rec_t* node_ptr;
father_page = page_align(node_ptr);
offsets = rec_get_offsets(node_ptr, index, offsets = btr_page_get_father_block(offsets, heap, index,
offsets, ULINT_UNDEFINED, &heap); block, &mtr, &node_cur);
father_page = btr_cur_get_page(&node_cur);
node_ptr = btr_cur_get_rec(&node_cur);
btr_cur_position(
index, page_rec_get_prev(page_get_supremum_rec(page)),
block, &node_cur);
offsets = btr_page_get_father_node_ptr(offsets, heap,
&node_cur, &mtr);
if (btr_node_ptr_get_child_page_no(node_ptr, offsets) if (UNIV_UNLIKELY(node_ptr != btr_cur_get_rec(&node_cur))
!= page_get_page_no(page) || UNIV_UNLIKELY(btr_node_ptr_get_child_page_no(node_ptr,
|| node_ptr != btr_page_get_father_for_rec( offsets)
index, page, != buf_block_get_page_no(block))) {
page_rec_get_prev(page_get_supremum_rec(page)),
&mtr)) {
btr_validate_report1(index, level, page); btr_validate_report1(index, level, page);
...@@ -3149,19 +3175,16 @@ btr_validate_level( ...@@ -3149,19 +3175,16 @@ btr_validate_level(
buf_page_print(page, 0); buf_page_print(page, 0);
fputs("InnoDB: node ptr ", stderr); fputs("InnoDB: node ptr ", stderr);
rec_print_new(stderr, node_ptr, offsets); rec_print(stderr, node_ptr, index);
rec = btr_cur_get_rec(&node_cur);
fprintf(stderr, "\n" fprintf(stderr, "\n"
"InnoDB: node ptr child page n:o %lu\n", "InnoDB: node ptr child page n:o %lu\n",
(ulong) btr_node_ptr_get_child_page_no( (ulong) btr_node_ptr_get_child_page_no(
node_ptr, offsets)); rec, offsets));
fputs("InnoDB: record on page ", stderr); fputs("InnoDB: record on page ", stderr);
rec = btr_page_get_father_for_rec( rec_print_new(stderr, rec, offsets);
index, page,
page_rec_get_prev(page_get_supremum_rec(page)),
&mtr);
rec_print(stderr, rec, index);
putc('\n', stderr); putc('\n', stderr);
ret = FALSE; ret = FALSE;
...@@ -3169,10 +3192,6 @@ btr_validate_level( ...@@ -3169,10 +3192,6 @@ btr_validate_level(
} }
if (!page_is_leaf(page)) { if (!page_is_leaf(page)) {
offsets = rec_get_offsets(node_ptr, index,
offsets, ULINT_UNDEFINED,
&heap);
node_ptr_tuple = dict_index_build_node_ptr( node_ptr_tuple = dict_index_build_node_ptr(
index, index,
page_rec_get_next(page_get_infimum_rec(page)), page_rec_get_next(page_get_infimum_rec(page)),
...@@ -3212,13 +3231,14 @@ btr_validate_level( ...@@ -3212,13 +3231,14 @@ btr_validate_level(
page_get_supremum_rec(father_page))); page_get_supremum_rec(father_page)));
ut_a(btr_page_get_next(father_page, &mtr) == FIL_NULL); ut_a(btr_page_get_next(father_page, &mtr) == FIL_NULL);
} else { } else {
right_node_ptr = btr_page_get_father_node_ptr( offsets = btr_page_get_father_block(
index, right_page, &mtr); offsets, heap, index, right_block,
if (page_rec_get_next(node_ptr) &mtr, &right_node_cur);
if (page_rec_get_next((rec_t*) node_ptr)
!= page_get_supremum_rec(father_page)) { != page_get_supremum_rec(father_page)) {
if (right_node_ptr if (btr_cur_get_rec(&right_node_cur)
!= page_rec_get_next(node_ptr)) { != page_rec_get_next((rec_t*) node_ptr)) {
ret = FALSE; ret = FALSE;
fputs("InnoDB: node pointer to" fputs("InnoDB: node pointer to"
" the right page is wrong\n", " the right page is wrong\n",
...@@ -3232,9 +3252,11 @@ btr_validate_level( ...@@ -3232,9 +3252,11 @@ btr_validate_level(
buf_page_print(right_page, 0); buf_page_print(right_page, 0);
} }
} else { } else {
right_father_page = page_align(right_node_ptr); page_t* right_father_page
= btr_cur_get_page(&right_node_cur);
if (right_node_ptr != page_rec_get_next( if (btr_cur_get_rec(&right_node_cur)
!= page_rec_get_next(
page_get_infimum_rec( page_get_infimum_rec(
right_father_page))) { right_father_page))) {
ret = FALSE; ret = FALSE;
...@@ -3280,7 +3302,8 @@ btr_validate_level( ...@@ -3280,7 +3302,8 @@ btr_validate_level(
if (right_page_no != FIL_NULL) { if (right_page_no != FIL_NULL) {
mtr_start(&mtr); mtr_start(&mtr);
page = btr_page_get(space, right_page_no, RW_X_LATCH, &mtr); block = btr_block_get(space, right_page_no, RW_X_LATCH, &mtr);
page = buf_block_get_frame(block);
goto loop; goto loop;
} }
......
...@@ -532,10 +532,12 @@ btr_cur_search_to_nth_level( ...@@ -532,10 +532,12 @@ btr_cur_search_to_nth_level(
page_mode = mode; page_mode = mode;
} }
cursor->page_block = block;
page_cur_search_with_match(page, index, tuple, page_mode, page_cur_search_with_match(page, index, tuple, page_mode,
&up_match, &up_bytes, &up_match, &up_bytes,
&low_match, &low_bytes, &low_match, &low_bytes,
page_cursor); page_cursor);
if (estimate) { if (estimate) {
btr_cur_add_path_info(cursor, height, root_height); btr_cur_add_path_info(cursor, height, root_height);
} }
...@@ -676,6 +678,7 @@ btr_cur_open_at_index_side( ...@@ -676,6 +678,7 @@ btr_cur_open_at_index_side(
btr_page_get_index_id(page))); btr_page_get_index_id(page)));
block->check_index_page_at_flush = TRUE; block->check_index_page_at_flush = TRUE;
cursor->page_block = block;
if (height == ULINT_UNDEFINED) { if (height == ULINT_UNDEFINED) {
/* We are in the root node */ /* We are in the root node */
...@@ -705,6 +708,7 @@ btr_cur_open_at_index_side( ...@@ -705,6 +708,7 @@ btr_cur_open_at_index_side(
} }
} }
ut_ad(buf_block_get_frame(btr_cur_get_block(cursor)) == page);
if (from_left) { if (from_left) {
page_cur_set_before_first(page, page_cursor); page_cur_set_before_first(page, page_cursor);
} else { } else {
...@@ -804,6 +808,7 @@ btr_cur_open_at_rnd_pos( ...@@ -804,6 +808,7 @@ btr_cur_open_at_rnd_pos(
latch_mode, cursor, mtr); latch_mode, cursor, mtr);
} }
cursor->page_block = block;
page_cur_open_on_rnd_user_rec(page, page_cursor); page_cur_open_on_rnd_user_rec(page, page_cursor);
if (height == 0) { if (height == 0) {
...@@ -850,14 +855,14 @@ btr_cur_insert_if_possible( ...@@ -850,14 +855,14 @@ btr_cur_insert_if_possible(
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
page_cur_t* page_cursor; page_cur_t* page_cursor;
page_t* page; buf_block_t* block;
rec_t* rec; rec_t* rec;
ut_ad(dtuple_check_typed(tuple)); ut_ad(dtuple_check_typed(tuple));
page = btr_cur_get_page(cursor); block = btr_cur_get_block(cursor);
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
page_cursor = btr_cur_get_page_cur(cursor); page_cursor = btr_cur_get_page_cur(cursor);
/* Now, try the insert */ /* Now, try the insert */
...@@ -867,9 +872,10 @@ btr_cur_insert_if_possible( ...@@ -867,9 +872,10 @@ btr_cur_insert_if_possible(
if (UNIV_UNLIKELY(!rec)) { if (UNIV_UNLIKELY(!rec)) {
/* If record did not fit, reorganize */ /* If record did not fit, reorganize */
if (btr_page_reorganize(page, cursor->index, mtr)) { if (btr_page_reorganize(block, cursor->index, mtr)) {
page_cur_search(page, cursor->index, tuple, page_cur_search(buf_block_get_frame(block),
cursor->index, tuple,
PAGE_CUR_LE, page_cursor); PAGE_CUR_LE, page_cursor);
rec = page_cur_tuple_insert(page_cursor, page_zip, rec = page_cur_tuple_insert(page_cursor, page_zip,
...@@ -910,7 +916,9 @@ btr_cur_ins_lock_and_undo( ...@@ -910,7 +916,9 @@ btr_cur_ins_lock_and_undo(
rec = btr_cur_get_rec(cursor); rec = btr_cur_get_rec(cursor);
index = cursor->index; index = cursor->index;
err = lock_rec_insert_check_and_lock(flags, rec, index, thr, inherit); err = lock_rec_insert_check_and_lock(flags, rec,
btr_cur_get_block(cursor),
index, thr, inherit);
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
...@@ -1045,7 +1053,7 @@ btr_cur_optimistic_insert( ...@@ -1045,7 +1053,7 @@ btr_cur_optimistic_insert(
*big_rec = NULL; *big_rec = NULL;
block = buf_block_align(btr_cur_get_rec(cursor)); block = btr_cur_get_block(cursor);
page = buf_block_get_frame(block); page = buf_block_get_frame(block);
index = cursor->index; index = cursor->index;
page_zip = buf_block_get_page_zip(block); page_zip = buf_block_get_page_zip(block);
...@@ -1135,7 +1143,7 @@ btr_cur_optimistic_insert( ...@@ -1135,7 +1143,7 @@ btr_cur_optimistic_insert(
entry, index, ext, n_ext, mtr); entry, index, ext, n_ext, mtr);
if (UNIV_UNLIKELY(!(*rec))) { if (UNIV_UNLIKELY(!(*rec))) {
/* If the record did not fit, reorganize */ /* If the record did not fit, reorganize */
if (UNIV_UNLIKELY(!btr_page_reorganize(page, index, mtr))) { if (UNIV_UNLIKELY(!btr_page_reorganize(block, index, mtr))) {
ut_a(page_zip); ut_a(page_zip);
goto fail; goto fail;
...@@ -1233,7 +1241,7 @@ btr_cur_pessimistic_insert( ...@@ -1233,7 +1241,7 @@ btr_cur_pessimistic_insert(
ulint zip_size = dict_table_zip_size(index->table); ulint zip_size = dict_table_zip_size(index->table);
big_rec_t* big_rec_vec = NULL; big_rec_t* big_rec_vec = NULL;
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
page_t* page; buf_block_t* block;
ulint err; ulint err;
ibool dummy_inh; ibool dummy_inh;
ibool success; ibool success;
...@@ -1244,12 +1252,12 @@ btr_cur_pessimistic_insert( ...@@ -1244,12 +1252,12 @@ btr_cur_pessimistic_insert(
*big_rec = NULL; *big_rec = NULL;
page = btr_cur_get_page(cursor); block = btr_cur_get_block(cursor);
ut_ad(mtr_memo_contains(mtr, ut_ad(mtr_memo_contains(mtr,
dict_index_get_lock(btr_cur_get_index(cursor)), dict_index_get_lock(btr_cur_get_index(cursor)),
MTR_MEMO_X_LOCK)); MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
/* Try first an optimistic insert; reset the cursor flag: we do not /* Try first an optimistic insert; reset the cursor flag: we do not
assume anything of how it was positioned */ assume anything of how it was positioned */
...@@ -1291,7 +1299,8 @@ btr_cur_pessimistic_insert( ...@@ -1291,7 +1299,8 @@ btr_cur_pessimistic_insert(
if (page_zip_rec_needs_ext(rec_get_converted_size(index, entry, if (page_zip_rec_needs_ext(rec_get_converted_size(index, entry,
ext, n_ext), ext, n_ext),
page_is_comp(page), zip_size)) { dict_table_is_comp(index->table),
zip_size)) {
/* The record is so big that we have to store some fields /* The record is so big that we have to store some fields
externally on separate database pages */ externally on separate database pages */
...@@ -1359,7 +1368,7 @@ btr_cur_pessimistic_insert( ...@@ -1359,7 +1368,7 @@ btr_cur_pessimistic_insert(
} }
} }
if (dict_index_get_page(index) == page_get_page_no(page)) { if (dict_index_get_page(index) == buf_block_get_page_no(block)) {
/* The page is the root page */ /* The page is the root page */
*rec = btr_root_raise_and_insert(cursor, entry, *rec = btr_root_raise_and_insert(cursor, entry,
...@@ -1373,7 +1382,7 @@ btr_cur_pessimistic_insert( ...@@ -1373,7 +1382,7 @@ btr_cur_pessimistic_insert(
mem_heap_free(heap); mem_heap_free(heap);
} }
btr_cur_position(index, page_rec_get_prev(*rec), cursor); btr_cur_position(index, page_rec_get_prev(*rec), block, cursor);
#ifdef BTR_CUR_ADAPT #ifdef BTR_CUR_ADAPT
btr_search_update_hash_on_insert(cursor); btr_search_update_hash_on_insert(cursor);
...@@ -1424,8 +1433,9 @@ btr_cur_upd_lock_and_undo( ...@@ -1424,8 +1433,9 @@ btr_cur_upd_lock_and_undo(
if (!dict_index_is_clust(index)) { if (!dict_index_is_clust(index)) {
/* We do undo logging only when we update a clustered index /* We do undo logging only when we update a clustered index
record */ record */
return(lock_sec_rec_modify_check_and_lock(flags, rec, index, return(lock_sec_rec_modify_check_and_lock(
thr)); flags, rec, btr_cur_get_block(cursor),
index, thr));
} }
/* Check if we have to wait for a lock: enqueue an explicit lock /* Check if we have to wait for a lock: enqueue an explicit lock
...@@ -1628,7 +1638,7 @@ btr_cur_update_in_place( ...@@ -1628,7 +1638,7 @@ btr_cur_update_in_place(
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
block = buf_block_align(rec); block = btr_cur_get_block(cursor);
/* Check that enough space is available on the compressed page. */ /* Check that enough space is available on the compressed page. */
page_zip = buf_block_get_page_zip(block); page_zip = buf_block_get_page_zip(block);
...@@ -1728,6 +1738,7 @@ btr_cur_optimistic_update( ...@@ -1728,6 +1738,7 @@ btr_cur_optimistic_update(
dict_index_t* index; dict_index_t* index;
page_cur_t* page_cursor; page_cur_t* page_cursor;
ulint err; ulint err;
buf_block_t* block;
page_t* page; page_t* page;
page_zip_des_t* page_zip; page_zip_des_t* page_zip;
rec_t* rec; rec_t* rec;
...@@ -1742,10 +1753,12 @@ btr_cur_optimistic_update( ...@@ -1742,10 +1753,12 @@ btr_cur_optimistic_update(
ulint i; ulint i;
ulint* offsets; ulint* offsets;
page = btr_cur_get_page(cursor); block = btr_cur_get_block(cursor);
page = buf_block_get_frame(block);
orig_rec = rec = btr_cur_get_rec(cursor); orig_rec = rec = btr_cur_get_rec(cursor);
index = cursor->index; index = cursor->index;
ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table)); ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table));
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
heap = mem_heap_create(1024); heap = mem_heap_create(1024);
offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap); offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap);
...@@ -1757,7 +1770,6 @@ btr_cur_optimistic_update( ...@@ -1757,7 +1770,6 @@ btr_cur_optimistic_update(
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX));
if (!row_upd_changes_field_size_or_external(index, offsets, update)) { if (!row_upd_changes_field_size_or_external(index, offsets, update)) {
/* The simplest and the most common case: the update does not /* The simplest and the most common case: the update does not
...@@ -1798,7 +1810,7 @@ btr_cur_optimistic_update( ...@@ -1798,7 +1810,7 @@ btr_cur_optimistic_update(
old_rec_size = rec_offs_size(offsets); old_rec_size = rec_offs_size(offsets);
new_rec_size = rec_get_converted_size(index, new_entry, NULL, 0); new_rec_size = rec_get_converted_size(index, new_entry, NULL, 0);
page_zip = buf_frame_get_page_zip(page); page_zip = buf_block_get_page_zip(block);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
...@@ -1975,6 +1987,7 @@ btr_cur_pessimistic_update( ...@@ -1975,6 +1987,7 @@ btr_cur_pessimistic_update(
big_rec_t* big_rec_vec = NULL; big_rec_t* big_rec_vec = NULL;
big_rec_t* dummy_big_rec; big_rec_t* dummy_big_rec;
dict_index_t* index; dict_index_t* index;
buf_block_t* block;
page_t* page; page_t* page;
page_zip_des_t* page_zip; page_zip_des_t* page_zip;
rec_t* rec; rec_t* rec;
...@@ -1994,14 +2007,15 @@ btr_cur_pessimistic_update( ...@@ -1994,14 +2007,15 @@ btr_cur_pessimistic_update(
*big_rec = NULL; *big_rec = NULL;
page = btr_cur_get_page(cursor); block = btr_cur_get_block(cursor);
page_zip = buf_frame_get_page_zip(page); page = buf_block_get_frame(block);
page_zip = buf_block_get_page_zip(block);
rec = btr_cur_get_rec(cursor); rec = btr_cur_get_rec(cursor);
index = cursor->index; index = cursor->index;
ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index), ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK)); MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
...@@ -2374,8 +2388,6 @@ btr_cur_del_mark_set_clust_rec( ...@@ -2374,8 +2388,6 @@ btr_cur_del_mark_set_clust_rec(
ut_ad(dict_index_is_clust(index)); ut_ad(dict_index_is_clust(index));
ut_ad(!rec_get_deleted_flag(rec, rec_offs_comp(offsets))); ut_ad(!rec_get_deleted_flag(rec, rec_offs_comp(offsets)));
page_zip = buf_frame_get_page_zip(rec);
err = lock_clust_rec_modify_check_and_lock(flags, err = lock_clust_rec_modify_check_and_lock(flags,
rec, index, offsets, thr); rec, index, offsets, thr);
...@@ -2392,12 +2404,14 @@ btr_cur_del_mark_set_clust_rec( ...@@ -2392,12 +2404,14 @@ btr_cur_del_mark_set_clust_rec(
goto func_exit; goto func_exit;
} }
block = buf_block_align(rec); block = btr_cur_get_block(cursor);
if (block->is_hashed) { if (block->is_hashed) {
rw_lock_x_lock(&btr_search_latch); rw_lock_x_lock(&btr_search_latch);
} }
page_zip = buf_block_get_page_zip(block);
btr_rec_set_deleted_flag(rec, page_zip, val); btr_rec_set_deleted_flag(rec, page_zip, val);
trx = thr_get_trx(thr); trx = thr_get_trx(thr);
...@@ -2512,10 +2526,10 @@ btr_cur_del_mark_set_sec_rec( ...@@ -2512,10 +2526,10 @@ btr_cur_del_mark_set_sec_rec(
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
buf_block_t* block; buf_block_t* block;
page_zip_des_t* page_zip;
rec_t* rec; rec_t* rec;
ulint err; ulint err;
block = btr_cur_get_block(cursor);
rec = btr_cur_get_rec(cursor); rec = btr_cur_get_rec(cursor);
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
...@@ -2526,23 +2540,22 @@ btr_cur_del_mark_set_sec_rec( ...@@ -2526,23 +2540,22 @@ btr_cur_del_mark_set_sec_rec(
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
err = lock_sec_rec_modify_check_and_lock(flags, rec, cursor->index, err = lock_sec_rec_modify_check_and_lock(flags, rec,
thr); btr_cur_get_block(cursor),
cursor->index, thr);
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
return(err); return(err);
} }
block = buf_block_align(rec); ut_ad(!!page_rec_is_comp(rec)
ut_ad(!!page_is_comp(buf_block_get_frame(block))
== dict_table_is_comp(cursor->index->table)); == dict_table_is_comp(cursor->index->table));
page_zip = buf_frame_get_page_zip(rec);
if (block->is_hashed) { if (block->is_hashed) {
rw_lock_x_lock(&btr_search_latch); rw_lock_x_lock(&btr_search_latch);
} }
btr_rec_set_deleted_flag(rec, page_zip, val); btr_rec_set_deleted_flag(rec, buf_block_get_page_zip(block), val);
if (block->is_hashed) { if (block->is_hashed) {
rw_lock_x_unlock(&btr_search_latch); rw_lock_x_unlock(&btr_search_latch);
...@@ -2566,9 +2579,6 @@ btr_cur_del_unmark_for_ibuf( ...@@ -2566,9 +2579,6 @@ btr_cur_del_unmark_for_ibuf(
/* We do not need to reserve btr_search_latch, as the page has just /* We do not need to reserve btr_search_latch, as the page has just
been read to the buffer pool and there cannot be a hash index to it. */ been read to the buffer pool and there cannot be a hash index to it. */
/* The insert buffer is not used on compressed pages. */
ut_ad(!buf_frame_get_page_zip(rec));
btr_rec_set_deleted_flag(rec, NULL, FALSE); btr_rec_set_deleted_flag(rec, NULL, FALSE);
btr_cur_del_mark_set_sec_rec_log(rec, FALSE, mtr); btr_cur_del_mark_set_sec_rec_log(rec, FALSE, mtr);
...@@ -2595,8 +2605,8 @@ btr_cur_compress_if_useful( ...@@ -2595,8 +2605,8 @@ btr_cur_compress_if_useful(
ut_ad(mtr_memo_contains(mtr, ut_ad(mtr_memo_contains(mtr,
dict_index_get_lock(btr_cur_get_index(cursor)), dict_index_get_lock(btr_cur_get_index(cursor)),
MTR_MEMO_X_LOCK)); MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains_page(mtr, btr_cur_get_rec(cursor), ut_ad(mtr_memo_contains(mtr, btr_cur_get_block(cursor),
MTR_MEMO_PAGE_X_FIX)); MTR_MEMO_PAGE_X_FIX));
return(btr_cur_compress_recommendation(cursor, mtr) return(btr_cur_compress_recommendation(cursor, mtr)
&& btr_compress(cursor, mtr)); && btr_compress(cursor, mtr));
...@@ -2627,11 +2637,11 @@ btr_cur_optimistic_delete( ...@@ -2627,11 +2637,11 @@ btr_cur_optimistic_delete(
ibool no_compress_needed; ibool no_compress_needed;
*offsets_ = (sizeof offsets_) / sizeof *offsets_; *offsets_ = (sizeof offsets_) / sizeof *offsets_;
ut_ad(mtr_memo_contains_page(mtr, btr_cur_get_rec(cursor), ut_ad(mtr_memo_contains(mtr, btr_cur_get_block(cursor),
MTR_MEMO_PAGE_X_FIX)); MTR_MEMO_PAGE_X_FIX));
/* This is intended only for leaf page deletions */ /* This is intended only for leaf page deletions */
block = buf_block_align(btr_cur_get_rec(cursor)); block = btr_cur_get_block(cursor);
ut_ad(page_is_leaf(buf_block_get_frame(block))); ut_ad(page_is_leaf(buf_block_get_frame(block)));
...@@ -2702,6 +2712,7 @@ btr_cur_pessimistic_delete( ...@@ -2702,6 +2712,7 @@ btr_cur_pessimistic_delete(
ibool in_rollback,/* in: TRUE if called in rollback */ ibool in_rollback,/* in: TRUE if called in rollback */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
buf_block_t* block;
page_t* page; page_t* page;
page_zip_des_t* page_zip; page_zip_des_t* page_zip;
dict_index_t* index; dict_index_t* index;
...@@ -2715,12 +2726,13 @@ btr_cur_pessimistic_delete( ...@@ -2715,12 +2726,13 @@ btr_cur_pessimistic_delete(
mem_heap_t* heap; mem_heap_t* heap;
ulint* offsets; ulint* offsets;
page = btr_cur_get_page(cursor); block = btr_cur_get_block(cursor);
page = buf_block_get_frame(block);
index = btr_cur_get_index(cursor); index = btr_cur_get_index(cursor);
ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index), ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK)); MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
if (!has_reserved_extents) { if (!has_reserved_extents) {
/* First reserve enough free space for the file segments /* First reserve enough free space for the file segments
of the index tree, so that the node pointer updates will of the index tree, so that the node pointer updates will
...@@ -2741,7 +2753,7 @@ btr_cur_pessimistic_delete( ...@@ -2741,7 +2753,7 @@ btr_cur_pessimistic_delete(
heap = mem_heap_create(1024); heap = mem_heap_create(1024);
rec = btr_cur_get_rec(cursor); rec = btr_cur_get_rec(cursor);
page_zip = buf_frame_get_page_zip(page); page_zip = buf_block_get_page_zip(block);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
...@@ -2764,7 +2776,7 @@ btr_cur_pessimistic_delete( ...@@ -2764,7 +2776,7 @@ btr_cur_pessimistic_delete(
if (UNIV_UNLIKELY(page_get_n_recs(page) < 2) if (UNIV_UNLIKELY(page_get_n_recs(page) < 2)
&& UNIV_UNLIKELY(dict_index_get_page(btr_cur_get_index(cursor)) && UNIV_UNLIKELY(dict_index_get_page(btr_cur_get_index(cursor))
!= page_get_page_no(page))) { != buf_block_get_page_no(block))) {
/* If there is only one record, drop the whole page in /* If there is only one record, drop the whole page in
btr_discard_page, if this is not the root page */ btr_discard_page, if this is not the root page */
...@@ -2804,7 +2816,7 @@ btr_cur_pessimistic_delete( ...@@ -2804,7 +2816,7 @@ btr_cur_pessimistic_delete(
so that it is equal to the new leftmost node pointer so that it is equal to the new leftmost node pointer
on the page */ on the page */
btr_node_ptr_delete(index, page, mtr); btr_node_ptr_delete(index, block, mtr);
node_ptr = dict_index_build_node_ptr( node_ptr = dict_index_build_node_ptr(
index, next_rec, page_get_page_no(page), index, next_rec, page_get_page_no(page),
...@@ -3593,11 +3605,12 @@ btr_store_big_rec_extern_fields( ...@@ -3593,11 +3605,12 @@ btr_store_big_rec_extern_fields(
ut_ad(mtr_memo_contains_page(local_mtr, rec, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains_page(local_mtr, rec, MTR_MEMO_PAGE_X_FIX));
ut_a(dict_index_is_clust(index)); ut_a(dict_index_is_clust(index));
space_id = page_get_space_id(page_align(rec)); rec_block = buf_block_align(rec);
page_zip = buf_block_get_page_zip(rec_block);
page_zip = buf_frame_get_page_zip(rec);
ut_a(dict_table_zip_size(index->table) ut_a(dict_table_zip_size(index->table)
== (page_zip ? page_zip->size : 0)); == buf_block_get_zip_size(rec_block));
space_id = buf_block_get_space(rec_block);
if (UNIV_LIKELY_NULL(page_zip)) { if (UNIV_LIKELY_NULL(page_zip)) {
int err; int err;
...@@ -3685,8 +3698,8 @@ btr_store_big_rec_extern_fields( ...@@ -3685,8 +3698,8 @@ btr_store_big_rec_extern_fields(
mlog_write_ulint( mlog_write_ulint(
prev_page + FIL_PAGE_NEXT, prev_page + FIL_PAGE_NEXT,
page_no, MLOG_4BYTES, &mtr); page_no, MLOG_4BYTES, &mtr);
memcpy(buf_frame_get_page_zip( memcpy(buf_block_get_page_zip(
prev_page) prev_block)
->data + FIL_PAGE_NEXT, ->data + FIL_PAGE_NEXT,
prev_page + FIL_PAGE_NEXT, 4); prev_page + FIL_PAGE_NEXT, 4);
} else { } else {
...@@ -3914,14 +3927,12 @@ btr_free_externally_stored_field( ...@@ -3914,14 +3927,12 @@ btr_free_externally_stored_field(
mtr_t mtr; mtr_t mtr;
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
buf_block_t* block = buf_block_align(field_ref); buf_block_t* block = buf_block_align(field_ref);
#endif /* UNIV_DEBUG */
ut_ad(mtr_memo_contains(local_mtr, dict_index_get_lock(index), ut_ad(mtr_memo_contains(local_mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK)); MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(local_mtr, block, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(local_mtr, block, MTR_MEMO_PAGE_X_FIX));
ut_ad(!rec || rec_offs_validate(rec, index, offsets)); ut_ad(!rec || rec_offs_validate(rec, index, offsets));
#ifdef UNIV_DEBUG
if (rec) { if (rec) {
ulint local_len; ulint local_len;
byte* f = rec_get_nth_field(rec, offsets, i, &local_len); byte* f = rec_get_nth_field(rec, offsets, i, &local_len);
......
...@@ -75,6 +75,7 @@ btr_pcur_store_position( ...@@ -75,6 +75,7 @@ btr_pcur_store_position(
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
page_cur_t* page_cursor; page_cur_t* page_cursor;
buf_block_t* block;
rec_t* rec; rec_t* rec;
dict_index_t* index; dict_index_t* index;
page_t* page; page_t* page;
...@@ -83,6 +84,7 @@ btr_pcur_store_position( ...@@ -83,6 +84,7 @@ btr_pcur_store_position(
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);
block = btr_pcur_get_block(cursor);
index = btr_cur_get_index(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);
...@@ -91,8 +93,8 @@ btr_pcur_store_position( ...@@ -91,8 +93,8 @@ btr_pcur_store_position(
page = page_align(rec); page = page_align(rec);
offs = page_offset(rec); offs = page_offset(rec);
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_S_FIX) ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_S_FIX)
|| mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); || mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
ut_a(cursor->latch_mode != BTR_NO_LATCHES); ut_a(cursor->latch_mode != BTR_NO_LATCHES);
if (UNIV_UNLIKELY(page_get_n_recs(page) == 0)) { if (UNIV_UNLIKELY(page_get_n_recs(page) == 0)) {
...@@ -135,9 +137,8 @@ btr_pcur_store_position( ...@@ -135,9 +137,8 @@ btr_pcur_store_position(
index, 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 = block;
cursor->modify_clock = buf_block_get_modify_clock( cursor->modify_clock = buf_block_get_modify_clock(block);
cursor->block_when_stored);
} }
/****************************************************************** /******************************************************************
...@@ -215,9 +216,9 @@ btr_pcur_restore_position( ...@@ -215,9 +216,9 @@ btr_pcur_restore_position(
ut_error; ut_error;
} }
if (UNIV_UNLIKELY( if (UNIV_UNLIKELY
cursor->rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE (cursor->rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE
|| cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE)) { || cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE)) {
/* In these cases we do not try an optimistic restoration, /* In these cases we do not try an optimistic restoration,
but always do a search */ but always do a search */
...@@ -226,8 +227,7 @@ btr_pcur_restore_position( ...@@ -226,8 +227,7 @@ btr_pcur_restore_position(
cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE, cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE,
index, latch_mode, btr_pcur_get_btr_cur(cursor), mtr); index, latch_mode, btr_pcur_get_btr_cur(cursor), mtr);
cursor->block_when_stored cursor->block_when_stored = btr_pcur_get_block(cursor);
= buf_block_align(btr_pcur_get_page(cursor));
return(FALSE); return(FALSE);
} }
...@@ -235,7 +235,7 @@ btr_pcur_restore_position( ...@@ -235,7 +235,7 @@ btr_pcur_restore_position(
ut_a(cursor->old_rec); ut_a(cursor->old_rec);
ut_a(cursor->old_n_fields); ut_a(cursor->old_n_fields);
page = btr_cur_get_page(btr_pcur_get_btr_cur(cursor)); page = btr_pcur_get_page(cursor);
if (UNIV_LIKELY(latch_mode == BTR_SEARCH_LEAF) if (UNIV_LIKELY(latch_mode == BTR_SEARCH_LEAF)
|| UNIV_LIKELY(latch_mode == BTR_MODIFY_LEAF)) { || UNIV_LIKELY(latch_mode == BTR_MODIFY_LEAF)) {
...@@ -247,7 +247,7 @@ btr_pcur_restore_position( ...@@ -247,7 +247,7 @@ btr_pcur_restore_position(
cursor->modify_clock, mtr))) { cursor->modify_clock, mtr))) {
cursor->pos_state = BTR_PCUR_IS_POSITIONED; cursor->pos_state = BTR_PCUR_IS_POSITIONED;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(buf_block_align(page), buf_block_dbg_add_level(btr_pcur_get_block(cursor),
SYNC_TREE_NODE); SYNC_TREE_NODE);
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
if (cursor->rel_pos == BTR_PCUR_ON) { if (cursor->rel_pos == BTR_PCUR_ON) {
...@@ -316,8 +316,7 @@ btr_pcur_restore_position( ...@@ -316,8 +316,7 @@ btr_pcur_restore_position(
the cursor can now be on a different page! But we can retain the cursor can now be on a different page! But we can retain
the value of old_rec */ the value of old_rec */
cursor->block_when_stored = buf_block_align( cursor->block_when_stored = btr_pcur_get_block(cursor);
btr_pcur_get_page(cursor));
cursor->modify_clock = buf_block_get_modify_clock( cursor->modify_clock = buf_block_get_modify_clock(
cursor->block_when_stored); cursor->block_when_stored);
cursor->old_stored = BTR_PCUR_OLD_STORED; cursor->old_stored = BTR_PCUR_OLD_STORED;
...@@ -356,7 +355,7 @@ btr_pcur_release_leaf( ...@@ -356,7 +355,7 @@ btr_pcur_release_leaf(
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);
block = buf_block_align(btr_cur_get_rec(btr_pcur_get_btr_cur(cursor))); block = btr_pcur_get_block(cursor);
btr_leaf_page_release(block, cursor->latch_mode, mtr); btr_leaf_page_release(block, cursor->latch_mode, mtr);
...@@ -391,9 +390,8 @@ btr_pcur_move_to_next_page( ...@@ -391,9 +390,8 @@ btr_pcur_move_to_next_page(
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
page = btr_pcur_get_page(cursor); page = btr_pcur_get_page(cursor);
next_page_no = btr_page_get_next(page, mtr); next_page_no = btr_page_get_next(page, mtr);
space = page_get_space_id(page); space = buf_block_get_space(btr_pcur_get_block(cursor));
ut_ad(next_page_no != FIL_NULL); ut_ad(next_page_no != FIL_NULL);
...@@ -402,12 +400,15 @@ btr_pcur_move_to_next_page( ...@@ -402,12 +400,15 @@ btr_pcur_move_to_next_page(
next_page = buf_block_get_frame(next_block); next_page = buf_block_get_frame(next_block);
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(next_page) == page_is_comp(page)); ut_a(page_is_comp(next_page) == page_is_comp(page));
ut_a(btr_page_get_prev(next_page, mtr) == page_get_page_no(page)); ut_a(btr_page_get_prev(next_page, mtr)
== buf_block_get_page_no(btr_pcur_get_block(cursor)));
#endif /* UNIV_BTR_DEBUG */ #endif /* UNIV_BTR_DEBUG */
next_block->check_index_page_at_flush = TRUE; next_block->check_index_page_at_flush = TRUE;
btr_leaf_page_release(buf_block_align(page), cursor->latch_mode, mtr); btr_leaf_page_release(btr_pcur_get_block(cursor),
cursor->latch_mode, mtr);
btr_pcur_get_btr_cur(cursor)->page_block = next_block;
page_cur_set_before_first(next_page, btr_pcur_get_page_cur(cursor)); page_cur_set_before_first(next_page, btr_pcur_get_page_cur(cursor));
page_check_dir(next_page); page_check_dir(next_page);
...@@ -467,18 +468,21 @@ btr_pcur_move_backward_from_page( ...@@ -467,18 +468,21 @@ btr_pcur_move_backward_from_page(
page = btr_pcur_get_page(cursor); page = btr_pcur_get_page(cursor);
prev_page_no = btr_page_get_prev(page, mtr); prev_page_no = btr_page_get_prev(page, mtr);
space = page_get_space_id(page); space = buf_block_get_space(btr_pcur_get_block(cursor));
if (btr_pcur_is_before_first_on_page(cursor, mtr) if (prev_page_no == FIL_NULL) {
&& (prev_page_no != FIL_NULL)) { } else if (btr_pcur_is_before_first_on_page(cursor, mtr)) {
prev_page = btr_pcur_get_btr_cur(cursor)->left_page; prev_page = btr_pcur_get_btr_cur(cursor)->left_page;
btr_leaf_page_release(buf_block_align(page), latch_mode, mtr); btr_leaf_page_release(btr_pcur_get_block(cursor),
latch_mode, mtr);
btr_pcur_get_btr_cur(cursor)->page_block
= buf_block_align(prev_page);
page_cur_set_after_last(prev_page, page_cur_set_after_last(prev_page,
btr_pcur_get_page_cur(cursor)); btr_pcur_get_page_cur(cursor));
} else if (prev_page_no != FIL_NULL) { } else {
/* The repositioned cursor did not end on an infimum record on /* The repositioned cursor did not end on an infimum record on
a page. Cursor repositioning acquired a latch also on the a page. Cursor repositioning acquired a latch also on the
......
...@@ -464,7 +464,7 @@ btr_search_info_update_slow( ...@@ -464,7 +464,7 @@ btr_search_info_update_slow(
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
block = buf_block_align(btr_cur_get_rec(cursor)); block = btr_cur_get_block(cursor);
/* NOTE that the following two function calls do NOT protect /* NOTE that the following two function calls do NOT protect
info or block->n_fields etc. with any semaphore, to save CPU time! info or block->n_fields etc. with any semaphore, to save CPU time!
...@@ -789,7 +789,7 @@ btr_search_guess_on_hash( ...@@ -789,7 +789,7 @@ btr_search_guess_on_hash(
ut_ad(block->state == BUF_BLOCK_FILE_PAGE); ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
ut_ad(page_rec_is_user_rec(rec)); ut_ad(page_rec_is_user_rec(rec));
btr_cur_position(index, rec, cursor); btr_cur_position(index, rec, block, cursor);
/* Check the validity of the guess within the page */ /* Check the validity of the guess within the page */
......
...@@ -2875,14 +2875,14 @@ void ...@@ -2875,14 +2875,14 @@ void
ibuf_insert_to_index_page( ibuf_insert_to_index_page(
/*======================*/ /*======================*/
dtuple_t* entry, /* in: buffered entry to insert */ dtuple_t* entry, /* in: buffered entry to insert */
page_t* page, /* in/out: index page where the buffered entry buf_block_t* block, /* in/out: index page where the buffered entry
should be placed */ should be placed */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
page_cur_t page_cur; page_cur_t page_cur;
ulint low_match; ulint low_match;
page_t* page = buf_block_get_frame(block);
rec_t* rec; rec_t* rec;
page_t* bitmap_page; page_t* bitmap_page;
ulint old_bits; ulint old_bits;
...@@ -2931,21 +2931,23 @@ ibuf_insert_to_index_page( ...@@ -2931,21 +2931,23 @@ ibuf_insert_to_index_page(
btr_cur_del_unmark_for_ibuf(rec, mtr); btr_cur_del_unmark_for_ibuf(rec, mtr);
} else { } else {
rec = page_cur_tuple_insert(&page_cur, page_zip, rec = page_cur_tuple_insert(&page_cur,
buf_block_get_page_zip(block),
entry, index, NULL, 0, mtr); entry, index, NULL, 0, mtr);
if (UNIV_UNLIKELY(rec == NULL)) { if (UNIV_UNLIKELY(rec == NULL)) {
/* If the record did not fit, reorganize */ /* If the record did not fit, reorganize */
btr_page_reorganize(page, index, mtr); btr_page_reorganize(block, index, mtr);
page_cur_search(page, index, entry, page_cur_search(page, index, entry,
PAGE_CUR_LE, &page_cur); PAGE_CUR_LE, &page_cur);
/* This time the record must fit */ /* This time the record must fit */
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!page_cur_tuple_insert(&page_cur, page_zip, entry, (!page_cur_tuple_insert(
index, NULL, 0, mtr))) { &page_cur, buf_block_get_page_zip(block),
entry, index, NULL, 0, mtr))) {
ulint space; ulint space;
ulint page_no; ulint page_no;
...@@ -3345,7 +3347,7 @@ ibuf_merge_or_delete_for_page( ...@@ -3345,7 +3347,7 @@ ibuf_merge_or_delete_for_page(
ut_a(volume <= 4 * UNIV_PAGE_SIZE ut_a(volume <= 4 * UNIV_PAGE_SIZE
/ IBUF_PAGE_SIZE_PER_FREE_SPACE); / IBUF_PAGE_SIZE_PER_FREE_SPACE);
#endif #endif
ibuf_insert_to_index_page(entry, page, page_zip, ibuf_insert_to_index_page(entry, block,
dummy_index, &mtr); dummy_index, &mtr);
ibuf_dummy_index_free(dummy_index); ibuf_dummy_index_free(dummy_index);
} }
......
...@@ -156,7 +156,7 @@ ulint ...@@ -156,7 +156,7 @@ ulint
btr_node_ptr_get_child_page_no( btr_node_ptr_get_child_page_no(
/*===========================*/ /*===========================*/
/* out: child node address */ /* out: child node address */
rec_t* rec, /* in: node pointer record */ const rec_t* rec, /* in: node pointer record */
const ulint* offsets);/* in: array returned by rec_get_offsets() */ const ulint* offsets);/* in: array returned by rec_get_offsets() */
/**************************************************************** /****************************************************************
Creates the root node for a new index tree. */ Creates the root node for a new index tree. */
...@@ -216,7 +216,7 @@ ibool ...@@ -216,7 +216,7 @@ ibool
btr_page_reorganize( btr_page_reorganize(
/*================*/ /*================*/
/* out: TRUE on success, FALSE on failure */ /* out: TRUE on success, FALSE on failure */
page_t* page, /* in: page to be reorganized */ buf_block_t* block, /* in: page to be reorganized */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr); /* in: mtr */ mtr_t* mtr); /* in: mtr */
/***************************************************************** /*****************************************************************
...@@ -290,7 +290,7 @@ void ...@@ -290,7 +290,7 @@ void
btr_node_ptr_delete( btr_node_ptr_delete(
/*================*/ /*================*/
dict_index_t* index, /* in: index tree */ dict_index_t* index, /* in: index tree */
page_t* page, /* in: page whose node pointer is deleted */ buf_block_t* block, /* in: page whose node pointer is deleted */
mtr_t* mtr); /* in: mtr */ mtr_t* mtr); /* in: mtr */
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
/**************************************************************** /****************************************************************
...@@ -357,8 +357,7 @@ btr_parse_page_reorganize( ...@@ -357,8 +357,7 @@ btr_parse_page_reorganize(
byte* ptr, /* in: buffer */ byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */ byte* end_ptr,/* in: buffer end */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
page_t* page, /* in/out: page to be reorganized, or NULL */ buf_block_t* block, /* in: page to be reorganized, or NULL */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
mtr_t* mtr); /* in: mtr or NULL */ mtr_t* mtr); /* in: mtr or NULL */
/****************************************************************** /******************************************************************
Gets the number of pages in a B-tree. */ Gets the number of pages in a B-tree. */
......
...@@ -229,17 +229,17 @@ ulint ...@@ -229,17 +229,17 @@ ulint
btr_node_ptr_get_child_page_no( btr_node_ptr_get_child_page_no(
/*===========================*/ /*===========================*/
/* out: child node address */ /* out: child node address */
rec_t* rec, /* in: node pointer record */ const rec_t* rec, /* in: node pointer record */
const ulint* offsets)/* in: array returned by rec_get_offsets() */ const ulint* offsets)/* in: array returned by rec_get_offsets() */
{ {
byte* field; const byte* field;
ulint len; ulint len;
ulint page_no; ulint page_no;
ut_ad(!rec_offs_comp(offsets) || rec_get_node_ptr_flag(rec)); ut_ad(!rec_offs_comp(offsets) || rec_get_node_ptr_flag(rec));
/* The child address is in the last field */ /* The child address is in the last field */
field = rec_get_nth_field(rec, offsets, field = rec_get_nth_field((rec_t*) rec, offsets,
rec_offs_n_fields(offsets) - 1, &len); rec_offs_n_fields(offsets) - 1, &len);
ut_ad(len == 4); ut_ad(len == 4);
...@@ -251,7 +251,7 @@ btr_node_ptr_get_child_page_no( ...@@ -251,7 +251,7 @@ btr_node_ptr_get_child_page_no(
"InnoDB: a nonsensical page number 0" "InnoDB: a nonsensical page number 0"
" in a node ptr record at offset %lu\n", " in a node ptr record at offset %lu\n",
(ulong) page_offset(rec)); (ulong) page_offset(rec));
buf_page_print(page_align(rec), 0); buf_page_print(page_align((rec_t*) rec), 0);
} }
return(page_no); return(page_no);
......
...@@ -36,6 +36,14 @@ btr_cur_get_page_cur( ...@@ -36,6 +36,14 @@ btr_cur_get_page_cur(
/* out: pointer to page cursor component */ /* out: pointer to page cursor component */
btr_cur_t* cursor);/* in: tree cursor */ btr_cur_t* cursor);/* in: tree cursor */
/************************************************************* /*************************************************************
Returns the buffer block on which the tree cursor is positioned. */
UNIV_INLINE
buf_block_t*
btr_cur_get_block(
/*==============*/
/* out: pointer to buffer block */
btr_cur_t* cursor);/* in: tree cursor */
/*************************************************************
Returns the record pointer of a tree cursor. */ Returns the record pointer of a tree cursor. */
UNIV_INLINE UNIV_INLINE
rec_t* rec_t*
...@@ -44,6 +52,15 @@ btr_cur_get_rec( ...@@ -44,6 +52,15 @@ btr_cur_get_rec(
/* out: pointer to record */ /* out: pointer to record */
btr_cur_t* cursor);/* in: tree cursor */ btr_cur_t* cursor);/* in: tree cursor */
/************************************************************* /*************************************************************
Returns the compressed page on which the tree cursor is positioned. */
UNIV_INLINE
page_zip_des_t*
btr_cur_get_page_zip(
/*=================*/
/* out: pointer to compressed page,
or NULL if the page is not compressed */
btr_cur_t* cursor);/* in: tree cursor */
/*************************************************************
Invalidates a tree cursor by setting record pointer to NULL. */ Invalidates a tree cursor by setting record pointer to NULL. */
UNIV_INLINE UNIV_INLINE
void void
...@@ -74,6 +91,7 @@ btr_cur_position( ...@@ -74,6 +91,7 @@ btr_cur_position(
/*=============*/ /*=============*/
dict_index_t* index, /* in: index */ dict_index_t* index, /* in: index */
rec_t* rec, /* in: record in tree */ rec_t* rec, /* in: record in tree */
buf_block_t* block, /* in: buffer block of rec */
btr_cur_t* cursor);/* in: cursor */ btr_cur_t* cursor);/* in: cursor */
/************************************************************************ /************************************************************************
Searches an index tree and positions a tree cursor on a given level. Searches an index tree and positions a tree cursor on a given level.
...@@ -577,6 +595,9 @@ to know struct size! */ ...@@ -577,6 +595,9 @@ to know struct size! */
struct btr_cur_struct { struct btr_cur_struct {
dict_index_t* index; /* index where positioned */ dict_index_t* index; /* index where positioned */
page_cur_t page_cur; /* page cursor */ page_cur_t page_cur; /* page cursor */
buf_block_t* page_block; /* buffer pool block were
cursor is positioned; needed
to avoid buf_block_align() */
page_t* left_page; /* this field is used to store page_t* left_page; /* this field is used to store
a pointer to the left neighbor a pointer to the left neighbor
page, in the cases page, in the cases
......
...@@ -19,6 +19,18 @@ btr_cur_get_page_cur( ...@@ -19,6 +19,18 @@ btr_cur_get_page_cur(
{ {
return(&(cursor->page_cur)); return(&(cursor->page_cur));
} }
/*************************************************************
Returns the buffer block on which the tree cursor is positioned. */
UNIV_INLINE
buf_block_t*
btr_cur_get_block(
/*==============*/
/* out: pointer to buffer block */
btr_cur_t* cursor) /* in: tree cursor */
{
ut_ad(page_align(cursor->page_cur.rec) == cursor->page_block->frame);
return(cursor->page_block);
}
/************************************************************* /*************************************************************
Returns the record pointer of a tree cursor. */ Returns the record pointer of a tree cursor. */
...@@ -29,9 +41,23 @@ btr_cur_get_rec( ...@@ -29,9 +41,23 @@ btr_cur_get_rec(
/* out: pointer to record */ /* out: pointer to record */
btr_cur_t* cursor) /* in: tree cursor */ btr_cur_t* cursor) /* in: tree cursor */
{ {
ut_ad(page_align(cursor->page_cur.rec) == cursor->page_block->frame);
return(page_cur_get_rec(&(cursor->page_cur))); return(page_cur_get_rec(&(cursor->page_cur)));
} }
/*************************************************************
Returns the compressed page on which the tree cursor is positioned. */
UNIV_INLINE
page_zip_des_t*
btr_cur_get_page_zip(
/*=================*/
/* out: pointer to compressed page,
or NULL if the page is not compressed */
btr_cur_t* cursor) /* in: tree cursor */
{
return(buf_block_get_page_zip(btr_cur_get_block(cursor)));
}
/************************************************************* /*************************************************************
Invalidates a tree cursor by setting record pointer to NULL. */ Invalidates a tree cursor by setting record pointer to NULL. */
UNIV_INLINE UNIV_INLINE
...@@ -41,6 +67,7 @@ btr_cur_invalidate( ...@@ -41,6 +67,7 @@ btr_cur_invalidate(
btr_cur_t* cursor) /* in: tree cursor */ btr_cur_t* cursor) /* in: tree cursor */
{ {
page_cur_invalidate(&(cursor->page_cur)); page_cur_invalidate(&(cursor->page_cur));
cursor->page_block = NULL;
} }
/************************************************************* /*************************************************************
...@@ -75,9 +102,13 @@ btr_cur_position( ...@@ -75,9 +102,13 @@ btr_cur_position(
/*=============*/ /*=============*/
dict_index_t* index, /* in: index */ dict_index_t* index, /* in: index */
rec_t* rec, /* in: record in tree */ rec_t* rec, /* in: record in tree */
btr_cur_t* cursor) /* in: cursor */ buf_block_t* block, /* in: buffer block of rec */
btr_cur_t* cursor) /* out: cursor */
{ {
ut_ad(page_align(rec) == buf_block_get_frame(block));
page_cur_position(rec, btr_cur_get_page_cur(cursor)); page_cur_position(rec, btr_cur_get_page_cur(cursor));
cursor->page_block = block;
cursor->index = index; cursor->index = index;
} }
......
...@@ -371,6 +371,14 @@ btr_pcur_get_page( ...@@ -371,6 +371,14 @@ btr_pcur_get_page(
/* out: pointer to the page */ /* out: pointer to the page */
btr_pcur_t* cursor);/* in: persistent cursor */ btr_pcur_t* cursor);/* in: persistent cursor */
/************************************************************* /*************************************************************
Returns the buffer block of a persistent cursor. */
UNIV_INLINE
buf_block_t*
btr_pcur_get_block(
/*===============*/
/* out: pointer to the block */
btr_pcur_t* cursor);/* in: persistent cursor */
/*************************************************************
Returns the record of a persistent cursor. */ Returns the record of a persistent cursor. */
UNIV_INLINE UNIV_INLINE
rec_t* rec_t*
......
...@@ -88,7 +88,21 @@ btr_pcur_get_page( ...@@ -88,7 +88,21 @@ btr_pcur_get_page(
{ {
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
return(page_cur_get_page(btr_pcur_get_page_cur(cursor))); return(btr_cur_get_page(btr_pcur_get_btr_cur(cursor)));
}
/*************************************************************
Returns the buffer block of a persistent cursor. */
UNIV_INLINE
buf_block_t*
btr_pcur_get_block(
/*===============*/
/* out: pointer to the block */
btr_pcur_t* cursor) /* in: persistent cursor */
{
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
return(btr_cur_get_block(btr_pcur_get_btr_cur(cursor)));
} }
/************************************************************* /*************************************************************
...@@ -103,7 +117,7 @@ btr_pcur_get_rec( ...@@ -103,7 +117,7 @@ btr_pcur_get_rec(
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
return(page_cur_get_rec(btr_pcur_get_page_cur(cursor))); return(btr_cur_get_rec(btr_pcur_get_btr_cur(cursor)));
} }
/****************************************************************** /******************************************************************
...@@ -296,7 +310,7 @@ btr_pcur_move_to_last_on_page( ...@@ -296,7 +310,7 @@ btr_pcur_move_to_last_on_page(
UT_NOT_USED(mtr); UT_NOT_USED(mtr);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
page_cur_set_after_last(page_align(btr_pcur_get_rec(cursor)), page_cur_set_after_last(btr_pcur_get_page(cursor),
btr_pcur_get_page_cur(cursor)); btr_pcur_get_page_cur(cursor));
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
...@@ -619,6 +633,7 @@ btr_pcur_close( ...@@ -619,6 +633,7 @@ btr_pcur_close(
cursor->old_rec_buf = NULL; cursor->old_rec_buf = NULL;
} }
cursor->btr_cur.page_block = NULL;
cursor->btr_cur.page_cur.rec = NULL; cursor->btr_cur.page_cur.rec = NULL;
cursor->old_rec = NULL; cursor->old_rec = NULL;
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
......
...@@ -132,9 +132,9 @@ UNIV_INLINE ...@@ -132,9 +132,9 @@ UNIV_INLINE
byte* byte*
buf_frame_copy( buf_frame_copy(
/*===========*/ /*===========*/
/* out: buf */ /* out: buf */
byte* buf, /* in: buffer to copy to */ byte* buf, /* in: buffer to copy to */
buf_frame_t* frame); /* in: buffer frame */ const buf_frame_t* frame); /* in: buffer frame */
/****************************************************************** /******************************************************************
NOTE! The following macros should be used instead of buf_page_get_gen, NOTE! The following macros should be used instead of buf_page_get_gen,
to improve debugging. Only values RW_S_LATCH and RW_X_LATCH are allowed to improve debugging. Only values RW_S_LATCH and RW_X_LATCH are allowed
...@@ -618,6 +618,7 @@ buf_block_align( ...@@ -618,6 +618,7 @@ buf_block_align(
/*============*/ /*============*/
/* out: pointer to block */ /* out: pointer to block */
byte* ptr); /* in: pointer to a frame */ byte* ptr); /* in: pointer to a frame */
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
/************************************************************************* /*************************************************************************
Gets the compressed page descriptor corresponding to an uncompressed page Gets the compressed page descriptor corresponding to an uncompressed page
if applicable. */ if applicable. */
...@@ -628,6 +629,7 @@ buf_frame_get_page_zip( ...@@ -628,6 +629,7 @@ buf_frame_get_page_zip(
/* out: compressed page descriptor, or NULL */ /* out: compressed page descriptor, or NULL */
byte* ptr) /* in: pointer to the page */ byte* ptr) /* in: pointer to the page */
__attribute((const)); __attribute((const));
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
/************************************************************************ /************************************************************************
This function is used to get info if there is an io operation This function is used to get info if there is an io operation
going on on a buffer page. */ going on on a buffer page. */
......
...@@ -261,6 +261,7 @@ buf_block_align( ...@@ -261,6 +261,7 @@ buf_block_align(
return(block); return(block);
} }
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
/************************************************************************* /*************************************************************************
Gets the compressed page descriptor corresponding to an uncompressed page Gets the compressed page descriptor corresponding to an uncompressed page
if applicable. */ if applicable. */
...@@ -273,6 +274,7 @@ buf_frame_get_page_zip( ...@@ -273,6 +274,7 @@ buf_frame_get_page_zip(
{ {
return(buf_block_get_page_zip(buf_block_align(ptr))); return(buf_block_get_page_zip(buf_block_align(ptr)));
} }
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
/************************************************************************** /**************************************************************************
Gets the space id, page offset, and byte offset within page of a Gets the space id, page offset, and byte offset within page of a
...@@ -286,7 +288,7 @@ buf_ptr_get_fsp_addr( ...@@ -286,7 +288,7 @@ buf_ptr_get_fsp_addr(
fil_addr_t* addr) /* out: page offset and byte offset */ fil_addr_t* addr) /* out: page offset and byte offset */
{ {
const page_t* page = ut_align_down((void*) ptr, UNIV_PAGE_SIZE); const page_t* page = ut_align_down((void*) ptr, UNIV_PAGE_SIZE);
ut_ad(buf_block_align(ptr)); ut_ad(buf_block_align((byte*) ptr));
*space = mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); *space = mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
addr->page = mach_read_from_4(page + FIL_PAGE_OFFSET); addr->page = mach_read_from_4(page + FIL_PAGE_OFFSET);
...@@ -361,9 +363,9 @@ UNIV_INLINE ...@@ -361,9 +363,9 @@ UNIV_INLINE
byte* byte*
buf_frame_copy( buf_frame_copy(
/*===========*/ /*===========*/
/* out: buf */ /* out: buf */
byte* buf, /* in: buffer to copy to */ byte* buf, /* in: buffer to copy to */
buf_frame_t* frame) /* in: buffer frame */ const buf_frame_t* frame) /* in: buffer frame */
{ {
ut_ad(buf && frame); ut_ad(buf && frame);
......
...@@ -10,6 +10,7 @@ Created 5/7/1996 Heikki Tuuri ...@@ -10,6 +10,7 @@ Created 5/7/1996 Heikki Tuuri
#define lock0lock_h #define lock0lock_h
#include "univ.i" #include "univ.i"
#include "buf0types.h"
#include "trx0types.h" #include "trx0types.h"
#include "rem0types.h" #include "rem0types.h"
#include "dict0types.h" #include "dict0types.h"
...@@ -250,6 +251,7 @@ lock_rec_insert_check_and_lock( ...@@ -250,6 +251,7 @@ lock_rec_insert_check_and_lock(
ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set, ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set,
does nothing */ does nothing */
rec_t* rec, /* in: record after which to insert */ rec_t* rec, /* in: record after which to insert */
buf_block_t* block, /* in: buffer block of rec */
dict_index_t* index, /* in: index */ dict_index_t* index, /* in: index */
que_thr_t* thr, /* in: query thread */ que_thr_t* thr, /* in: query thread */
ibool* inherit);/* out: set to TRUE if the new inserted ibool* inherit);/* out: set to TRUE if the new inserted
...@@ -289,6 +291,7 @@ lock_sec_rec_modify_check_and_lock( ...@@ -289,6 +291,7 @@ lock_sec_rec_modify_check_and_lock(
NOTE: as this is a secondary index, we NOTE: as this is a secondary index, we
always have to modify the clustered index always have to modify the clustered index
record first: see the comment below */ record first: see the comment below */
buf_block_t* block, /* in: buffer block of rec */
dict_index_t* index, /* in: secondary index */ dict_index_t* index, /* in: secondary index */
que_thr_t* thr); /* in: query thread */ que_thr_t* thr); /* in: query thread */
/************************************************************************* /*************************************************************************
......
...@@ -698,12 +698,11 @@ page_copy_rec_list_end( ...@@ -698,12 +698,11 @@ page_copy_rec_list_end(
on new_page, or NULL on zip overflow on new_page, or NULL on zip overflow
(new_page will be decompressed (new_page will be decompressed
from new_page_zip) */ from new_page_zip) */
page_t* new_page, /* in/out: index page to copy to */ buf_block_t* new_block, /* in/out: index page to copy to */
page_zip_des_t* new_page_zip, /* in/out: compressed page, or NULL */
rec_t* rec, /* in: record on page */ rec_t* rec, /* in: record on page */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
__attribute__((warn_unused_result, nonnull(1, 3, 4, 5))); __attribute__((warn_unused_result, nonnull));
/***************************************************************** /*****************************************************************
Copies records from page to new_page, up to the given record, NOT Copies records from page to new_page, up to the given record, NOT
including that record. Infimum and supremum records are not copied. including that record. Infimum and supremum records are not copied.
...@@ -717,12 +716,11 @@ page_copy_rec_list_start( ...@@ -717,12 +716,11 @@ page_copy_rec_list_start(
on new_page, or NULL on zip overflow on new_page, or NULL on zip overflow
(new_page will be decompressed (new_page will be decompressed
from new_page_zip) */ from new_page_zip) */
page_t* new_page, /* in/out: index page to copy to */ buf_block_t* new_block, /* in/out: index page to copy to */
page_zip_des_t* new_page_zip, /* in/out: compressed page, or NULL */
rec_t* rec, /* in: record on page */ rec_t* rec, /* in: record on page */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
__attribute__((warn_unused_result, nonnull(1, 3, 4, 5))); __attribute__((warn_unused_result, nonnull));
/***************************************************************** /*****************************************************************
Deletes records from a page from a given record onward, including that record. Deletes records from a page from a given record onward, including that record.
The infimum and supremum records are not deleted. */ The infimum and supremum records are not deleted. */
...@@ -762,15 +760,13 @@ page_move_rec_list_end( ...@@ -762,15 +760,13 @@ page_move_rec_list_end(
/* out: TRUE on success; FALSE on /* out: TRUE on success; FALSE on
compression failure (new_page will compression failure (new_page will
be decompressed from new_page_zip) */ be decompressed from new_page_zip) */
page_t* new_page, /* in: index page where to move */ buf_block_t* new_block, /* in/out: index page where to move */
page_zip_des_t* new_page_zip, /* in/out: compressed page of
new_page, or NULL */
rec_t* split_rec, /* in: first record to move */ rec_t* split_rec, /* in: first record to move */
page_zip_des_t* page_zip, /* in/out: compressed page of page_zip_des_t* page_zip, /* in/out: compressed page of
split_rec, or NULL */ split_rec, or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
__attribute__((nonnull(1, 3, 5, 6))); __attribute__((nonnull(1, 2, 4, 5)));
/***************************************************************** /*****************************************************************
Moves record list start to another page. Moved records do not include Moves record list start to another page. Moved records do not include
split_rec. */ split_rec. */
...@@ -780,15 +776,13 @@ page_move_rec_list_start( ...@@ -780,15 +776,13 @@ page_move_rec_list_start(
/*=====================*/ /*=====================*/
/* out: TRUE on success; FALSE on /* out: TRUE on success; FALSE on
compression failure */ compression failure */
page_t* new_page, /* in: index page where to move */ buf_block_t* new_block, /* in/out: index page where to move */
page_zip_des_t* new_page_zip, /* in/out: compressed page of
new_page, or NULL */
rec_t* split_rec, /* in: first record not to move */ rec_t* split_rec, /* in: first record not to move */
page_zip_des_t* page_zip, /* in/out: compressed page of page_zip_des_t* page_zip, /* in/out: compressed page of
split_rec, or NULL */ split_rec, or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
__attribute__((nonnull(1, 3, 5, 6))); __attribute__((nonnull(1, 2, 4, 5)));
/******************************************************************** /********************************************************************
Splits a directory slot which owns too many records. */ Splits a directory slot which owns too many records. */
......
...@@ -16,6 +16,7 @@ Created June 2005 by Marko Makela ...@@ -16,6 +16,7 @@ Created June 2005 by Marko Makela
#include "mtr0types.h" #include "mtr0types.h"
#include "page0types.h" #include "page0types.h"
#include "buf0types.h"
#include "dict0types.h" #include "dict0types.h"
#include "ut0byte.h" #include "ut0byte.h"
...@@ -335,9 +336,9 @@ page_zip_reorganize( ...@@ -335,9 +336,9 @@ page_zip_reorganize(
/* out: TRUE on success, FALSE on failure; /* out: TRUE on success, FALSE on failure;
page and page_zip will be left intact page and page_zip will be left intact
on failure. */ on failure. */
page_zip_des_t* page_zip,/* in: size; out: data, n_blobs, buf_block_t* block, /* in/out: page with compressed page;
m_start, m_end */ on the compressed page, in: size;
page_t* page, /* in/out: uncompressed page */ out: data, n_blobs, m_start, m_end */
dict_index_t* index, /* in: index of the B-tree node */ dict_index_t* index, /* in: index of the B-tree node */
mtr_t* mtr) /* in: mini-transaction */ mtr_t* mtr) /* in: mini-transaction */
__attribute__((warn_unused_result, nonnull)); __attribute__((warn_unused_result, nonnull));
......
...@@ -4926,6 +4926,7 @@ lock_rec_insert_check_and_lock( ...@@ -4926,6 +4926,7 @@ lock_rec_insert_check_and_lock(
ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set, ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set,
does nothing */ does nothing */
rec_t* rec, /* in: record after which to insert */ rec_t* rec, /* in: record after which to insert */
buf_block_t* block, /* in: buffer block of rec */
dict_index_t* index, /* in: index */ dict_index_t* index, /* in: index */
que_thr_t* thr, /* in: query thread */ que_thr_t* thr, /* in: query thread */
ibool* inherit)/* out: set to TRUE if the new inserted ibool* inherit)/* out: set to TRUE if the new inserted
...@@ -4968,7 +4969,7 @@ lock_rec_insert_check_and_lock( ...@@ -4968,7 +4969,7 @@ lock_rec_insert_check_and_lock(
if (!dict_index_is_clust(index)) { if (!dict_index_is_clust(index)) {
/* Update the page max trx id field */ /* Update the page max trx id field */
page_update_max_trx_id(page_align(rec), page_update_max_trx_id(page_align(rec),
buf_frame_get_page_zip(rec), buf_block_get_page_zip(block),
thr_get_trx(thr)->id); thr_get_trx(thr)->id);
} }
...@@ -5006,7 +5007,7 @@ lock_rec_insert_check_and_lock( ...@@ -5006,7 +5007,7 @@ lock_rec_insert_check_and_lock(
if ((err == DB_SUCCESS) && !dict_index_is_clust(index)) { if ((err == DB_SUCCESS) && !dict_index_is_clust(index)) {
/* Update the page max trx id field */ /* Update the page max trx id field */
page_update_max_trx_id(page_align(rec), page_update_max_trx_id(page_align(rec),
buf_frame_get_page_zip(rec), buf_block_get_page_zip(block),
thr_get_trx(thr)->id); thr_get_trx(thr)->id);
} }
...@@ -5142,6 +5143,7 @@ lock_sec_rec_modify_check_and_lock( ...@@ -5142,6 +5143,7 @@ lock_sec_rec_modify_check_and_lock(
NOTE: as this is a secondary index, we NOTE: as this is a secondary index, we
always have to modify the clustered index always have to modify the clustered index
record first: see the comment below */ record first: see the comment below */
buf_block_t* block, /* in: buffer block of rec */
dict_index_t* index, /* in: secondary index */ dict_index_t* index, /* in: secondary index */
que_thr_t* thr) /* in: query thread */ que_thr_t* thr) /* in: query thread */
{ {
...@@ -5186,7 +5188,7 @@ lock_sec_rec_modify_check_and_lock( ...@@ -5186,7 +5188,7 @@ lock_sec_rec_modify_check_and_lock(
if (err == DB_SUCCESS) { if (err == DB_SUCCESS) {
/* Update the page max trx id field */ /* Update the page max trx id field */
page_update_max_trx_id(page_align(rec), page_update_max_trx_id(page_align(rec),
buf_frame_get_page_zip(rec), buf_block_get_page_zip(block),
thr_get_trx(thr)->id); thr_get_trx(thr)->id);
} }
......
...@@ -881,7 +881,7 @@ recv_parse_or_apply_log_rec_body( ...@@ -881,7 +881,7 @@ recv_parse_or_apply_log_rec_body(
|| (ibool)!!page_is_comp(page) || (ibool)!!page_is_comp(page)
== dict_table_is_comp(index->table)); == dict_table_is_comp(index->table));
ptr = btr_parse_page_reorganize(ptr, end_ptr, index, ptr = btr_parse_page_reorganize(ptr, end_ptr, index,
page, page_zip, mtr); block, mtr);
} }
break; break;
case MLOG_PAGE_CREATE: case MLOG_COMP_PAGE_CREATE: case MLOG_PAGE_CREATE: case MLOG_COMP_PAGE_CREATE:
......
...@@ -1130,11 +1130,14 @@ page_cur_insert_rec_low( ...@@ -1130,11 +1130,14 @@ page_cur_insert_rec_low(
(!page_zip_compress(page_zip_orig, page, index, mtr))) { (!page_zip_compress(page_zip_orig, page, index, mtr))) {
/* Before trying to reorganize the page, /* Before trying to reorganize the page,
store the number of preceding records on the page. */ store the number of preceding records on the page. */
ulint insert_pos ulint insert_pos
= page_rec_get_n_recs_before(insert_rec); = page_rec_get_n_recs_before(insert_rec);
buf_block_t* block
= buf_block_align(page);
if (page_zip_reorganize(page_zip_orig, page, ut_ad(buf_block_get_page_zip(block) == page_zip_orig);
index, mtr)) {
if (page_zip_reorganize(block, index, mtr)) {
/* The page was reorganized: /* The page was reorganized:
Seek to insert_pos to find insert_rec. */ Seek to insert_pos to find insert_rec. */
insert_rec = page + PAGE_NEW_INFIMUM; insert_rec = page + PAGE_NEW_INFIMUM;
......
...@@ -579,15 +579,17 @@ page_copy_rec_list_end( ...@@ -579,15 +579,17 @@ page_copy_rec_list_end(
on new_page, or NULL on zip overflow on new_page, or NULL on zip overflow
(new_page will be decompressed (new_page will be decompressed
from new_page_zip) */ from new_page_zip) */
page_t* new_page, /* in/out: index page to copy to */ buf_block_t* new_block, /* in/out: index page to copy to */
page_zip_des_t* new_page_zip, /* in/out: compressed page, or NULL */
rec_t* rec, /* in: record on page */ rec_t* rec, /* in: record on page */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
page_t* page = page_align(rec); page_t* new_page = buf_block_get_frame(new_block);
rec_t* ret = page_rec_get_next(page_get_infimum_rec(new_page)); page_zip_des_t* new_page_zip = buf_block_get_page_zip(new_block);
ulint log_mode= 0; /* remove warning */ page_t* page = page_align(rec);
rec_t* ret = page_rec_get_next(
page_get_infimum_rec(new_page));
ulint log_mode = 0; /* remove warning */
/* page_zip_validate() will fail here if btr_compress() /* page_zip_validate() will fail here if btr_compress()
sets FIL_PAGE_PREV to FIL_NULL */ sets FIL_PAGE_PREV to FIL_NULL */
...@@ -616,8 +618,7 @@ page_copy_rec_list_end( ...@@ -616,8 +618,7 @@ page_copy_rec_list_end(
= page_rec_get_n_recs_before(ret); = page_rec_get_n_recs_before(ret);
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!page_zip_reorganize(new_page_zip, new_page, (!page_zip_reorganize(new_block, index, mtr))) {
index, mtr))) {
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!page_zip_decompress(new_page_zip, (!page_zip_decompress(new_page_zip,
...@@ -663,12 +664,13 @@ page_copy_rec_list_start( ...@@ -663,12 +664,13 @@ page_copy_rec_list_start(
on new_page, or NULL on zip overflow on new_page, or NULL on zip overflow
(new_page will be decompressed (new_page will be decompressed
from new_page_zip) */ from new_page_zip) */
page_t* new_page, /* in/out: index page to copy to */ buf_block_t* new_block, /* in/out: index page to copy to */
page_zip_des_t* new_page_zip, /* in/out: compressed page, or NULL */
rec_t* rec, /* in: record on page */ rec_t* rec, /* in: record on page */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
page_t* new_page = buf_block_get_frame(new_block);
page_zip_des_t* new_page_zip = buf_block_get_page_zip(new_block);
page_cur_t cur1; page_cur_t cur1;
page_cur_t cur2; page_cur_t cur2;
page_t* page; page_t* page;
...@@ -726,8 +728,7 @@ page_copy_rec_list_start( ...@@ -726,8 +728,7 @@ page_copy_rec_list_start(
= page_rec_get_n_recs_before(ret); = page_rec_get_n_recs_before(ret);
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!page_zip_reorganize(new_page_zip, new_page, (!page_zip_reorganize(new_block, index, mtr))) {
index, mtr))) {
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!page_zip_decompress(new_page_zip, (!page_zip_decompress(new_page_zip,
...@@ -1090,19 +1091,21 @@ page_move_rec_list_end( ...@@ -1090,19 +1091,21 @@ page_move_rec_list_end(
/* out: TRUE on success; FALSE on /* out: TRUE on success; FALSE on
compression failure (new_page will compression failure (new_page will
be decompressed from new_page_zip) */ be decompressed from new_page_zip) */
page_t* new_page, /* in: index page where to move */ buf_block_t* new_block, /* in/out: index page where to move */
page_zip_des_t* new_page_zip, /* in/out: compressed page of
new_page, or NULL */
rec_t* split_rec, /* in: first record to move */ rec_t* split_rec, /* in: first record to move */
page_zip_des_t* page_zip, /* in/out: compressed page of page_zip_des_t* page_zip, /* in/out: compressed page of
split_rec, or NULL */ split_rec, or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
ulint old_data_size; page_t* new_page = buf_block_get_frame(new_block);
ulint new_data_size; #ifdef UNIV_ZIP_DEBUG
ulint old_n_recs; page_zip_des_t* new_page_zip = buf_block_get_page_zip(new_block);
ulint new_n_recs; #endif /* UNIV_ZIP_DEBUG */
ulint old_data_size;
ulint new_data_size;
ulint old_n_recs;
ulint new_n_recs;
old_data_size = page_get_data_size(new_page); old_data_size = page_get_data_size(new_page);
old_n_recs = page_get_n_recs(new_page); old_n_recs = page_get_n_recs(new_page);
...@@ -1111,8 +1114,8 @@ page_move_rec_list_end( ...@@ -1111,8 +1114,8 @@ page_move_rec_list_end(
ut_a(!page_zip || page_zip_validate(page_zip, page_align(split_rec))); ut_a(!page_zip || page_zip_validate(page_zip, page_align(split_rec)));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
if (UNIV_UNLIKELY(!page_copy_rec_list_end(new_page, new_page_zip, if (UNIV_UNLIKELY(!page_copy_rec_list_end(new_block, split_rec,
split_rec, index, mtr))) { index, mtr))) {
return(FALSE); return(FALSE);
} }
...@@ -1138,17 +1141,15 @@ page_move_rec_list_start( ...@@ -1138,17 +1141,15 @@ page_move_rec_list_start(
/*=====================*/ /*=====================*/
/* out: TRUE on success; FALSE on /* out: TRUE on success; FALSE on
compression failure */ compression failure */
page_t* new_page, /* in: index page where to move */ buf_block_t* new_block, /* in/out: index page where to move */
page_zip_des_t* new_page_zip, /* in/out: compressed page of
new_page, or NULL */
rec_t* split_rec, /* in: first record not to move */ rec_t* split_rec, /* in: first record not to move */
page_zip_des_t* page_zip, /* in/out: compressed page of page_zip_des_t* page_zip, /* in/out: compressed page of
split_rec, or NULL */ split_rec, or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
if (UNIV_UNLIKELY(!page_copy_rec_list_start(new_page, new_page_zip, if (UNIV_UNLIKELY(!page_copy_rec_list_start(new_block, split_rec,
split_rec, index, mtr))) { index, mtr))) {
return(FALSE); return(FALSE);
} }
......
...@@ -3504,13 +3504,14 @@ page_zip_reorganize( ...@@ -3504,13 +3504,14 @@ page_zip_reorganize(
/* out: TRUE on success, FALSE on failure; /* out: TRUE on success, FALSE on failure;
page and page_zip will be left intact page and page_zip will be left intact
on failure. */ on failure. */
page_zip_des_t* page_zip,/* in: size; out: data, n_blobs, buf_block_t* block, /* in/out: page with compressed page;
m_start, m_end */ on the compressed page, in: size;
page_t* page, /* in/out: uncompressed page */ out: data, n_blobs, m_start, m_end */
dict_index_t* index, /* in: index of the B-tree node */ dict_index_t* index, /* in: index of the B-tree node */
mtr_t* mtr) /* in: mini-transaction */ mtr_t* mtr) /* in: mini-transaction */
{ {
buf_block_t* block; page_zip_des_t* page_zip = buf_block_get_page_zip(block);
page_t* page = buf_block_get_frame(block);
buf_block_t* temp_block; buf_block_t* temp_block;
page_t* temp_page; page_t* temp_page;
ulint log_mode; ulint log_mode;
...@@ -3531,7 +3532,6 @@ page_zip_reorganize( ...@@ -3531,7 +3532,6 @@ page_zip_reorganize(
/* Recreate the page: note that global data on page (possible /* Recreate the page: note that global data on page (possible
segment headers, next page-field, etc.) is preserved intact */ segment headers, next page-field, etc.) is preserved intact */
block = buf_block_align(page);
page_create(block, mtr, dict_table_is_comp(index->table)); page_create(block, mtr, dict_table_is_comp(index->table));
block->check_index_page_at_flush = TRUE; block->check_index_page_at_flush = TRUE;
......
...@@ -2084,7 +2084,8 @@ row_ins_index_entry_low( ...@@ -2084,7 +2084,8 @@ row_ins_index_entry_low(
if (modify == ROW_INS_NEXT) { if (modify == ROW_INS_NEXT) {
rec = page_rec_get_next(btr_cur_get_rec(&cursor)); rec = page_rec_get_next(btr_cur_get_rec(&cursor));
btr_cur_position(index, rec, &cursor); btr_cur_position(index, rec,
btr_cur_get_block(&cursor),&cursor);
} }
if (dict_index_is_clust(index)) { if (dict_index_is_clust(index)) {
......
...@@ -3793,7 +3793,9 @@ row_search_for_mysql( ...@@ -3793,7 +3793,9 @@ row_search_for_mysql(
" buf block fix count %lu\n", " buf block fix count %lu\n",
(void*) rec, (void*) buf_pool->frame_zero, (void*) rec, (void*) buf_pool->frame_zero,
(void*) buf_pool->high_end, (void*) buf_pool->high_end,
(ulong)buf_block_align(rec)->buf_fix_count); (ulong)
btr_cur_get_block(btr_pcur_get_btr_cur(pcur))
->buf_fix_count);
fprintf(stderr, fprintf(stderr,
"InnoDB: Index corruption: rec offs %lu" "InnoDB: Index corruption: rec offs %lu"
" next offs %lu, page no %lu,\n" " next offs %lu, page no %lu,\n"
......
...@@ -1470,7 +1470,7 @@ row_upd_clust_rec_by_insert( ...@@ -1470,7 +1470,7 @@ row_upd_clust_rec_by_insert(
index = dict_table_get_first_index(table); index = dict_table_get_first_index(table);
btr_cur_mark_extern_inherited_fields( btr_cur_mark_extern_inherited_fields(
buf_frame_get_page_zip(rec), btr_cur_get_page_zip(btr_cur),
rec, index, rec, index,
rec_get_offsets(rec, index, offsets_, rec_get_offsets(rec, index, offsets_,
ULINT_UNDEFINED, &heap), ULINT_UNDEFINED, &heap),
......
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