Commit b6e26f24 authored by marko's avatar marko

branches/zip: Remove some more buf_block_align() calls.

btr_cur_t: Move page_block to page_cur_t::block.

page_cur_get_block(), page_cur_get_page_zip(): New functions.

page_cur_position(): Add parameter block.

Remove many page_zip parameters, now that there is page_cur_get_page_zip().
Replace some page, page_zip parameters with block.

Add some const qualifiers to function parameters and remove casts.

PAGE_HEAP_NO_INFIMUM, PAGE_HEAP_NO_SUPREMUM, PAGE_HEAP_NO_USER_LOW:
New constants.

Replace some cursor code in low-level diagnostic functions with
direct management of rec, because buf_block_t::buf_fix_count may be 0
when the functions are called, and debug assertions would fail.
parent bb9b1b0c
...@@ -516,7 +516,7 @@ buf_block_t* ...@@ -516,7 +516,7 @@ buf_block_t*
btr_node_ptr_get_child( btr_node_ptr_get_child(
/*===================*/ /*===================*/
/* out: child page, x-latched */ /* out: child page, x-latched */
rec_t* node_ptr,/* in: node pointer */ const rec_t* node_ptr,/* in: node pointer */
const ulint* offsets,/* in: array returned by rec_get_offsets() */ const ulint* offsets,/* in: array returned by rec_get_offsets() */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
...@@ -524,7 +524,7 @@ btr_node_ptr_get_child( ...@@ -524,7 +524,7 @@ btr_node_ptr_get_child(
ulint space; ulint space;
ut_ad(rec_offs_validate(node_ptr, NULL, offsets)); ut_ad(rec_offs_validate(node_ptr, NULL, offsets));
space = page_get_space_id(page_align(node_ptr)); space = page_get_space_id(page_align((rec_t*) 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_block_get(space, page_no, RW_X_LATCH, mtr)); return(btr_block_get(space, page_no, RW_X_LATCH, mtr));
...@@ -911,7 +911,7 @@ btr_page_reorganize_low( ...@@ -911,7 +911,7 @@ btr_page_reorganize_low(
/* Copy the records from the temporary space to the recreated page; /* Copy the records from the temporary space to the recreated page;
do not copy the lock bits yet */ do not copy the lock bits yet */
page_copy_rec_list_end_no_locks(page, page_copy_rec_list_end_no_locks(block, temp_block,
page_get_infimum_rec(temp_page), page_get_infimum_rec(temp_page),
index, mtr); index, mtr);
/* Copy max trx id to recreated page */ /* Copy max trx id to recreated page */
...@@ -1107,7 +1107,7 @@ btr_root_raise_and_insert( ...@@ -1107,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_block, (!page_copy_rec_list_end(new_block, root_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);
...@@ -1164,11 +1164,10 @@ btr_root_raise_and_insert( ...@@ -1164,11 +1164,10 @@ 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_block, 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, node_ptr,
node_ptr, index, NULL, 0, mtr); index, NULL, 0, mtr);
/* The root page should only contain the node pointer /* The root page should only contain the node pointer
to new_page at this point. Thus, the data should fit. */ to new_page at this point. Thus, the data should fit. */
...@@ -1186,8 +1185,7 @@ btr_root_raise_and_insert( ...@@ -1186,8 +1185,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_block, index, tuple,
page_cur_search(new_page, index, tuple,
PAGE_CUR_LE, page_cursor); PAGE_CUR_LE, page_cursor);
/* Split the child and insert tuple */ /* Split the child and insert tuple */
...@@ -1716,7 +1714,6 @@ btr_page_split_and_insert( ...@@ -1716,7 +1714,6 @@ btr_page_split_and_insert(
buf_block_t* right_block; buf_block_t* right_block;
buf_block_t* insert_block; buf_block_t* insert_block;
page_t* insert_page; page_t* insert_page;
page_zip_des_t* insert_page_zip;
page_cur_t* page_cursor; page_cur_t* page_cursor;
rec_t* first_rec; rec_t* first_rec;
byte* buf = 0; /* remove warning */ byte* buf = 0; /* remove warning */
...@@ -1833,7 +1830,7 @@ func_start: ...@@ -1833,7 +1830,7 @@ func_start:
/* fputs("Split left\n", stderr); */ /* fputs("Split left\n", stderr); */
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!page_move_rec_list_start(new_block, move_limit, page_zip, (!page_move_rec_list_start(new_block, block, move_limit,
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
...@@ -1844,13 +1841,12 @@ func_start: ...@@ -1844,13 +1841,12 @@ func_start:
page_zip_copy(new_page_zip, new_page, page_zip_copy(new_page_zip, new_page,
page_zip, page, cursor->index, mtr); page_zip, page, cursor->index, mtr);
page_delete_rec_list_end(move_limit - page page_delete_rec_list_end(move_limit - page + new_page,
+ new_page, cursor->index, new_block, cursor->index,
ULINT_UNDEFINED, ULINT_UNDEFINED,
ULINT_UNDEFINED, ULINT_UNDEFINED, mtr);
new_page_zip, mtr); page_delete_rec_list_start(move_limit, block,
page_delete_rec_list_start(move_limit, cursor->index, cursor->index, mtr);
page_zip, mtr);
} }
left_block = new_block; left_block = new_block;
...@@ -1861,7 +1857,7 @@ func_start: ...@@ -1861,7 +1857,7 @@ func_start:
/* fputs("Split right\n", stderr); */ /* fputs("Split right\n", stderr); */
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!page_move_rec_list_end(new_block, move_limit, page_zip, (!page_move_rec_list_end(new_block, block, move_limit,
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
...@@ -1873,12 +1869,12 @@ func_start: ...@@ -1873,12 +1869,12 @@ func_start:
page_zip_copy(new_page_zip, new_page, page_zip_copy(new_page_zip, new_page,
page_zip, page, cursor->index, mtr); page_zip, page, cursor->index, mtr);
page_delete_rec_list_start(move_limit - page page_delete_rec_list_start(move_limit - page
+ new_page, cursor->index, + new_page, new_block,
new_page_zip, mtr); cursor->index, mtr);
page_delete_rec_list_end(move_limit, cursor->index, page_delete_rec_list_end(move_limit, block,
ULINT_UNDEFINED, cursor->index,
ULINT_UNDEFINED, ULINT_UNDEFINED,
page_zip, mtr); ULINT_UNDEFINED, mtr);
} }
left_block = block; left_block = block;
...@@ -1907,21 +1903,23 @@ func_start: ...@@ -1907,21 +1903,23 @@ func_start:
} }
insert_page = buf_block_get_frame(insert_block); insert_page = buf_block_get_frame(insert_block);
insert_page_zip = buf_block_get_page_zip(insert_block);
/* 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_block, 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, tuple,
tuple, cursor->index, ext, n_ext, mtr); cursor->index, ext, n_ext, mtr);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!insert_page_zip {
|| page_zip_validate(insert_page_zip, insert_page)); page_zip_des_t* insert_page_zip
= buf_block_get_page_zip(insert_block);
ut_a(!insert_page_zip
|| page_zip_validate(insert_page_zip, insert_page));
}
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
if (UNIV_LIKELY(rec != NULL)) { if (UNIV_LIKELY(rec != NULL)) {
...@@ -1946,11 +1944,10 @@ func_start: ...@@ -1946,11 +1944,10 @@ func_start:
goto insert_failed; goto insert_failed;
} }
ut_ad(cursor->page_block == insert_block); page_cur_search(insert_block, 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, tuple, cursor->index,
tuple, cursor->index, ext, n_ext, mtr); ext, n_ext, mtr);
if (UNIV_UNLIKELY(rec == NULL)) { if (UNIV_UNLIKELY(rec == NULL)) {
/* The insert did not fit on the page: loop back to the /* The insert did not fit on the page: loop back to the
...@@ -1962,8 +1959,10 @@ insert_failed: ...@@ -1962,8 +1959,10 @@ insert_failed:
/* fprintf(stderr, "Split second round %lu\n", /* fprintf(stderr, "Split second round %lu\n",
page_get_page_no(page)); */ page_get_page_no(page)); */
n_iterations++; n_iterations++;
ut_ad(n_iterations < 2 || insert_page_zip); ut_ad(n_iterations < 2
ut_ad(!insert_will_fit || insert_page_zip); || buf_block_get_page_zip(insert_block));
ut_ad(!insert_will_fit
|| buf_block_get_page_zip(insert_block));
goto func_start; goto func_start;
} }
...@@ -1980,7 +1979,7 @@ insert_failed: ...@@ -1980,7 +1979,7 @@ insert_failed:
#endif #endif
ut_ad(page_validate(buf_block_get_frame(left_block), cursor->index)); ut_ad(page_validate(buf_block_get_frame(left_block), cursor->index));
ut_ad(page_validate(buf_block_get_frame(left_block), cursor->index)); ut_ad(page_validate(buf_block_get_frame(right_block), cursor->index));
mem_heap_free(heap); mem_heap_free(heap);
return(rec); return(rec);
...@@ -2188,7 +2187,7 @@ btr_lift_page_up( ...@@ -2188,7 +2187,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_block, (!page_copy_rec_list_end(father_block, 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);
...@@ -2250,7 +2249,7 @@ btr_compress( ...@@ -2250,7 +2249,7 @@ btr_compress(
ulint level; ulint level;
block = btr_cur_get_block(cursor); block = btr_cur_get_block(cursor);
page = buf_block_get_frame(block); page = btr_cur_get_page(cursor);
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));
...@@ -2356,7 +2355,8 @@ err_exit: ...@@ -2356,7 +2355,8 @@ err_exit:
/* 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_block, page_get_supremum_rec(page), index, mtr); merge_block, block, page_get_supremum_rec(page),
index, mtr);
if (UNIV_UNLIKELY(!orig_pred)) { if (UNIV_UNLIKELY(!orig_pred)) {
goto err_exit; goto err_exit;
...@@ -2389,7 +2389,7 @@ err_exit: ...@@ -2389,7 +2389,7 @@ err_exit:
memset(merge_page + FIL_PAGE_PREV, 0xff, 4); memset(merge_page + FIL_PAGE_PREV, 0xff, 4);
} }
orig_succ = page_copy_rec_list_end(merge_block, orig_succ = page_copy_rec_list_end(merge_block, block,
page_get_infimum_rec(page), page_get_infimum_rec(page),
cursor->index, mtr); cursor->index, mtr);
...@@ -2643,30 +2643,29 @@ void ...@@ -2643,30 +2643,29 @@ void
btr_print_recursive( btr_print_recursive(
/*================*/ /*================*/
dict_index_t* index, /* in: index tree */ dict_index_t* index, /* in: index tree */
page_t* page, /* in: index page */ buf_block_t* block, /* in: index page */
ulint width, /* in: print this many entries from start ulint width, /* in: print this many entries from start
and end */ and end */
mem_heap_t** heap, /* in/out: heap for rec_get_offsets() */ mem_heap_t** heap, /* in/out: heap for rec_get_offsets() */
ulint** offsets,/* in/out: buffer for rec_get_offsets() */ ulint** offsets,/* in/out: buffer for rec_get_offsets() */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
const page_t* page = buf_block_get_frame(block);
page_cur_t cursor; page_cur_t cursor;
ulint n_recs; ulint n_recs;
ulint i = 0; ulint i = 0;
mtr_t mtr2; mtr_t mtr2;
rec_t* node_ptr;
page_t* child;
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));
fprintf(stderr, "NODE ON LEVEL %lu page number %lu\n", fprintf(stderr, "NODE ON LEVEL %lu page number %lu\n",
(ulong) btr_page_get_level(page, mtr), (ulong) btr_page_get_level(page, mtr),
(ulong) page_get_page_no(page)); (ulong) page_get_page_no(page));
page_print(page, index, width, width); page_print(block, index, width, width);
n_recs = page_get_n_recs(page); n_recs = page_get_n_recs(page);
page_cur_set_before_first(page, &cursor); page_cur_set_before_first(block, &cursor);
page_cur_move_to_next(&cursor); page_cur_move_to_next(&cursor);
while (!page_cur_is_after_last(&cursor)) { while (!page_cur_is_after_last(&cursor)) {
...@@ -2677,17 +2676,19 @@ btr_print_recursive( ...@@ -2677,17 +2676,19 @@ btr_print_recursive(
} else if ((i <= width) || (i >= n_recs - width)) { } else if ((i <= width) || (i >= n_recs - width)) {
const rec_t* node_ptr;
mtr_start(&mtr2); mtr_start(&mtr2);
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);
child = buf_block_get_frame( btr_print_recursive(index,
btr_node_ptr_get_child(node_ptr, btr_node_ptr_get_child(node_ptr,
*offsets, &mtr2)); *offsets,
btr_print_recursive(index, child, width, &mtr2),
heap, offsets, &mtr2); width, heap, offsets, &mtr2);
mtr_commit(&mtr2); mtr_commit(&mtr2);
} }
...@@ -2707,7 +2708,7 @@ btr_print_index( ...@@ -2707,7 +2708,7 @@ btr_print_index(
and end */ and end */
{ {
mtr_t mtr; mtr_t mtr;
page_t* root; buf_block_t* root;
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint offsets_[REC_OFFS_NORMAL_SIZE];
ulint* offsets = offsets_; ulint* offsets = offsets_;
...@@ -2718,7 +2719,7 @@ btr_print_index( ...@@ -2718,7 +2719,7 @@ btr_print_index(
mtr_start(&mtr); mtr_start(&mtr);
root = btr_root_get(index, &mtr); root = btr_root_block_get(index, &mtr);
btr_print_recursive(index, root, width, &heap, &offsets, &mtr); btr_print_recursive(index, root, width, &heap, &offsets, &mtr);
if (UNIV_LIKELY_NULL(heap)) { if (UNIV_LIKELY_NULL(heap)) {
...@@ -2906,13 +2907,13 @@ ibool ...@@ -2906,13 +2907,13 @@ ibool
btr_index_page_validate( btr_index_page_validate(
/*====================*/ /*====================*/
/* out: TRUE if ok */ /* out: TRUE if ok */
page_t* page, /* in: index page */ buf_block_t* block, /* in: index page */
dict_index_t* index) /* in: index */ dict_index_t* index) /* in: index */
{ {
page_cur_t cur; page_cur_t cur;
ibool ret = TRUE; ibool ret = TRUE;
page_cur_set_before_first(page, &cur); page_cur_set_before_first(block, &cur);
page_cur_move_to_next(&cur); page_cur_move_to_next(&cur);
for (;;) { for (;;) {
...@@ -2938,13 +2939,13 @@ static ...@@ -2938,13 +2939,13 @@ static
void void
btr_validate_report1( btr_validate_report1(
/*=================*/ /*=================*/
/* out: TRUE if ok */ /* out: TRUE if ok */
dict_index_t* index, /* in: index */ dict_index_t* index, /* in: index */
ulint level, /* in: B-tree level */ ulint level, /* in: B-tree level */
page_t* page) /* in: index page */ const buf_block_t* block) /* in: index page */
{ {
fprintf(stderr, "InnoDB: Error in page %lu of ", fprintf(stderr, "InnoDB: Error in page %lu of ",
page_get_page_no(page)); buf_block_get_page_no(block));
dict_index_name_print(stderr, NULL, index); dict_index_name_print(stderr, NULL, index);
if (level) { if (level) {
fprintf(stderr, ", index tree level %lu", level); fprintf(stderr, ", index tree level %lu", level);
...@@ -2958,15 +2959,15 @@ static ...@@ -2958,15 +2959,15 @@ static
void void
btr_validate_report2( btr_validate_report2(
/*=================*/ /*=================*/
/* out: TRUE if ok */ /* out: TRUE if ok */
dict_index_t* index, /* in: index */ const dict_index_t* index, /* in: index */
ulint level, /* in: B-tree level */ ulint level, /* in: B-tree level */
page_t* page1, /* in: first index page */ const buf_block_t* block1, /* in: first index page */
page_t* page2) /* in: second index page */ const buf_block_t* block2) /* in: second index page */
{ {
fprintf(stderr, "InnoDB: Error in pages %lu and %lu of ", fprintf(stderr, "InnoDB: Error in pages %lu and %lu of ",
page_get_page_no(page1), buf_block_get_page_no(block1),
page_get_page_no(page2)); buf_block_get_page_no(block2));
dict_index_name_print(stderr, NULL, index); dict_index_name_print(stderr, NULL, index);
if (level) { if (level) {
fprintf(stderr, ", index tree level %lu", level); fprintf(stderr, ", index tree level %lu", level);
...@@ -3017,7 +3018,7 @@ btr_validate_level( ...@@ -3017,7 +3018,7 @@ btr_validate_level(
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; const rec_t* node_ptr;
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
page_zip = buf_block_get_page_zip(block); page_zip = buf_block_get_page_zip(block);
...@@ -3025,7 +3026,7 @@ btr_validate_level( ...@@ -3025,7 +3026,7 @@ btr_validate_level(
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
ut_a(!page_is_leaf(page)); ut_a(!page_is_leaf(page));
page_cur_set_before_first(page, &cursor); page_cur_set_before_first(block, &cursor);
page_cur_move_to_next(&cursor); page_cur_move_to_next(&cursor);
node_ptr = page_cur_get_rec(&cursor); node_ptr = page_cur_get_rec(&cursor);
...@@ -3055,14 +3056,14 @@ loop: ...@@ -3055,14 +3056,14 @@ loop:
/* Check ordering etc. of records */ /* Check ordering etc. of records */
if (!page_validate(page, index)) { if (!page_validate(page, index)) {
btr_validate_report1(index, level, page); btr_validate_report1(index, level, block);
ret = FALSE; ret = FALSE;
} else if (level == 0) { } else if (level == 0) {
/* We are on level 0. Check that the records have the right /* We are on level 0. Check that the records have the right
number of fields, and field lengths are right. */ number of fields, and field lengths are right. */
if (!btr_index_page_validate(page, index)) { if (!btr_index_page_validate(block, index)) {
ret = FALSE; ret = FALSE;
} }
...@@ -3078,13 +3079,13 @@ loop: ...@@ -3078,13 +3079,13 @@ loop:
== dict_index_get_page(index))); == dict_index_get_page(index)));
if (right_page_no != FIL_NULL) { if (right_page_no != FIL_NULL) {
rec_t* right_rec; const rec_t* right_rec;
right_block = btr_block_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); 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, block, right_block);
fputs("InnoDB: broken FIL_PAGE_NEXT" fputs("InnoDB: broken FIL_PAGE_NEXT"
" or FIL_PAGE_PREV links\n", stderr); " or FIL_PAGE_PREV links\n", stderr);
buf_page_print(page, 0); buf_page_print(page, 0);
...@@ -3095,7 +3096,7 @@ loop: ...@@ -3095,7 +3096,7 @@ loop:
if (UNIV_UNLIKELY(page_is_comp(right_page) if (UNIV_UNLIKELY(page_is_comp(right_page)
!= page_is_comp(page))) { != page_is_comp(page))) {
btr_validate_report2(index, level, page, right_page); btr_validate_report2(index, level, block, right_block);
fputs("InnoDB: 'compact' flag mismatch\n", stderr); fputs("InnoDB: 'compact' flag mismatch\n", stderr);
buf_page_print(page, 0); buf_page_print(page, 0);
buf_page_print(right_page, 0); buf_page_print(right_page, 0);
...@@ -3116,7 +3117,7 @@ loop: ...@@ -3116,7 +3117,7 @@ loop:
offsets, offsets2, offsets, offsets2,
index) >= 0)) { index) >= 0)) {
btr_validate_report2(index, level, page, right_page); btr_validate_report2(index, level, block, right_block);
fputs("InnoDB: records in wrong order" fputs("InnoDB: records in wrong order"
" on adjacent pages\n", stderr); " on adjacent pages\n", stderr);
...@@ -3166,7 +3167,7 @@ loop: ...@@ -3166,7 +3167,7 @@ loop:
offsets) offsets)
!= buf_block_get_page_no(block))) { != buf_block_get_page_no(block))) {
btr_validate_report1(index, level, page); btr_validate_report1(index, level, block);
fputs("InnoDB: node pointer to the page is wrong\n", fputs("InnoDB: node pointer to the page is wrong\n",
stderr); stderr);
...@@ -3199,10 +3200,10 @@ loop: ...@@ -3199,10 +3200,10 @@ loop:
if (cmp_dtuple_rec(node_ptr_tuple, node_ptr, if (cmp_dtuple_rec(node_ptr_tuple, node_ptr,
offsets)) { offsets)) {
rec_t* first_rec = page_rec_get_next( const rec_t* first_rec = page_rec_get_next(
page_get_infimum_rec(page)); page_get_infimum_rec(page));
btr_validate_report1(index, level, page); btr_validate_report1(index, level, block);
buf_page_print(father_page, 0); buf_page_print(father_page, 0);
buf_page_print(page, 0); buf_page_print(page, 0);
...@@ -3245,7 +3246,7 @@ loop: ...@@ -3245,7 +3246,7 @@ loop:
stderr); stderr);
btr_validate_report1(index, level, btr_validate_report1(index, level,
page); block);
buf_page_print(father_page, 0); buf_page_print(father_page, 0);
buf_page_print(page, 0); buf_page_print(page, 0);
...@@ -3265,7 +3266,7 @@ loop: ...@@ -3265,7 +3266,7 @@ loop:
stderr); stderr);
btr_validate_report1(index, level, btr_validate_report1(index, level,
page); block);
buf_page_print(father_page, 0); buf_page_print(father_page, 0);
buf_page_print(right_father_page, 0); buf_page_print(right_father_page, 0);
...@@ -3282,7 +3283,7 @@ loop: ...@@ -3282,7 +3283,7 @@ loop:
stderr); stderr);
btr_validate_report1(index, level, btr_validate_report1(index, level,
page); block);
buf_page_print(father_page, 0); buf_page_print(father_page, 0);
buf_page_print(right_father_page, 0); buf_page_print(right_father_page, 0);
......
...@@ -539,8 +539,7 @@ retry_page_get: ...@@ -539,8 +539,7 @@ retry_page_get:
page_mode = mode; page_mode = mode;
} }
cursor->page_block = block; page_cur_search_with_match(block, 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);
...@@ -685,7 +684,6 @@ btr_cur_open_at_index_side( ...@@ -685,7 +684,6 @@ 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 */
...@@ -715,11 +713,10 @@ btr_cur_open_at_index_side( ...@@ -715,11 +713,10 @@ btr_cur_open_at_index_side(
} }
} }
ut_ad(buf_block_get_frame(cursor->page_block) == page);
if (from_left) { if (from_left) {
page_cur_set_before_first(page, page_cursor); page_cur_set_before_first(block, page_cursor);
} else { } else {
page_cur_set_after_last(page, page_cursor); page_cur_set_after_last(block, page_cursor);
} }
if (height == 0) { if (height == 0) {
...@@ -815,8 +812,7 @@ btr_cur_open_at_rnd_pos( ...@@ -815,8 +812,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(block, page_cursor);
page_cur_open_on_rnd_user_rec(page, page_cursor);
if (height == 0) { if (height == 0) {
...@@ -854,7 +850,6 @@ btr_cur_insert_if_possible( ...@@ -854,7 +850,6 @@ btr_cur_insert_if_possible(
else NULL */ else NULL */
btr_cur_t* cursor, /* in: cursor on page after which to insert; btr_cur_t* cursor, /* in: cursor on page after which to insert;
cursor stays valid */ cursor stays valid */
page_zip_des_t* page_zip,/* in: compressed page of cursor */
const dtuple_t* tuple, /* in: tuple to insert; the size info need not const dtuple_t* tuple, /* in: tuple to insert; the size info need not
have been stored to tuple */ have been stored to tuple */
const ulint* ext, /* in: array of extern field numbers */ const ulint* ext, /* in: array of extern field numbers */
...@@ -873,20 +868,19 @@ btr_cur_insert_if_possible( ...@@ -873,20 +868,19 @@ btr_cur_insert_if_possible(
page_cursor = btr_cur_get_page_cur(cursor); page_cursor = btr_cur_get_page_cur(cursor);
/* Now, try the insert */ /* Now, try the insert */
rec = page_cur_tuple_insert(page_cursor, page_zip, rec = page_cur_tuple_insert(page_cursor, tuple,
tuple, cursor->index, ext, n_ext, mtr); cursor->index, ext, n_ext, mtr);
if (UNIV_UNLIKELY(!rec)) { if (UNIV_UNLIKELY(!rec)) {
/* If record did not fit, reorganize */ /* If record did not fit, reorganize */
if (btr_page_reorganize(block, cursor->index, mtr)) { if (btr_page_reorganize(block, cursor->index, mtr)) {
page_cur_search(buf_block_get_frame(block), page_cur_search(block, cursor->index, tuple,
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, tuple,
tuple, cursor->index, cursor->index,
ext, n_ext, mtr); ext, n_ext, mtr);
} }
} }
...@@ -1146,8 +1140,8 @@ fail: ...@@ -1146,8 +1140,8 @@ fail:
/* Now, try the insert */ /* Now, try the insert */
*rec = page_cur_tuple_insert(page_cursor, page_zip, *rec = page_cur_tuple_insert(page_cursor, entry, index,
entry, index, ext, n_ext, mtr); 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(block, index, mtr))) { if (UNIV_UNLIKELY(!btr_page_reorganize(block, index, mtr))) {
...@@ -1160,10 +1154,10 @@ fail: ...@@ -1160,10 +1154,10 @@ fail:
reorg = TRUE; reorg = TRUE;
page_cur_search(page, index, entry, PAGE_CUR_LE, page_cursor); page_cur_search(block, index, entry, PAGE_CUR_LE, page_cursor);
*rec = page_cur_tuple_insert(page_cursor, page_zip, *rec = page_cur_tuple_insert(page_cursor, entry, index,
entry, index, ext, n_ext, mtr); ext, n_ext, mtr);
if (UNIV_UNLIKELY(!*rec)) { if (UNIV_UNLIKELY(!*rec)) {
if (UNIV_LIKELY(page_zip != NULL)) { if (UNIV_LIKELY(page_zip != NULL)) {
...@@ -1353,11 +1347,11 @@ btr_cur_pessimistic_insert( ...@@ -1353,11 +1347,11 @@ btr_cur_pessimistic_insert(
rec_t* temp_rec; rec_t* temp_rec;
page_cur_position(temp_page + PAGE_NEW_INFIMUM, page_cur_position(temp_page + PAGE_NEW_INFIMUM,
&temp_cursor); temp_block, &temp_cursor);
temp_rec = page_cur_tuple_insert( temp_rec = page_cur_tuple_insert(&temp_cursor,
&temp_cursor, &temp_block->page_zip, entry, index,
entry, index, ext, n_ext, NULL); ext, n_ext, NULL);
buf_block_free(temp_block); buf_block_free(temp_block);
if (UNIV_UNLIKELY(!temp_rec)) { if (UNIV_UNLIKELY(!temp_rec)) {
...@@ -1883,7 +1877,7 @@ btr_cur_optimistic_update( ...@@ -1883,7 +1877,7 @@ btr_cur_optimistic_update(
btr_search_update_hash_on_delete(cursor); btr_search_update_hash_on_delete(cursor);
page_cur_delete_rec(page_cursor, index, offsets, page_zip, mtr); page_cur_delete_rec(page_cursor, index, offsets, mtr);
page_cur_move_to_prev(page_cursor); page_cur_move_to_prev(page_cursor);
...@@ -1897,8 +1891,7 @@ btr_cur_optimistic_update( ...@@ -1897,8 +1891,7 @@ btr_cur_optimistic_update(
} }
/* There are no externally stored columns in new_entry */ /* There are no externally stored columns in new_entry */
rec = btr_cur_insert_if_possible(cursor, page_zip, new_entry, rec = btr_cur_insert_if_possible(cursor, new_entry, NULL, 0, mtr);
NULL, 0, mtr);
ut_a(rec); /* <- We calculated above the insert would fit */ ut_a(rec); /* <- We calculated above the insert would fit */
if (!rec_get_deleted_flag(rec, page_is_comp(page))) { if (!rec_get_deleted_flag(rec, page_is_comp(page))) {
...@@ -2143,11 +2136,11 @@ btr_cur_pessimistic_update( ...@@ -2143,11 +2136,11 @@ btr_cur_pessimistic_update(
#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 */
page_cur_delete_rec(page_cursor, index, offsets, page_zip, mtr); page_cur_delete_rec(page_cursor, index, offsets, mtr);
page_cur_move_to_prev(page_cursor); page_cur_move_to_prev(page_cursor);
rec = btr_cur_insert_if_possible(cursor, page_zip, new_entry, rec = btr_cur_insert_if_possible(cursor, new_entry,
ext_vect, n_ext_vect, mtr); ext_vect, n_ext_vect, mtr);
ut_a(rec || optim_err != DB_UNDERFLOW); ut_a(rec || optim_err != DB_UNDERFLOW);
...@@ -2663,7 +2656,9 @@ btr_cur_optimistic_delete( ...@@ -2663,7 +2656,9 @@ btr_cur_optimistic_delete(
if (no_compress_needed) { if (no_compress_needed) {
page_t* page = buf_block_get_frame(block); page_t* page = buf_block_get_frame(block);
#ifdef UNIV_ZIP_DEBUG
page_zip_des_t* page_zip= buf_block_get_page_zip(block); page_zip_des_t* page_zip= buf_block_get_page_zip(block);
#endif /* UNIV_ZIP_DEBUG */
lock_update_delete(rec); lock_update_delete(rec);
...@@ -2675,7 +2670,7 @@ btr_cur_optimistic_delete( ...@@ -2675,7 +2670,7 @@ btr_cur_optimistic_delete(
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 */
page_cur_delete_rec(btr_cur_get_page_cur(cursor), page_cur_delete_rec(btr_cur_get_page_cur(cursor),
cursor->index, offsets, page_zip, mtr); cursor->index, offsets, mtr);
#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 */
...@@ -2836,8 +2831,7 @@ btr_cur_pessimistic_delete( ...@@ -2836,8 +2831,7 @@ btr_cur_pessimistic_delete(
btr_search_update_hash_on_delete(cursor); btr_search_update_hash_on_delete(cursor);
page_cur_delete_rec(btr_cur_get_page_cur(cursor), index, page_cur_delete_rec(btr_cur_get_page_cur(cursor), index, offsets, mtr);
offsets, page_zip, mtr);
#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 */
......
...@@ -408,8 +408,7 @@ btr_pcur_move_to_next_page( ...@@ -408,8 +408,7 @@ btr_pcur_move_to_next_page(
btr_leaf_page_release(btr_pcur_get_block(cursor), btr_leaf_page_release(btr_pcur_get_block(cursor),
cursor->latch_mode, mtr); cursor->latch_mode, mtr);
btr_pcur_get_btr_cur(cursor)->page_block = next_block; page_cur_set_before_first(next_block, 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);
} }
...@@ -478,8 +477,7 @@ btr_pcur_move_backward_from_page( ...@@ -478,8 +477,7 @@ btr_pcur_move_backward_from_page(
btr_leaf_page_release(btr_pcur_get_block(cursor), btr_leaf_page_release(btr_pcur_get_block(cursor),
latch_mode, mtr); latch_mode, mtr);
btr_pcur_get_btr_cur(cursor)->page_block = prev_block; page_cur_set_after_last(prev_block,
page_cur_set_after_last(buf_block_get_frame(prev_block),
btr_pcur_get_page_cur(cursor)); btr_pcur_get_page_cur(cursor));
} else { } else {
......
...@@ -1276,23 +1276,17 @@ parameters as page (this often happens when a page is split). */ ...@@ -1276,23 +1276,17 @@ parameters as page (this often happens when a page is split). */
void void
btr_search_move_or_delete_hash_entries( btr_search_move_or_delete_hash_entries(
/*===================================*/ /*===================================*/
page_t* new_page, /* in: records are copied buf_block_t* new_block, /* in: records are copied
to this page */ to this page */
page_t* page, /* in: index page from which buf_block_t* block, /* in: index page from which
records were copied, and the records were copied, and the
copied records will be deleted copied records will be deleted
from this page */ from this page */
dict_index_t* index) /* in: record descriptor */ dict_index_t* index) /* in: record descriptor */
{ {
buf_block_t* block; ulint n_fields;
buf_block_t* new_block; ulint n_bytes;
ulint n_fields; ibool left_side;
ulint n_bytes;
ibool left_side;
block = buf_block_align(page);
new_block = buf_block_align(new_page);
ut_a(page_is_comp(page) == page_is_comp(new_page));
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX)); ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
...@@ -1328,11 +1322,9 @@ btr_search_move_or_delete_hash_entries( ...@@ -1328,11 +1322,9 @@ btr_search_move_or_delete_hash_entries(
btr_search_build_page_hash_index(index, new_block, n_fields, btr_search_build_page_hash_index(index, new_block, n_fields,
n_bytes, left_side); n_bytes, left_side);
#if 1 /* TODO: safe to remove? */ ut_ad(n_fields == block->curr_n_fields);
ut_a(n_fields == block->curr_n_fields); ut_ad(n_bytes == block->curr_n_bytes);
ut_a(n_bytes == block->curr_n_bytes); ut_ad(left_side == block->curr_left_side);
ut_a(left_side == block->curr_left_side);
#endif
return; return;
} }
......
...@@ -2917,7 +2917,7 @@ dump: ...@@ -2917,7 +2917,7 @@ dump:
return; return;
} }
low_match = page_cur_search(page, index, entry, low_match = page_cur_search(block, index, entry,
PAGE_CUR_LE, &page_cur); PAGE_CUR_LE, &page_cur);
if (low_match == dtuple_get_n_fields(entry)) { if (low_match == dtuple_get_n_fields(entry)) {
...@@ -2925,23 +2925,21 @@ dump: ...@@ -2925,23 +2925,21 @@ dump:
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, rec = page_cur_tuple_insert(&page_cur, entry, index,
buf_block_get_page_zip(block), 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(block, index, mtr); btr_page_reorganize(block, index, mtr);
page_cur_search(page, index, entry, page_cur_search(block, 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_tuple_insert(&page_cur, entry, index,
&page_cur, buf_block_get_page_zip(block), NULL, 0, mtr))) {
entry, index, NULL, 0, mtr))) {
ulint space; ulint space;
ulint page_no; ulint page_no;
......
...@@ -81,42 +81,42 @@ dulint ...@@ -81,42 +81,42 @@ dulint
btr_page_get_index_id( btr_page_get_index_id(
/*==================*/ /*==================*/
/* out: index id */ /* out: index id */
page_t* page); /* in: index page */ const page_t* page); /* in: index page */
/************************************************************ /************************************************************
Gets the node level field in an index page. */ Gets the node level field in an index page. */
UNIV_INLINE UNIV_INLINE
ulint ulint
btr_page_get_level_low( btr_page_get_level_low(
/*===================*/ /*===================*/
/* out: level, leaf level == 0 */ /* out: level, leaf level == 0 */
page_t* page); /* in: index page */ const page_t* page); /* in: index page */
/************************************************************ /************************************************************
Gets the node level field in an index page. */ Gets the node level field in an index page. */
UNIV_INLINE UNIV_INLINE
ulint ulint
btr_page_get_level( btr_page_get_level(
/*===============*/ /*===============*/
/* out: level, leaf level == 0 */ /* out: level, leaf level == 0 */
page_t* page, /* in: index page */ const page_t* page, /* in: index page */
mtr_t* mtr); /* in: mini-transaction handle */ mtr_t* mtr); /* in: mini-transaction handle */
/************************************************************ /************************************************************
Gets the next index page number. */ Gets the next index page number. */
UNIV_INLINE UNIV_INLINE
ulint ulint
btr_page_get_next( btr_page_get_next(
/*==============*/ /*==============*/
/* out: next page number */ /* out: next page number */
page_t* page, /* in: index page */ const page_t* page, /* in: index page */
mtr_t* mtr); /* in: mini-transaction handle */ mtr_t* mtr); /* in: mini-transaction handle */
/************************************************************ /************************************************************
Gets the previous index page number. */ Gets the previous index page number. */
UNIV_INLINE UNIV_INLINE
ulint ulint
btr_page_get_prev( btr_page_get_prev(
/*==============*/ /*==============*/
/* out: prev page number */ /* out: prev page number */
page_t* page, /* in: index page */ const page_t* page, /* in: index page */
mtr_t* mtr); /* in: mini-transaction handle */ mtr_t* mtr); /* in: mini-transaction handle */
/***************************************************************** /*****************************************************************
Gets pointer to the previous user record in the tree. It is assumed Gets pointer to the previous user record in the tree. It is assumed
that the caller has appropriate latches on the page and its neighbor. */ that the caller has appropriate latches on the page and its neighbor. */
......
...@@ -80,7 +80,7 @@ dulint ...@@ -80,7 +80,7 @@ dulint
btr_page_get_index_id( btr_page_get_index_id(
/*==================*/ /*==================*/
/* out: index id */ /* out: index id */
page_t* page) /* in: index page */ const page_t* page) /* in: index page */
{ {
return(mach_read_from_8(page + PAGE_HEADER + PAGE_INDEX_ID)); return(mach_read_from_8(page + PAGE_HEADER + PAGE_INDEX_ID));
} }
...@@ -91,8 +91,8 @@ UNIV_INLINE ...@@ -91,8 +91,8 @@ UNIV_INLINE
ulint ulint
btr_page_get_level_low( btr_page_get_level_low(
/*===================*/ /*===================*/
/* out: level, leaf level == 0 */ /* out: level, leaf level == 0 */
page_t* page) /* in: index page */ const page_t* page) /* in: index page */
{ {
ulint level; ulint level;
...@@ -111,9 +111,10 @@ UNIV_INLINE ...@@ -111,9 +111,10 @@ UNIV_INLINE
ulint ulint
btr_page_get_level( btr_page_get_level(
/*===============*/ /*===============*/
/* out: level, leaf level == 0 */ /* out: level, leaf level == 0 */
page_t* page, /* in: index page */ const page_t* page, /* in: index page */
mtr_t* mtr __attribute__((unused))) /* in: mini-transaction handle */ mtr_t* mtr __attribute__((unused)))
/* in: mini-transaction handle */
{ {
ut_ad(page && mtr); ut_ad(page && mtr);
...@@ -152,9 +153,10 @@ UNIV_INLINE ...@@ -152,9 +153,10 @@ UNIV_INLINE
ulint ulint
btr_page_get_next( btr_page_get_next(
/*==============*/ /*==============*/
/* out: next page number */ /* out: next page number */
page_t* page, /* in: index page */ const page_t* page, /* in: index page */
mtr_t* mtr __attribute__((unused))) /* in: mini-transaction handle */ mtr_t* mtr __attribute__((unused)))
/* in: mini-transaction handle */
{ {
ut_ad(page && mtr); ut_ad(page && mtr);
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX) ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)
...@@ -191,8 +193,8 @@ UNIV_INLINE ...@@ -191,8 +193,8 @@ UNIV_INLINE
ulint ulint
btr_page_get_prev( btr_page_get_prev(
/*==============*/ /*==============*/
/* out: prev page number */ /* out: prev page number */
page_t* page, /* in: index page */ const page_t* page, /* in: index page */
mtr_t* mtr __attribute__((unused))) /* in: mini-transaction handle */ mtr_t* mtr __attribute__((unused))) /* in: mini-transaction handle */
{ {
ut_ad(page && mtr); ut_ad(page && mtr);
......
...@@ -595,9 +595,6 @@ to know struct size! */ ...@@ -595,9 +595,6 @@ 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() */
buf_block_t* left_block; /* this field is used to store buf_block_t* left_block; /* 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
......
...@@ -28,8 +28,7 @@ btr_cur_get_block( ...@@ -28,8 +28,7 @@ btr_cur_get_block(
/* out: pointer to buffer block */ /* out: pointer to buffer block */
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_block(btr_cur_get_page_cur(cursor)));
return(cursor->page_block);
} }
/************************************************************* /*************************************************************
...@@ -41,7 +40,6 @@ btr_cur_get_rec( ...@@ -41,7 +40,6 @@ 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)));
} }
...@@ -67,7 +65,6 @@ btr_cur_invalidate( ...@@ -67,7 +65,6 @@ 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;
} }
/************************************************************* /*************************************************************
...@@ -107,8 +104,7 @@ btr_cur_position( ...@@ -107,8 +104,7 @@ btr_cur_position(
{ {
ut_ad(page_align(rec) == buf_block_get_frame(block)); ut_ad(page_align(rec) == buf_block_get_frame(block));
page_cur_position(rec, btr_cur_get_page_cur(cursor)); page_cur_position(rec, block, btr_cur_get_page_cur(cursor));
cursor->page_block = block;
cursor->index = index; cursor->index = index;
} }
......
...@@ -310,7 +310,7 @@ btr_pcur_move_to_last_on_page( ...@@ -310,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(btr_pcur_get_page(cursor), page_cur_set_after_last(btr_pcur_get_block(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;
...@@ -633,8 +633,8 @@ btr_pcur_close( ...@@ -633,8 +633,8 @@ 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->btr_cur.page_cur.block = 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;
......
...@@ -77,9 +77,12 @@ parameters as page (this often happens when a page is split). */ ...@@ -77,9 +77,12 @@ parameters as page (this often happens when a page is split). */
void void
btr_search_move_or_delete_hash_entries( btr_search_move_or_delete_hash_entries(
/*===================================*/ /*===================================*/
page_t* new_page, /* in: records are copied buf_block_t* new_block, /* in: records are copied
to this page */ to this page */
page_t* page, /* in: index page */ buf_block_t* block, /* in: index page from which
records were copied, and the
copied records will be deleted
from this page */
dict_index_t* index); /* in: record descriptor */ dict_index_t* index); /* in: record descriptor */
/************************************************************************ /************************************************************************
Drops a page hash index. */ Drops a page hash index. */
......
...@@ -581,16 +581,18 @@ UNIV_INLINE ...@@ -581,16 +581,18 @@ UNIV_INLINE
ulint ulint
buf_block_get_space( buf_block_get_space(
/*================*/ /*================*/
/* out: space id */ /* out: space id */
buf_block_t* block); /* in: pointer to the control block */ const buf_block_t* block) /* in: pointer to the control block */
__attribute((const));
/************************************************************************* /*************************************************************************
Gets the page number of a block. */ Gets the page number of a block. */
UNIV_INLINE UNIV_INLINE
ulint ulint
buf_block_get_page_no( buf_block_get_page_no(
/*==================*/ /*==================*/
/* out: page number */ /* out: page number */
buf_block_t* block); /* in: pointer to the control block */ const buf_block_t* block) /* in: pointer to the control block */
__attribute((const));
/************************************************************************* /*************************************************************************
Gets the compressed page size of a block. */ Gets the compressed page size of a block. */
UNIV_INLINE UNIV_INLINE
......
...@@ -162,8 +162,8 @@ UNIV_INLINE ...@@ -162,8 +162,8 @@ UNIV_INLINE
ulint ulint
buf_block_get_space( buf_block_get_space(
/*================*/ /*================*/
/* out: space id */ /* out: space id */
buf_block_t* block) /* in: pointer to the control block */ const buf_block_t* block) /* in: pointer to the control block */
{ {
ut_ad(block); ut_ad(block);
ut_ad(block >= buf_pool->blocks); ut_ad(block >= buf_pool->blocks);
...@@ -180,8 +180,8 @@ UNIV_INLINE ...@@ -180,8 +180,8 @@ UNIV_INLINE
ulint ulint
buf_block_get_page_no( buf_block_get_page_no(
/*==================*/ /*==================*/
/* out: page number */ /* out: page number */
buf_block_t* block) /* in: pointer to the control block */ const buf_block_t* block) /* in: pointer to the control block */
{ {
ut_ad(block); ut_ad(block);
ut_ad(block >= buf_pool->blocks); ut_ad(block >= buf_pool->blocks);
......
...@@ -293,10 +293,10 @@ Checks if memo contains the given page. */ ...@@ -293,10 +293,10 @@ Checks if memo contains the given page. */
ibool ibool
mtr_memo_contains_page( mtr_memo_contains_page(
/*===================*/ /*===================*/
/* out: TRUE if contains */ /* out: TRUE if contains */
mtr_t* mtr, /* in: mtr */ mtr_t* mtr, /* in: mtr */
byte* ptr, /* in: pointer to buffer frame */ const byte* ptr, /* in: pointer to buffer frame */
ulint type); /* in: type of object */ ulint type); /* in: type of object */
/************************************************************* /*************************************************************
Prints info of an mtr handle. */ Prints info of an mtr handle. */
......
...@@ -11,7 +11,7 @@ Created 10/4/1994 Heikki Tuuri ...@@ -11,7 +11,7 @@ Created 10/4/1994 Heikki Tuuri
#include "univ.i" #include "univ.i"
#include "page0types.h" #include "buf0types.h"
#include "page0page.h" #include "page0page.h"
#include "rem0rec.h" #include "rem0rec.h"
#include "data0data.h" #include "data0data.h"
...@@ -49,6 +49,22 @@ page_cur_get_page( ...@@ -49,6 +49,22 @@ page_cur_get_page(
/* out: page */ /* out: page */
page_cur_t* cur); /* in: page cursor */ page_cur_t* cur); /* in: page cursor */
/************************************************************* /*************************************************************
Gets pointer to the buffer block where the cursor is positioned. */
UNIV_INLINE
buf_block_t*
page_cur_get_block(
/*===============*/
/* out: page */
page_cur_t* cur); /* in: page cursor */
/*************************************************************
Gets pointer to the page frame where the cursor is positioned. */
UNIV_INLINE
page_zip_des_t*
page_cur_get_page_zip(
/*==================*/
/* out: page */
page_cur_t* cur); /* in: page cursor */
/*************************************************************
Gets the record where the cursor is positioned. */ Gets the record where the cursor is positioned. */
UNIV_INLINE UNIV_INLINE
rec_t* rec_t*
...@@ -63,7 +79,7 @@ UNIV_INLINE ...@@ -63,7 +79,7 @@ UNIV_INLINE
void void
page_cur_set_before_first( page_cur_set_before_first(
/*======================*/ /*======================*/
page_t* page, /* in: index page */ buf_block_t* block, /* in: index page */
page_cur_t* cur); /* in: cursor */ page_cur_t* cur); /* in: cursor */
/************************************************************* /*************************************************************
Sets the cursor object to point after the last user record on Sets the cursor object to point after the last user record on
...@@ -72,7 +88,7 @@ UNIV_INLINE ...@@ -72,7 +88,7 @@ UNIV_INLINE
void void
page_cur_set_after_last( page_cur_set_after_last(
/*====================*/ /*====================*/
page_t* page, /* in: index page */ buf_block_t* block, /* in: index page */
page_cur_t* cur); /* in: cursor */ page_cur_t* cur); /* in: cursor */
/************************************************************* /*************************************************************
Returns TRUE if the cursor is before first user record on page. */ Returns TRUE if the cursor is before first user record on page. */
...@@ -97,7 +113,8 @@ void ...@@ -97,7 +113,8 @@ void
page_cur_position( page_cur_position(
/*==============*/ /*==============*/
rec_t* rec, /* in: record on a page */ rec_t* rec, /* in: record on a page */
page_cur_t* cur); /* in: page cursor */ buf_block_t* block, /* in: buffer block containing the record */
page_cur_t* cur); /* out: page cursor */
/************************************************************** /**************************************************************
Invalidates a page cursor by setting the record pointer NULL. */ Invalidates a page cursor by setting the record pointer NULL. */
UNIV_INLINE UNIV_INLINE
...@@ -130,7 +147,6 @@ page_cur_tuple_insert( ...@@ -130,7 +147,6 @@ page_cur_tuple_insert(
/* out: pointer to record if succeed, NULL /* out: pointer to record if succeed, NULL
otherwise */ otherwise */
page_cur_t* cursor, /* in: a page cursor */ page_cur_t* cursor, /* in: a page cursor */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
const dtuple_t* tuple, /* in: pointer to a data tuple */ const dtuple_t* tuple, /* in: pointer to a data tuple */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
const ulint* ext, /* in: array of extern field numbers */ const ulint* ext, /* in: array of extern field numbers */
...@@ -147,7 +163,6 @@ page_cur_rec_insert( ...@@ -147,7 +163,6 @@ page_cur_rec_insert(
/* out: pointer to record if succeed, NULL /* out: pointer to record if succeed, NULL
otherwise */ otherwise */
page_cur_t* cursor, /* in: a page cursor */ page_cur_t* cursor, /* in: a page cursor */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
rec_t* rec, /* in: record to insert */ rec_t* rec, /* in: record to insert */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
ulint* offsets,/* in/out: rec_get_offsets(rec, index) */ ulint* offsets,/* in/out: rec_get_offsets(rec, index) */
...@@ -163,8 +178,9 @@ page_cur_insert_rec_low( ...@@ -163,8 +178,9 @@ page_cur_insert_rec_low(
/*====================*/ /*====================*/
/* out: pointer to record if succeed, NULL /* out: pointer to record if succeed, NULL
otherwise */ otherwise */
page_cur_t* cursor, /* in: a page cursor */ rec_t* current_rec,/* in: current record after which the
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */ new record is inserted */
page_zip_des_t* page_zip,/* in: compressed page, or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
rec_t* rec, /* in: pointer to a physical record */ rec_t* rec, /* in: pointer to a physical record */
ulint* offsets,/* in/out: rec_get_offsets(rec, index) */ ulint* offsets,/* in/out: rec_get_offsets(rec, index) */
...@@ -190,7 +206,6 @@ page_cur_delete_rec( ...@@ -190,7 +206,6 @@ page_cur_delete_rec(
page_cur_t* cursor, /* in/out: a page cursor */ page_cur_t* cursor, /* in/out: a page cursor */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
const ulint* offsets,/* in: rec_get_offsets(cursor->rec, index) */ const ulint* offsets,/* in: rec_get_offsets(cursor->rec, index) */
page_zip_des_t* page_zip,/* in/out: compressed, or NULL */
mtr_t* mtr); /* in: mini-transaction handle */ mtr_t* mtr); /* in: mini-transaction handle */
/******************************************************************** /********************************************************************
Searches the right position for a page cursor. */ Searches the right position for a page cursor. */
...@@ -199,7 +214,7 @@ ulint ...@@ -199,7 +214,7 @@ ulint
page_cur_search( page_cur_search(
/*============*/ /*============*/
/* out: number of matched fields on the left */ /* out: number of matched fields on the left */
page_t* page, /* in: index page */ buf_block_t* block, /* in: buffer block */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
const dtuple_t* tuple, /* in: data tuple */ const dtuple_t* tuple, /* in: data tuple */
ulint mode, /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G, ulint mode, /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G,
...@@ -211,7 +226,7 @@ Searches the right position for a page cursor. */ ...@@ -211,7 +226,7 @@ Searches the right position for a page cursor. */
void void
page_cur_search_with_match( page_cur_search_with_match(
/*=======================*/ /*=======================*/
page_t* page, /* in: index page */ buf_block_t* block, /* in: buffer block */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
const dtuple_t* tuple, /* in: data tuple */ const dtuple_t* tuple, /* in: data tuple */
ulint mode, /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G, ulint mode, /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G,
...@@ -236,8 +251,8 @@ are no user records, sets the cursor on the infimum record. */ ...@@ -236,8 +251,8 @@ are no user records, sets the cursor on the infimum record. */
void void
page_cur_open_on_rnd_user_rec( page_cur_open_on_rnd_user_rec(
/*==========================*/ /*==========================*/
page_t* page, /* in: page */ buf_block_t* block, /* in: page */
page_cur_t* cursor);/* in/out: page cursor */ page_cur_t* cursor);/* out: page cursor */
/*************************************************************** /***************************************************************
Parses a log record of a record insert on a page. */ Parses a log record of a record insert on a page. */
...@@ -248,9 +263,8 @@ page_cur_parse_insert_rec( ...@@ -248,9 +263,8 @@ page_cur_parse_insert_rec(
ibool is_short,/* in: TRUE if short inserts */ ibool is_short,/* in: TRUE if short inserts */
byte* ptr, /* in: buffer */ byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */ byte* end_ptr,/* in: buffer end */
buf_block_t* block, /* in: page or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
page_t* page, /* in/out: page 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 */
/************************************************************** /**************************************************************
Parses a log record of copying a record list end to a new created page. */ Parses a log record of copying a record list end to a new created page. */
...@@ -261,9 +275,8 @@ page_parse_copy_rec_list_to_created_page( ...@@ -261,9 +275,8 @@ page_parse_copy_rec_list_to_created_page(
/* out: end of log record or NULL */ /* out: end of log record or NULL */
byte* ptr, /* in: buffer */ byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */ byte* end_ptr,/* in: buffer end */
buf_block_t* block, /* in: page or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
page_t* page, /* in/out: page 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 */
/*************************************************************** /***************************************************************
Parses log record of a record delete on a page. */ Parses log record of a record delete on a page. */
...@@ -274,15 +287,15 @@ page_cur_parse_delete_rec( ...@@ -274,15 +287,15 @@ page_cur_parse_delete_rec(
/* out: pointer to record end or NULL */ /* out: pointer to record end or NULL */
byte* ptr, /* in: buffer */ byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */ byte* end_ptr,/* in: buffer end */
buf_block_t* block, /* in: page or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
page_t* page, /* in/out: page 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 */
/* Index page cursor */ /* Index page cursor */
struct page_cur_struct{ struct page_cur_struct{
byte* rec; /* pointer to a record on page */ byte* rec; /* pointer to a record on page */
buf_block_t* block; /* pointer to the block containing rec */
}; };
#ifndef UNIV_NONINL #ifndef UNIV_NONINL
......
...@@ -7,6 +7,7 @@ Created 10/4/1994 Heikki Tuuri ...@@ -7,6 +7,7 @@ Created 10/4/1994 Heikki Tuuri
*************************************************************************/ *************************************************************************/
#include "page0page.h" #include "page0page.h"
#include "buf0types.h"
/************************************************************* /*************************************************************
...@@ -23,6 +24,32 @@ page_cur_get_page( ...@@ -23,6 +24,32 @@ page_cur_get_page(
return(page_align(cur->rec)); return(page_align(cur->rec));
} }
/*************************************************************
Gets pointer to the buffer block where the cursor is positioned. */
UNIV_INLINE
buf_block_t*
page_cur_get_block(
/*===============*/
/* out: page */
page_cur_t* cur) /* in: page cursor */
{
ut_ad(cur);
ut_ad(page_align(cur->rec) == cur->block->frame);
return(cur->block);
}
/*************************************************************
Gets pointer to the page frame where the cursor is positioned. */
UNIV_INLINE
page_zip_des_t*
page_cur_get_page_zip(
/*==================*/
/* out: page */
page_cur_t* cur) /* in: page cursor */
{
return(buf_block_get_page_zip(page_cur_get_block(cur)));
}
/************************************************************* /*************************************************************
Gets the record where the cursor is positioned. */ Gets the record where the cursor is positioned. */
UNIV_INLINE UNIV_INLINE
...@@ -33,6 +60,7 @@ page_cur_get_rec( ...@@ -33,6 +60,7 @@ page_cur_get_rec(
page_cur_t* cur) /* in: page cursor */ page_cur_t* cur) /* in: page cursor */
{ {
ut_ad(cur); ut_ad(cur);
ut_ad(page_align(cur->rec) == cur->block->frame);
return(cur->rec); return(cur->rec);
} }
...@@ -44,10 +72,11 @@ UNIV_INLINE ...@@ -44,10 +72,11 @@ UNIV_INLINE
void void
page_cur_set_before_first( page_cur_set_before_first(
/*======================*/ /*======================*/
page_t* page, /* in: index page */ buf_block_t* block, /* in: index page */
page_cur_t* cur) /* in: cursor */ page_cur_t* cur) /* in: cursor */
{ {
cur->rec = page_get_infimum_rec(page); cur->rec = page_get_infimum_rec(buf_block_get_frame(block));
cur->block = block;
} }
/************************************************************* /*************************************************************
...@@ -57,10 +86,11 @@ UNIV_INLINE ...@@ -57,10 +86,11 @@ UNIV_INLINE
void void
page_cur_set_after_last( page_cur_set_after_last(
/*====================*/ /*====================*/
page_t* page, /* in: index page */ buf_block_t* block, /* in: index page */
page_cur_t* cur) /* in: cursor */ page_cur_t* cur) /* in: cursor */
{ {
cur->rec = page_get_supremum_rec(page); cur->rec = page_get_supremum_rec(buf_block_get_frame(block));
cur->block = block;
} }
/************************************************************* /*************************************************************
...@@ -94,11 +124,14 @@ void ...@@ -94,11 +124,14 @@ void
page_cur_position( page_cur_position(
/*==============*/ /*==============*/
rec_t* rec, /* in: record on a page */ rec_t* rec, /* in: record on a page */
page_cur_t* cur) /* in: page cursor */ buf_block_t* block, /* in: buffer block containing the record */
page_cur_t* cur) /* out: page cursor */
{ {
ut_ad(rec && cur); ut_ad(rec && block && cur);
ut_ad(page_align(rec) == block->frame);
cur->rec = rec; cur->rec = rec;
cur->block = block;
} }
/************************************************************** /**************************************************************
...@@ -112,6 +145,7 @@ page_cur_invalidate( ...@@ -112,6 +145,7 @@ page_cur_invalidate(
ut_ad(cur); ut_ad(cur);
cur->rec = NULL; cur->rec = NULL;
cur->block = NULL;
} }
/************************************************************** /**************************************************************
...@@ -147,7 +181,7 @@ ulint ...@@ -147,7 +181,7 @@ ulint
page_cur_search( page_cur_search(
/*============*/ /*============*/
/* out: number of matched fields on the left */ /* out: number of matched fields on the left */
page_t* page, /* in: index page */ buf_block_t* block, /* in: buffer block */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
const dtuple_t* tuple, /* in: data tuple */ const dtuple_t* tuple, /* in: data tuple */
ulint mode, /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G, ulint mode, /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G,
...@@ -161,7 +195,7 @@ page_cur_search( ...@@ -161,7 +195,7 @@ page_cur_search(
ut_ad(dtuple_check_typed(tuple)); ut_ad(dtuple_check_typed(tuple));
page_cur_search_with_match(page, index, tuple, mode, page_cur_search_with_match(block, index, tuple, mode,
&up_matched_fields, &up_matched_fields,
&up_matched_bytes, &up_matched_bytes,
&low_matched_fields, &low_matched_fields,
...@@ -181,7 +215,6 @@ page_cur_tuple_insert( ...@@ -181,7 +215,6 @@ page_cur_tuple_insert(
/* out: pointer to record if succeed, NULL /* out: pointer to record if succeed, NULL
otherwise */ otherwise */
page_cur_t* cursor, /* in: a page cursor */ page_cur_t* cursor, /* in: a page cursor */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
const dtuple_t* tuple, /* in: pointer to a data tuple */ const dtuple_t* tuple, /* in: pointer to a data tuple */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
const ulint* ext, /* in: array of extern field numbers */ const ulint* ext, /* in: array of extern field numbers */
...@@ -202,7 +235,8 @@ page_cur_tuple_insert( ...@@ -202,7 +235,8 @@ page_cur_tuple_insert(
index, tuple, ext, n_ext); index, tuple, ext, n_ext);
offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap); offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap);
rec = page_cur_insert_rec_low(cursor, page_zip, rec = page_cur_insert_rec_low(cursor->rec,
buf_block_get_page_zip(cursor->block),
index, rec, offsets, mtr); index, rec, offsets, mtr);
mem_heap_free(heap); mem_heap_free(heap);
return(rec); return(rec);
...@@ -219,13 +253,13 @@ page_cur_rec_insert( ...@@ -219,13 +253,13 @@ page_cur_rec_insert(
/* out: pointer to record if succeed, NULL /* out: pointer to record if succeed, NULL
otherwise */ otherwise */
page_cur_t* cursor, /* in: a page cursor */ page_cur_t* cursor, /* in: a page cursor */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
rec_t* rec, /* in: record to insert */ rec_t* rec, /* in: record to insert */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
ulint* offsets,/* in/out: rec_get_offsets(rec, index) */ ulint* offsets,/* in/out: rec_get_offsets(rec, index) */
mtr_t* mtr) /* in: mini-transaction handle, or NULL */ mtr_t* mtr) /* in: mini-transaction handle, or NULL */
{ {
return(page_cur_insert_rec_low(cursor, page_zip, return(page_cur_insert_rec_low(cursor->rec,
buf_block_get_page_zip(cursor->block),
index, rec, offsets, mtr)); index, rec, offsets, mtr));
} }
...@@ -100,6 +100,14 @@ typedef byte page_header_t; ...@@ -100,6 +100,14 @@ typedef byte page_header_t;
a new-style compact page */ a new-style compact page */
/*-----------------------------*/ /*-----------------------------*/
/* Heap numbers */
#define PAGE_HEAP_NO_INFIMUM 0 /* page infimum */
#define PAGE_HEAP_NO_SUPREMUM 1 /* page supremum */
#define PAGE_HEAP_NO_USER_LOW 2 /* first user record in
creation (insertion) order,
not necessarily collation order;
this record may have been deleted */
/* Directions of cursor movement */ /* Directions of cursor movement */
#define PAGE_LEFT 1 #define PAGE_LEFT 1
#define PAGE_RIGHT 2 #define PAGE_RIGHT 2
...@@ -681,7 +689,8 @@ touch the lock table and max trx id on page or compress the page. */ ...@@ -681,7 +689,8 @@ touch the lock table and max trx id on page or compress the page. */
void void
page_copy_rec_list_end_no_locks( page_copy_rec_list_end_no_locks(
/*============================*/ /*============================*/
page_t* new_page, /* in: index page to copy to */ buf_block_t* new_block, /* in: index page to copy to */
buf_block_t* block, /* in: index page of rec */
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 */
...@@ -696,9 +705,9 @@ page_copy_rec_list_end( ...@@ -696,9 +705,9 @@ page_copy_rec_list_end(
/* out: pointer to the original /* out: pointer to the original
successor of the infimum record successor of the infimum record
on new_page, or NULL on zip overflow on new_page, or NULL on zip overflow
(new_page will be decompressed (new_block will be decompressed) */
from new_page_zip) */
buf_block_t* new_block, /* in/out: index page to copy to */ buf_block_t* new_block, /* in/out: index page to copy to */
buf_block_t* block, /* in: index page containing rec */
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 */
...@@ -714,9 +723,9 @@ page_copy_rec_list_start( ...@@ -714,9 +723,9 @@ page_copy_rec_list_start(
/* out: pointer to the original /* out: pointer to the original
predecessor of the supremum record predecessor of the supremum record
on new_page, or NULL on zip overflow on new_page, or NULL on zip overflow
(new_page will be decompressed (new_block will be decompressed) */
from new_page_zip) */
buf_block_t* new_block, /* in/out: index page to copy to */ buf_block_t* new_block, /* in/out: index page to copy to */
buf_block_t* block, /* in: index page containing rec */
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 */
...@@ -729,15 +738,15 @@ void ...@@ -729,15 +738,15 @@ void
page_delete_rec_list_end( page_delete_rec_list_end(
/*=====================*/ /*=====================*/
rec_t* rec, /* in: pointer to record on page */ rec_t* rec, /* in: pointer to record on page */
buf_block_t* block, /* in: buffer block of the page */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
ulint n_recs, /* in: number of records to delete, ulint n_recs, /* in: number of records to delete,
or ULINT_UNDEFINED if not known */ or ULINT_UNDEFINED if not known */
ulint size, /* in: the sum of the sizes of the ulint size, /* in: the sum of the sizes of the
records in the end of the chain to records in the end of the chain to
delete, or ULINT_UNDEFINED if not known */ delete, or ULINT_UNDEFINED if not known */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
__attribute__((nonnull(1, 2, 6))); __attribute__((nonnull));
/***************************************************************** /*****************************************************************
Deletes records from page, up to the given record, NOT including Deletes records from page, up to the given record, NOT including
that record. Infimum and supremum records are not deleted. */ that record. Infimum and supremum records are not deleted. */
...@@ -746,10 +755,10 @@ void ...@@ -746,10 +755,10 @@ void
page_delete_rec_list_start( page_delete_rec_list_start(
/*=======================*/ /*=======================*/
rec_t* rec, /* in: record on page */ rec_t* rec, /* in: record on page */
buf_block_t* block, /* in: buffer block of the page */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
page_zip_des_t* page_zip,/* in/out: compressed page of rec, or NULL */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
__attribute__((nonnull(1, 2, 4))); __attribute__((nonnull));
/***************************************************************** /*****************************************************************
Moves record list end to another page. Moved records include Moves record list end to another page. Moved records include
split_rec. */ split_rec. */
...@@ -758,12 +767,11 @@ ibool ...@@ -758,12 +767,11 @@ ibool
page_move_rec_list_end( page_move_rec_list_end(
/*===================*/ /*===================*/
/* out: TRUE on success; FALSE on /* out: TRUE on success; FALSE on
compression failure (new_page will compression failure
be decompressed from new_page_zip) */ (new_block will be decompressed) */
buf_block_t* new_block, /* in/out: index page where to move */ buf_block_t* new_block, /* in/out: index page where to move */
buf_block_t* block, /* in: index page from where to move */
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
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, 2, 4, 5))); __attribute__((nonnull(1, 2, 4, 5)));
...@@ -777,9 +785,8 @@ page_move_rec_list_start( ...@@ -777,9 +785,8 @@ page_move_rec_list_start(
/* out: TRUE on success; FALSE on /* out: TRUE on success; FALSE on
compression failure */ compression failure */
buf_block_t* new_block, /* in/out: index page where to move */ buf_block_t* new_block, /* in/out: index page where to move */
buf_block_t* block, /* in/out: page containing split_rec */
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
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, 2, 4, 5))); __attribute__((nonnull(1, 2, 4, 5)));
...@@ -820,9 +827,8 @@ page_parse_delete_rec_list( ...@@ -820,9 +827,8 @@ page_parse_delete_rec_list(
MLOG_COMP_LIST_START_DELETE */ MLOG_COMP_LIST_START_DELETE */
byte* ptr, /* in: buffer */ byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */ byte* end_ptr,/* in: buffer end */
buf_block_t* block, /* in/out: buffer block or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
page_t* page, /* in/out: page 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 */
/*************************************************************** /***************************************************************
Parses a redo log record of creating a page. */ Parses a redo log record of creating a page. */
...@@ -874,7 +880,7 @@ debugging purposes. */ ...@@ -874,7 +880,7 @@ debugging purposes. */
void void
page_print_list( page_print_list(
/*============*/ /*============*/
page_t* page, /* in: index page */ buf_block_t* block, /* in: index page */
dict_index_t* index, /* in: dictionary index of the page */ dict_index_t* index, /* in: dictionary index of the page */
ulint pr_n); /* in: print n first and n last entries */ ulint pr_n); /* in: print n first and n last entries */
/******************************************************************* /*******************************************************************
...@@ -883,7 +889,7 @@ Prints the info in a page header. */ ...@@ -883,7 +889,7 @@ Prints the info in a page header. */
void void
page_header_print( page_header_print(
/*==============*/ /*==============*/
page_t* page); const page_t* page);
/******************************************************************* /*******************************************************************
This is used to print the contents of the page for This is used to print the contents of the page for
debugging purposes. */ debugging purposes. */
...@@ -891,7 +897,7 @@ debugging purposes. */ ...@@ -891,7 +897,7 @@ debugging purposes. */
void void
page_print( page_print(
/*=======*/ /*=======*/
page_t* page, /* in: index page */ buf_block_t* block, /* in: index page */
dict_index_t* index, /* in: dictionary index of the page */ dict_index_t* index, /* in: dictionary index of the page */
ulint dn, /* in: print dn first and last entries ulint dn, /* in: print dn first and last entries
in directory */ in directory */
...@@ -936,7 +942,7 @@ ibool ...@@ -936,7 +942,7 @@ ibool
page_simple_validate_new( page_simple_validate_new(
/*=====================*/ /*=====================*/
/* out: TRUE if ok */ /* out: TRUE if ok */
page_t* page); /* in: new-style index page */ page_t* block); /* in: new-style index page */
/******************************************************************* /*******************************************************************
This function checks the consistency of an index page. */ This function checks the consistency of an index page. */
...@@ -950,12 +956,12 @@ page_validate( ...@@ -950,12 +956,12 @@ page_validate(
/******************************************************************* /*******************************************************************
Looks in the page record list for a record with the given heap number. */ Looks in the page record list for a record with the given heap number. */
rec_t* const rec_t*
page_find_rec_with_heap_no( page_find_rec_with_heap_no(
/*=======================*/ /*=======================*/
/* out: record, NULL if not found */ /* out: record, NULL if not found */
page_t* page, /* in: index page */ const page_t* page, /* in: index page */
ulint heap_no);/* in: heap number */ ulint heap_no);/* in: heap number */
#ifdef UNIV_MATERIALIZE #ifdef UNIV_MATERIALIZE
#undef UNIV_INLINE #undef UNIV_INLINE
......
...@@ -2702,8 +2702,8 @@ lock_move_reorganize_page( ...@@ -2702,8 +2702,8 @@ lock_move_reorganize_page(
update of a record is occurring on the page, and its locks update of a record is occurring on the page, and its locks
were temporarily stored on the infimum */ were temporarily stored on the infimum */
page_cur_set_before_first(page, &cur1); page_cur_set_before_first(buf_block_align(page), &cur1);
page_cur_set_before_first(old_page, &cur2); page_cur_set_before_first(buf_block_align(old_page), &cur2);
/* Set locks according to old locks */ /* Set locks according to old locks */
for (;;) { for (;;) {
...@@ -2798,13 +2798,13 @@ lock_move_rec_list_end( ...@@ -2798,13 +2798,13 @@ lock_move_rec_list_end(
while (lock != NULL) { while (lock != NULL) {
page_cur_position(rec, &cur1); page_cur_position(rec, buf_block_align(rec), &cur1);
if (page_cur_is_before_first(&cur1)) { if (page_cur_is_before_first(&cur1)) {
page_cur_move_to_next(&cur1); page_cur_move_to_next(&cur1);
} }
page_cur_set_before_first(new_page, &cur2); page_cur_set_before_first(buf_block_align(new_page), &cur2);
page_cur_move_to_next(&cur2); page_cur_move_to_next(&cur2);
/* Copy lock requests on user records to new page and /* Copy lock requests on user records to new page and
...@@ -2894,10 +2894,10 @@ lock_move_rec_list_start( ...@@ -2894,10 +2894,10 @@ lock_move_rec_list_start(
while (lock != NULL) { while (lock != NULL) {
page_cur_set_before_first(page, &cur1); page_cur_set_before_first(buf_block_align(page), &cur1);
page_cur_move_to_next(&cur1); page_cur_move_to_next(&cur1);
page_cur_position(old_end, &cur2); page_cur_position(old_end, buf_block_align(old_end), &cur2);
page_cur_move_to_next(&cur2); page_cur_move_to_next(&cur2);
/* Copy lock requests on user records to new page and /* Copy lock requests on user records to new page and
...@@ -4302,7 +4302,7 @@ lock_rec_print( ...@@ -4302,7 +4302,7 @@ lock_rec_print(
fprintf(file, "Record lock, heap no %lu ", (ulong) i); fprintf(file, "Record lock, heap no %lu ", (ulong) i);
if (block) { if (block) {
rec_t* rec const rec_t* rec
= page_find_rec_with_heap_no( = page_find_rec_with_heap_no(
buf_block_get_frame(block), i); buf_block_get_frame(block), i);
offsets = rec_get_offsets( offsets = rec_get_offsets(
......
...@@ -803,8 +803,7 @@ recv_parse_or_apply_log_rec_body( ...@@ -803,8 +803,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 = page_cur_parse_insert_rec(FALSE, ptr, end_ptr, ptr = page_cur_parse_insert_rec(FALSE, ptr, end_ptr,
index, block, index, mtr);
page, page_zip, mtr);
} }
break; break;
case MLOG_REC_CLUST_DELETE_MARK: case MLOG_COMP_REC_CLUST_DELETE_MARK: case MLOG_REC_CLUST_DELETE_MARK: case MLOG_COMP_REC_CLUST_DELETE_MARK:
...@@ -856,8 +855,7 @@ recv_parse_or_apply_log_rec_body( ...@@ -856,8 +855,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 = page_parse_delete_rec_list(type, ptr, end_ptr, ptr = page_parse_delete_rec_list(type, ptr, end_ptr,
index, page, block, index, mtr);
page_zip, mtr);
} }
break; break;
case MLOG_LIST_END_COPY_CREATED: case MLOG_COMP_LIST_END_COPY_CREATED: case MLOG_LIST_END_COPY_CREATED: case MLOG_COMP_LIST_END_COPY_CREATED:
...@@ -869,7 +867,7 @@ recv_parse_or_apply_log_rec_body( ...@@ -869,7 +867,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 = page_parse_copy_rec_list_to_created_page( ptr = page_parse_copy_rec_list_to_created_page(
ptr, end_ptr, index, page, page_zip, mtr); ptr, end_ptr, block, index, mtr);
} }
break; break;
case MLOG_PAGE_REORGANIZE: case MLOG_COMP_PAGE_REORGANIZE: case MLOG_PAGE_REORGANIZE: case MLOG_COMP_PAGE_REORGANIZE:
...@@ -925,8 +923,8 @@ recv_parse_or_apply_log_rec_body( ...@@ -925,8 +923,8 @@ recv_parse_or_apply_log_rec_body(
ut_a(!page ut_a(!page
|| (ibool)!!page_is_comp(page) || (ibool)!!page_is_comp(page)
== dict_table_is_comp(index->table)); == dict_table_is_comp(index->table));
ptr = page_cur_parse_delete_rec(ptr, end_ptr, index, ptr = page_cur_parse_delete_rec(ptr, end_ptr,
page, page_zip, mtr); block, index, mtr);
} }
break; break;
case MLOG_IBUF_BITMAP_INIT: case MLOG_IBUF_BITMAP_INIT:
......
...@@ -317,12 +317,12 @@ Checks if memo contains the given page. */ ...@@ -317,12 +317,12 @@ Checks if memo contains the given page. */
ibool ibool
mtr_memo_contains_page( mtr_memo_contains_page(
/*===================*/ /*===================*/
/* out: TRUE if contains */ /* out: TRUE if contains */
mtr_t* mtr, /* in: mtr */ mtr_t* mtr, /* in: mtr */
byte* ptr, /* in: pointer to buffer frame */ const byte* ptr, /* in: pointer to buffer frame */
ulint type) /* in: type of object */ ulint type) /* in: type of object */
{ {
return(mtr_memo_contains(mtr, buf_block_align(ptr), type)); return(mtr_memo_contains(mtr, buf_block_align((byte*) ptr), type));
} }
/************************************************************* /*************************************************************
......
...@@ -31,7 +31,7 @@ ibool ...@@ -31,7 +31,7 @@ ibool
page_cur_try_search_shortcut( page_cur_try_search_shortcut(
/*=========================*/ /*=========================*/
/* out: TRUE on success */ /* out: TRUE on success */
page_t* page, /* in: index page */ buf_block_t* block, /* in: index page */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
const dtuple_t* tuple, /* in: data tuple */ const dtuple_t* tuple, /* in: data tuple */
ulint* iup_matched_fields, ulint* iup_matched_fields,
...@@ -48,16 +48,17 @@ page_cur_try_search_shortcut( ...@@ -48,16 +48,17 @@ page_cur_try_search_shortcut(
not yet completely matched */ not yet completely matched */
page_cur_t* cursor) /* out: page cursor */ page_cur_t* cursor) /* out: page cursor */
{ {
rec_t* rec; rec_t* rec;
rec_t* next_rec; const rec_t* next_rec;
ulint low_match; ulint low_match;
ulint low_bytes; ulint low_bytes;
ulint up_match; ulint up_match;
ulint up_bytes; ulint up_bytes;
#ifdef UNIV_SEARCH_DEBUG #ifdef UNIV_SEARCH_DEBUG
page_cur_t cursor2; page_cur_t cursor2;
#endif #endif
ibool success = FALSE; ibool success = FALSE;
page_t* page = buf_block_get_frame(block);
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint offsets_[REC_OFFS_NORMAL_SIZE];
ulint* offsets = offsets_; ulint* offsets = offsets_;
...@@ -93,10 +94,10 @@ page_cur_try_search_shortcut( ...@@ -93,10 +94,10 @@ page_cur_try_search_shortcut(
goto exit_func; goto exit_func;
} }
cursor->rec = rec; page_cur_position(rec, block, cursor);
#ifdef UNIV_SEARCH_DEBUG #ifdef UNIV_SEARCH_DEBUG
page_cur_search_with_match(page, index, tuple, PAGE_CUR_DBG, page_cur_search_with_match(block, index, tuple, PAGE_CUR_DBG,
iup_matched_fields, iup_matched_fields,
iup_matched_bytes, iup_matched_bytes,
ilow_matched_fields, ilow_matched_fields,
...@@ -104,7 +105,7 @@ page_cur_try_search_shortcut( ...@@ -104,7 +105,7 @@ page_cur_try_search_shortcut(
&cursor2); &cursor2);
ut_a(cursor2.rec == cursor->rec); ut_a(cursor2.rec == cursor->rec);
if (next_rec != page_get_supremum_rec(page)) { if (!page_rec_is_supremum(next_rec)) {
ut_a(*iup_matched_fields == up_match); ut_a(*iup_matched_fields == up_match);
ut_a(*iup_matched_bytes == up_bytes); ut_a(*iup_matched_bytes == up_bytes);
...@@ -193,7 +194,7 @@ Searches the right position for a page cursor. */ ...@@ -193,7 +194,7 @@ Searches the right position for a page cursor. */
void void
page_cur_search_with_match( page_cur_search_with_match(
/*=======================*/ /*=======================*/
page_t* page, /* in: index page */ buf_block_t* block, /* in: buffer block */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
const dtuple_t* tuple, /* in: data tuple */ const dtuple_t* tuple, /* in: data tuple */
ulint mode, /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G, ulint mode, /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G,
...@@ -215,6 +216,7 @@ page_cur_search_with_match( ...@@ -215,6 +216,7 @@ page_cur_search_with_match(
ulint up; ulint up;
ulint low; ulint low;
ulint mid; ulint mid;
page_t* page;
page_dir_slot_t* slot; page_dir_slot_t* slot;
rec_t* up_rec; rec_t* up_rec;
rec_t* low_rec; rec_t* low_rec;
...@@ -236,10 +238,9 @@ page_cur_search_with_match( ...@@ -236,10 +238,9 @@ page_cur_search_with_match(
ulint* offsets = offsets_; ulint* offsets = offsets_;
*offsets_ = (sizeof offsets_) / sizeof *offsets_; *offsets_ = (sizeof offsets_) / sizeof *offsets_;
ut_ad(page && tuple && iup_matched_fields && iup_matched_bytes ut_ad(block && tuple && iup_matched_fields && iup_matched_bytes
&& ilow_matched_fields && ilow_matched_bytes && cursor); && ilow_matched_fields && ilow_matched_bytes && cursor);
ut_ad(dtuple_validate(tuple)); ut_ad(dtuple_validate(tuple));
ut_ad(dtuple_check_typed(tuple));
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
# ifdef PAGE_CUR_DBG # ifdef PAGE_CUR_DBG
if (mode != PAGE_CUR_DBG) if (mode != PAGE_CUR_DBG)
...@@ -250,8 +251,9 @@ page_cur_search_with_match( ...@@ -250,8 +251,9 @@ page_cur_search_with_match(
ut_ad(mode == PAGE_CUR_L || mode == PAGE_CUR_LE ut_ad(mode == PAGE_CUR_L || mode == PAGE_CUR_LE
|| mode == PAGE_CUR_G || mode == PAGE_CUR_GE); || mode == PAGE_CUR_G || mode == PAGE_CUR_GE);
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
page = buf_block_get_frame(block);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
page_zip_des_t* page_zip = buf_frame_get_page_zip(page); page_zip_des_t* 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 */
...@@ -265,7 +267,7 @@ page_cur_search_with_match( ...@@ -265,7 +267,7 @@ page_cur_search_with_match(
&& (page_header_get_field(page, PAGE_DIRECTION) == PAGE_RIGHT)) { && (page_header_get_field(page, PAGE_DIRECTION) == PAGE_RIGHT)) {
if (page_cur_try_search_shortcut( if (page_cur_try_search_shortcut(
page, index, tuple, block, index, tuple,
iup_matched_fields, iup_matched_bytes, iup_matched_fields, iup_matched_bytes,
ilow_matched_fields, ilow_matched_bytes, ilow_matched_fields, ilow_matched_bytes,
cursor)) { cursor)) {
...@@ -465,9 +467,9 @@ up_rec_match: ...@@ -465,9 +467,9 @@ up_rec_match:
} }
#endif #endif
if (mode <= PAGE_CUR_GE) { if (mode <= PAGE_CUR_GE) {
cursor->rec = up_rec; page_cur_position(up_rec, block, cursor);
} else { } else {
cursor->rec = low_rec; page_cur_position(low_rec, block, cursor);
} }
*iup_matched_fields = up_matched_fields; *iup_matched_fields = up_matched_fields;
...@@ -486,33 +488,26 @@ are no user records, sets the cursor on the infimum record. */ ...@@ -486,33 +488,26 @@ are no user records, sets the cursor on the infimum record. */
void void
page_cur_open_on_rnd_user_rec( page_cur_open_on_rnd_user_rec(
/*==========================*/ /*==========================*/
page_t* page, /* in: page */ buf_block_t* block, /* in: page */
page_cur_t* cursor) /* in/out: page cursor */ page_cur_t* cursor) /* out: page cursor */
{ {
ulint rnd; ulint rnd;
rec_t* rec; ulint n_recs = page_get_n_recs(buf_block_get_frame(block));
if (UNIV_UNLIKELY(page_get_n_recs(page) == 0)) { page_cur_set_before_first(block, cursor);
page_cur_position(page_get_infimum_rec(page), cursor);
if (UNIV_UNLIKELY(n_recs == 0)) {
return; return;
} }
page_rnd += 87584577; page_rnd += 87584577;
rnd = page_rnd % page_get_n_recs(page); rnd = page_rnd % n_recs;
rec = page_get_infimum_rec(page);
rec = page_rec_get_next(rec);
while (rnd > 0) {
rec = page_rec_get_next(rec);
rnd--; do {
} page_cur_move_to_next(cursor);
} while (rnd--);
page_cur_position(rec, cursor);
} }
/*************************************************************** /***************************************************************
...@@ -707,18 +702,18 @@ page_cur_parse_insert_rec( ...@@ -707,18 +702,18 @@ page_cur_parse_insert_rec(
ibool is_short,/* in: TRUE if short inserts */ ibool is_short,/* in: TRUE if short inserts */
byte* ptr, /* in: buffer */ byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */ byte* end_ptr,/* in: buffer end */
buf_block_t* block, /* in: page or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
page_t* page, /* in/out: page 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 */
{ {
ulint origin_offset; ulint origin_offset;
ulint end_seg_len; ulint end_seg_len;
ulint mismatch_index; ulint mismatch_index;
page_t* page;
rec_t* cursor_rec; rec_t* cursor_rec;
byte buf1[1024]; byte buf1[1024];
byte* buf; byte* buf;
byte* ptr2 = ptr; byte* ptr2 = ptr;
ulint info_and_status_bits = 0; /* remove warning */ ulint info_and_status_bits = 0; /* remove warning */
page_cur_t cursor; page_cur_t cursor;
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
...@@ -726,6 +721,8 @@ page_cur_parse_insert_rec( ...@@ -726,6 +721,8 @@ page_cur_parse_insert_rec(
ulint* offsets = offsets_; ulint* offsets = offsets_;
*offsets_ = (sizeof offsets_) / sizeof *offsets_; *offsets_ = (sizeof offsets_) / sizeof *offsets_;
page = block ? buf_block_get_frame(block) : NULL;
if (is_short) { if (is_short) {
cursor_rec = page_rec_get_prev(page_get_supremum_rec(page)); cursor_rec = page_rec_get_prev(page_get_supremum_rec(page));
} else { } else {
...@@ -799,13 +796,13 @@ page_cur_parse_insert_rec( ...@@ -799,13 +796,13 @@ page_cur_parse_insert_rec(
return(NULL); return(NULL);
} }
if (page == NULL) { if (!block) {
return(ptr + (end_seg_len >> 1)); return(ptr + (end_seg_len >> 1));
} }
ut_ad(!!page_is_comp(page) == dict_table_is_comp(index->table)); ut_ad(!!page_is_comp(page) == dict_table_is_comp(index->table));
ut_ad(!page_zip || page_is_comp(page)); ut_ad(!buf_block_get_page_zip(block) || page_is_comp(page));
/* Read from the log the inserted index record end segment which /* Read from the log the inserted index record end segment which
differs from the cursor record */ differs from the cursor record */
...@@ -861,11 +858,11 @@ page_cur_parse_insert_rec( ...@@ -861,11 +858,11 @@ page_cur_parse_insert_rec(
info_and_status_bits); info_and_status_bits);
} }
page_cur_position(cursor_rec, &cursor); page_cur_position(cursor_rec, block, &cursor);
offsets = rec_get_offsets(buf + origin_offset, index, offsets, offsets = rec_get_offsets(buf + origin_offset, index, offsets,
ULINT_UNDEFINED, &heap); ULINT_UNDEFINED, &heap);
if (UNIV_UNLIKELY(!page_cur_rec_insert(&cursor, page_zip, if (UNIV_UNLIKELY(!page_cur_rec_insert(&cursor,
buf + origin_offset, buf + origin_offset,
index, offsets, mtr))) { index, offsets, mtr))) {
/* The redo log record should only have been written /* The redo log record should only have been written
...@@ -896,8 +893,9 @@ page_cur_insert_rec_low( ...@@ -896,8 +893,9 @@ page_cur_insert_rec_low(
/*====================*/ /*====================*/
/* out: pointer to record if succeed, NULL /* out: pointer to record if succeed, NULL
otherwise */ otherwise */
page_cur_t* cursor, /* in: a page cursor */ rec_t* current_rec,/* in: current record after which the
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */ new record is inserted */
page_zip_des_t* page_zip,/* in: compressed page, or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
rec_t* rec, /* in: pointer to a physical record */ rec_t* rec, /* in: pointer to a physical record */
ulint* offsets,/* in/out: rec_get_offsets(rec, index) */ ulint* offsets,/* in/out: rec_get_offsets(rec, index) */
...@@ -905,7 +903,7 @@ page_cur_insert_rec_low( ...@@ -905,7 +903,7 @@ page_cur_insert_rec_low(
{ {
byte* insert_buf = NULL; byte* insert_buf = NULL;
ulint rec_size; ulint rec_size;
byte* page; /* the relevant page */ page_t* page; /* the relevant page */
rec_t* last_insert; /* cursor position at previous rec_t* last_insert; /* cursor position at previous
insert */ insert */
rec_t* free_rec; /* a free record that was reused, rec_t* free_rec; /* a free record that was reused,
...@@ -913,18 +911,15 @@ page_cur_insert_rec_low( ...@@ -913,18 +911,15 @@ page_cur_insert_rec_low(
rec_t* insert_rec; /* inserted record */ rec_t* insert_rec; /* inserted record */
ulint heap_no; /* heap number of the inserted ulint heap_no; /* heap number of the inserted
record */ record */
rec_t* current_rec; /* current record after which the
new record is inserted */
page_zip_des_t* page_zip_orig = page_zip; page_zip_des_t* page_zip_orig = page_zip;
ut_ad(cursor);
ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(rec_offs_validate(rec, index, offsets));
page = page_cur_get_page(cursor); page = page_align(current_rec);
ut_ad(dict_table_is_comp(index->table) ut_ad(dict_table_is_comp(index->table)
== (ibool) !!page_is_comp(page)); == (ibool) !!page_is_comp(page));
ut_ad(!page_rec_is_supremum(cursor->rec)); ut_ad(!page_rec_is_supremum(current_rec));
#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 */
...@@ -1023,7 +1018,6 @@ use_heap: ...@@ -1023,7 +1018,6 @@ use_heap:
rec_offs_make_valid(insert_rec, index, offsets); rec_offs_make_valid(insert_rec, index, offsets);
/* 4. Insert the record in the linked list of records */ /* 4. Insert the record in the linked list of records */
current_rec = cursor->rec;
ut_ad(current_rec != insert_rec); ut_ad(current_rec != insert_rec);
{ {
...@@ -1207,13 +1201,14 @@ page_parse_copy_rec_list_to_created_page( ...@@ -1207,13 +1201,14 @@ page_parse_copy_rec_list_to_created_page(
/* out: end of log record or NULL */ /* out: end of log record or NULL */
byte* ptr, /* in: buffer */ byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */ byte* end_ptr,/* in: buffer end */
buf_block_t* block, /* in: page or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
page_t* page, /* in/out: page 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 */
{ {
byte* rec_end; byte* rec_end;
ulint log_data_len; ulint log_data_len;
page_t* page;
page_zip_des_t* page_zip;
if (ptr + 4 > end_ptr) { if (ptr + 4 > end_ptr) {
...@@ -1230,18 +1225,21 @@ page_parse_copy_rec_list_to_created_page( ...@@ -1230,18 +1225,21 @@ page_parse_copy_rec_list_to_created_page(
return(NULL); return(NULL);
} }
if (!page) { if (!block) {
return(rec_end); return(rec_end);
} }
while (ptr < rec_end) { while (ptr < rec_end) {
ptr = page_cur_parse_insert_rec(TRUE, ptr, end_ptr, ptr = page_cur_parse_insert_rec(TRUE, ptr, end_ptr,
index, page, page_zip, mtr); block, index, mtr);
} }
ut_a(ptr == rec_end); ut_a(ptr == rec_end);
page = buf_block_get_frame(block);
page_zip = buf_block_get_page_zip(block);
page_header_set_ptr(page, page_zip, PAGE_LAST_INSERT, NULL); page_header_set_ptr(page, page_zip, PAGE_LAST_INSERT, NULL);
page_header_set_field(page, page_zip, PAGE_DIRECTION, page_header_set_field(page, page_zip, PAGE_DIRECTION,
PAGE_NO_DIRECTION); PAGE_NO_DIRECTION);
...@@ -1278,7 +1276,7 @@ page_copy_rec_list_end_to_created_page( ...@@ -1278,7 +1276,7 @@ page_copy_rec_list_end_to_created_page(
ulint* offsets = offsets_; ulint* offsets = offsets_;
*offsets_ = (sizeof offsets_) / sizeof *offsets_; *offsets_ = (sizeof offsets_) / sizeof *offsets_;
ut_ad(page_dir_get_n_heap(new_page) == 2); ut_ad(page_dir_get_n_heap(new_page) == PAGE_HEAP_NO_USER_LOW);
ut_ad(page_align(rec) != new_page); ut_ad(page_align(rec) != new_page);
ut_ad(page_rec_is_comp(rec) == page_is_comp(new_page)); ut_ad(page_rec_is_comp(rec) == page_is_comp(new_page));
...@@ -1329,13 +1327,15 @@ page_copy_rec_list_end_to_created_page( ...@@ -1329,13 +1327,15 @@ page_copy_rec_list_end_to_created_page(
page_offset(insert_rec)); page_offset(insert_rec));
rec_set_n_owned_new(insert_rec, NULL, 0); rec_set_n_owned_new(insert_rec, NULL, 0);
rec_set_heap_no_new(insert_rec, 2 + n_recs); rec_set_heap_no_new(insert_rec,
PAGE_HEAP_NO_USER_LOW + n_recs);
} else { } else {
rec_set_next_offs_old(prev_rec, rec_set_next_offs_old(prev_rec,
page_offset(insert_rec)); page_offset(insert_rec));
rec_set_n_owned_old(insert_rec, 0); rec_set_n_owned_old(insert_rec, 0);
rec_set_heap_no_old(insert_rec, 2 + n_recs); rec_set_heap_no_old(insert_rec,
PAGE_HEAP_NO_USER_LOW + n_recs);
} }
count++; count++;
...@@ -1408,7 +1408,7 @@ page_copy_rec_list_end_to_created_page( ...@@ -1408,7 +1408,7 @@ page_copy_rec_list_end_to_created_page(
page_dir_set_n_slots(new_page, NULL, 2 + slot_index); page_dir_set_n_slots(new_page, NULL, 2 + slot_index);
page_header_set_ptr(new_page, NULL, PAGE_HEAP_TOP, heap_top); page_header_set_ptr(new_page, NULL, PAGE_HEAP_TOP, heap_top);
page_dir_set_n_heap(new_page, NULL, 2 + n_recs); page_dir_set_n_heap(new_page, NULL, PAGE_HEAP_NO_USER_LOW + n_recs);
page_header_set_field(new_page, NULL, PAGE_N_RECS, n_recs); page_header_set_field(new_page, NULL, PAGE_N_RECS, n_recs);
page_header_set_ptr(new_page, NULL, PAGE_LAST_INSERT, NULL); page_header_set_ptr(new_page, NULL, PAGE_LAST_INSERT, NULL);
...@@ -1461,9 +1461,8 @@ page_cur_parse_delete_rec( ...@@ -1461,9 +1461,8 @@ page_cur_parse_delete_rec(
/* out: pointer to record end or NULL */ /* out: pointer to record end or NULL */
byte* ptr, /* in: buffer */ byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */ byte* end_ptr,/* in: buffer end */
buf_block_t* block, /* in: page or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
page_t* page, /* in/out: page 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 */
{ {
ulint offset; ulint offset;
...@@ -1480,19 +1479,20 @@ page_cur_parse_delete_rec( ...@@ -1480,19 +1479,20 @@ page_cur_parse_delete_rec(
ut_a(offset <= UNIV_PAGE_SIZE); ut_a(offset <= UNIV_PAGE_SIZE);
if (page) { if (block) {
page_t* page = buf_block_get_frame(block);
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint offsets_[REC_OFFS_NORMAL_SIZE];
rec_t* rec = page + offset; rec_t* rec = page + offset;
*offsets_ = (sizeof offsets_) / sizeof *offsets_; *offsets_ = (sizeof offsets_) / sizeof *offsets_;
page_cur_position(rec, &cursor); page_cur_position(rec, block, &cursor);
ut_ad(!page_zip || page_is_comp(page)); ut_ad(!buf_block_get_page_zip(block) || page_is_comp(page));
page_cur_delete_rec(&cursor, index, page_cur_delete_rec(&cursor, index,
rec_get_offsets(rec, index, offsets_, rec_get_offsets(rec, index, offsets_,
ULINT_UNDEFINED, &heap), ULINT_UNDEFINED, &heap),
page_zip, mtr); mtr);
if (UNIV_LIKELY_NULL(heap)) { if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap); mem_heap_free(heap);
} }
...@@ -1511,12 +1511,12 @@ page_cur_delete_rec( ...@@ -1511,12 +1511,12 @@ page_cur_delete_rec(
page_cur_t* cursor, /* in/out: a page cursor */ page_cur_t* cursor, /* in/out: a page cursor */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
const ulint* offsets,/* in: rec_get_offsets(cursor->rec, index) */ const ulint* offsets,/* in: rec_get_offsets(cursor->rec, index) */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
mtr_t* mtr) /* in: mini-transaction handle */ mtr_t* mtr) /* in: mini-transaction handle */
{ {
page_dir_slot_t* cur_dir_slot; page_dir_slot_t* cur_dir_slot;
page_dir_slot_t* prev_slot; page_dir_slot_t* prev_slot;
page_t* page; page_t* page;
page_zip_des_t* page_zip;
rec_t* current_rec; rec_t* current_rec;
rec_t* prev_rec = NULL; rec_t* prev_rec = NULL;
rec_t* next_rec; rec_t* next_rec;
...@@ -1527,6 +1527,7 @@ page_cur_delete_rec( ...@@ -1527,6 +1527,7 @@ page_cur_delete_rec(
ut_ad(cursor && mtr); ut_ad(cursor && mtr);
page = page_cur_get_page(cursor); page = page_cur_get_page(cursor);
page_zip = page_cur_get_page_zip(cursor);
/* page_zip_validate() may fail here when /* page_zip_validate() may fail here when
btr_cur_pessimistic_delete() invokes btr_set_min_rec_mark(). */ btr_cur_pessimistic_delete() invokes btr_set_min_rec_mark(). */
current_rec = cursor->rec; current_rec = cursor->rec;
......
...@@ -418,7 +418,9 @@ page_create_low( ...@@ -418,7 +418,9 @@ page_create_low(
page_header_set_field(page, NULL, PAGE_N_DIR_SLOTS, 2); page_header_set_field(page, NULL, PAGE_N_DIR_SLOTS, 2);
page_header_set_ptr(page, NULL, PAGE_HEAP_TOP, heap_top); page_header_set_ptr(page, NULL, PAGE_HEAP_TOP, heap_top);
page_header_set_field(page, NULL, PAGE_N_HEAP, comp ? 0x8002 : 2); page_header_set_field(page, NULL, PAGE_N_HEAP, comp
? 0x8000 | PAGE_HEAP_NO_USER_LOW
: PAGE_HEAP_NO_USER_LOW);
page_header_set_ptr(page, NULL, PAGE_FREE, NULL); page_header_set_ptr(page, NULL, PAGE_FREE, NULL);
page_header_set_field(page, NULL, PAGE_GARBAGE, 0); page_header_set_field(page, NULL, PAGE_GARBAGE, 0);
page_header_set_ptr(page, NULL, PAGE_LAST_INSERT, NULL); page_header_set_ptr(page, NULL, PAGE_LAST_INSERT, NULL);
...@@ -427,7 +429,7 @@ page_create_low( ...@@ -427,7 +429,7 @@ page_create_low(
page_header_set_field(page, NULL, PAGE_N_RECS, 0); page_header_set_field(page, NULL, PAGE_N_RECS, 0);
page_set_max_trx_id(page, NULL, ut_dulint_zero); page_set_max_trx_id(page, NULL, ut_dulint_zero);
memset(heap_top, 0, UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START memset(heap_top, 0, UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START
- (heap_top - page)); - page_offset(heap_top));
/* 5. SET POINTERS IN RECORDS AND DIR SLOTS */ /* 5. SET POINTERS IN RECORDS AND DIR SLOTS */
...@@ -506,19 +508,21 @@ touch the lock table and max trx id on page or compress the page. */ ...@@ -506,19 +508,21 @@ touch the lock table and max trx id on page or compress the page. */
void void
page_copy_rec_list_end_no_locks( page_copy_rec_list_end_no_locks(
/*============================*/ /*============================*/
page_t* new_page, /* in: index page to copy to */ buf_block_t* new_block, /* in: index page to copy to */
buf_block_t* block, /* in: index page of rec */
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_cur_t cur1; page_cur_t cur1;
page_cur_t cur2; rec_t* cur2;
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint offsets_[REC_OFFS_NORMAL_SIZE];
ulint* offsets = offsets_; ulint* offsets = offsets_;
*offsets_ = (sizeof offsets_) / sizeof *offsets_; *offsets_ = (sizeof offsets_) / sizeof *offsets_;
page_cur_position(rec, &cur1); page_cur_position(rec, block, &cur1);
if (page_cur_is_before_first(&cur1)) { if (page_cur_is_before_first(&cur1)) {
...@@ -531,16 +535,18 @@ page_copy_rec_list_end_no_locks( ...@@ -531,16 +535,18 @@ page_copy_rec_list_end_no_locks(
ut_a(mach_read_from_2(new_page + UNIV_PAGE_SIZE - 10) == (ulint) ut_a(mach_read_from_2(new_page + UNIV_PAGE_SIZE - 10) == (ulint)
(page_is_comp(new_page) ? PAGE_NEW_INFIMUM : PAGE_OLD_INFIMUM)); (page_is_comp(new_page) ? PAGE_NEW_INFIMUM : PAGE_OLD_INFIMUM));
page_cur_set_before_first(new_page, &cur2); cur2 = page_get_infimum_rec(buf_block_get_frame(new_block));
/* Copy records from the original page to the new page */ /* Copy records from the original page to the new page */
while (!page_cur_is_after_last(&cur1)) { while (!page_cur_is_after_last(&cur1)) {
rec_t* cur1_rec = page_cur_get_rec(&cur1); rec_t* cur1_rec = page_cur_get_rec(&cur1);
rec_t* ins_rec;
offsets = rec_get_offsets(cur1_rec, index, offsets, offsets = rec_get_offsets(cur1_rec, index, offsets,
ULINT_UNDEFINED, &heap); ULINT_UNDEFINED, &heap);
if (UNIV_UNLIKELY(!page_cur_rec_insert(&cur2, NULL, cur1_rec, ins_rec = page_cur_insert_rec_low(cur2, NULL, index,
index, offsets, mtr))) { cur1_rec, offsets, mtr);
if (UNIV_UNLIKELY(!ins_rec)) {
/* Track an assertion failure reported on the mailing /* Track an assertion failure reported on the mailing
list on June 18th, 2003 */ list on June 18th, 2003 */
...@@ -553,12 +559,12 @@ page_copy_rec_list_end_no_locks( ...@@ -553,12 +559,12 @@ page_copy_rec_list_end_no_locks(
" cur2 offset %lu\n", " cur2 offset %lu\n",
(ulong) page_offset(rec), (ulong) page_offset(rec),
(ulong) page_offset(page_cur_get_rec(&cur1)), (ulong) page_offset(page_cur_get_rec(&cur1)),
(ulong) page_offset(page_cur_get_rec(&cur2))); (ulong) page_offset(cur2));
ut_error; ut_error;
} }
page_cur_move_to_next(&cur1); page_cur_move_to_next(&cur1);
page_cur_move_to_next(&cur2); cur2 = ins_rec;
} }
if (UNIV_LIKELY_NULL(heap)) { if (UNIV_LIKELY_NULL(heap)) {
...@@ -577,9 +583,9 @@ page_copy_rec_list_end( ...@@ -577,9 +583,9 @@ page_copy_rec_list_end(
/* out: pointer to the original /* out: pointer to the original
successor of the infimum record successor of the infimum record
on new_page, or NULL on zip overflow on new_page, or NULL on zip overflow
(new_page will be decompressed (new_block will be decompressed) */
from new_page_zip) */
buf_block_t* new_block, /* in/out: index page to copy to */ buf_block_t* new_block, /* in/out: index page to copy to */
buf_block_t* block, /* in: index page containing rec */
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 */
...@@ -593,6 +599,7 @@ page_copy_rec_list_end( ...@@ -593,6 +599,7 @@ page_copy_rec_list_end(
/* 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 */
ut_ad(buf_block_get_frame(block) == page);
ut_ad(page_is_leaf(page) == page_is_leaf(new_page)); ut_ad(page_is_leaf(page) == page_is_leaf(new_page));
ut_ad(page_is_comp(page) == page_is_comp(new_page)); ut_ad(page_is_comp(page) == page_is_comp(new_page));
...@@ -600,11 +607,12 @@ page_copy_rec_list_end( ...@@ -600,11 +607,12 @@ page_copy_rec_list_end(
log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE); log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE);
} }
if (page_dir_get_n_heap(new_page) == 2) { if (page_dir_get_n_heap(new_page) == PAGE_HEAP_NO_USER_LOW) {
page_copy_rec_list_end_to_created_page(new_page, rec, page_copy_rec_list_end_to_created_page(new_page, rec,
index, mtr); index, mtr);
} else { } else {
page_copy_rec_list_end_no_locks(new_page, rec, index, mtr); page_copy_rec_list_end_no_locks(new_block, block, rec,
index, mtr);
} }
if (UNIV_LIKELY_NULL(new_page_zip)) { if (UNIV_LIKELY_NULL(new_page_zip)) {
...@@ -646,7 +654,7 @@ page_copy_rec_list_end( ...@@ -646,7 +654,7 @@ page_copy_rec_list_end(
page_update_max_trx_id(new_page, new_page_zip, page_update_max_trx_id(new_page, new_page_zip,
page_get_max_trx_id(page)); page_get_max_trx_id(page));
btr_search_move_or_delete_hash_entries(new_page, page, index); btr_search_move_or_delete_hash_entries(new_block, block, index);
return(ret); return(ret);
} }
...@@ -662,9 +670,9 @@ page_copy_rec_list_start( ...@@ -662,9 +670,9 @@ page_copy_rec_list_start(
/* out: pointer to the original /* out: pointer to the original
predecessor of the supremum record predecessor of the supremum record
on new_page, or NULL on zip overflow on new_page, or NULL on zip overflow
(new_page will be decompressed (new_block will be decompressed) */
from new_page_zip) */
buf_block_t* new_block, /* in/out: index page to copy to */ buf_block_t* new_block, /* in/out: index page to copy to */
buf_block_t* block, /* in: index page containing rec */
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 */
...@@ -672,8 +680,7 @@ page_copy_rec_list_start( ...@@ -672,8 +680,7 @@ page_copy_rec_list_start(
page_t* new_page = buf_block_get_frame(new_block); 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_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; rec_t* cur2;
page_t* page;
ulint log_mode = 0 /* remove warning */; ulint log_mode = 0 /* remove warning */;
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
rec_t* ret rec_t* ret
...@@ -691,26 +698,22 @@ page_copy_rec_list_start( ...@@ -691,26 +698,22 @@ page_copy_rec_list_start(
log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE); log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE);
} }
page = page_align(rec); page_cur_set_before_first(block, &cur1);
page_cur_set_before_first(page, &cur1);
page_cur_move_to_next(&cur1); page_cur_move_to_next(&cur1);
page_cur_position(ret, &cur2); cur2 = ret;
/* Copy records from the original page to the new page */ /* Copy records from the original page to the new page */
while (page_cur_get_rec(&cur1) != rec) { while (page_cur_get_rec(&cur1) != rec) {
rec_t* ins_rec;
rec_t* cur1_rec = page_cur_get_rec(&cur1); rec_t* cur1_rec = page_cur_get_rec(&cur1);
offsets = rec_get_offsets(cur1_rec, index, offsets, offsets = rec_get_offsets(cur1_rec, index, offsets,
ULINT_UNDEFINED, &heap); ULINT_UNDEFINED, &heap);
ins_rec = page_cur_rec_insert(&cur2, NULL, cur1_rec, cur2 = page_cur_insert_rec_low(cur2, NULL, index,
index, offsets, mtr); cur1_rec, offsets, mtr);
ut_a(ins_rec); ut_a(cur2);
page_cur_move_to_next(&cur1); page_cur_move_to_next(&cur1);
page_cur_move_to_next(&cur2);
} }
if (UNIV_LIKELY_NULL(heap)) { if (UNIV_LIKELY_NULL(heap)) {
...@@ -752,11 +755,11 @@ page_copy_rec_list_start( ...@@ -752,11 +755,11 @@ page_copy_rec_list_start(
/* Update MAX_TRX_ID, the lock table, and possible hash index */ /* Update MAX_TRX_ID, the lock table, and possible hash index */
page_update_max_trx_id(new_page, new_page_zip, page_update_max_trx_id(new_page, new_page_zip,
page_get_max_trx_id(page)); page_get_max_trx_id(page_align(rec)));
lock_move_rec_list_start(new_page, page, rec, ret); lock_move_rec_list_start(new_page, page_align(rec), rec, ret);
btr_search_move_or_delete_hash_entries(new_page, page, index); btr_search_move_or_delete_hash_entries(new_block, block, index);
return(ret); return(ret);
} }
...@@ -800,12 +803,12 @@ page_parse_delete_rec_list( ...@@ -800,12 +803,12 @@ page_parse_delete_rec_list(
MLOG_COMP_LIST_START_DELETE */ MLOG_COMP_LIST_START_DELETE */
byte* ptr, /* in: buffer */ byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */ byte* end_ptr,/* in: buffer end */
buf_block_t* block, /* in/out: buffer block or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
page_t* page, /* in/out: page 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 */
{ {
ulint offset; page_t* page;
ulint offset;
ut_ad(type == MLOG_LIST_END_DELETE ut_ad(type == MLOG_LIST_END_DELETE
|| type == MLOG_LIST_START_DELETE || type == MLOG_LIST_START_DELETE
...@@ -822,21 +825,22 @@ page_parse_delete_rec_list( ...@@ -822,21 +825,22 @@ page_parse_delete_rec_list(
offset = mach_read_from_2(ptr); offset = mach_read_from_2(ptr);
ptr += 2; ptr += 2;
if (!page) { if (!block) {
return(ptr); return(ptr);
} }
page = buf_block_get_frame(block);
ut_ad(!!page_is_comp(page) == dict_table_is_comp(index->table)); ut_ad(!!page_is_comp(page) == dict_table_is_comp(index->table));
if (type == MLOG_LIST_END_DELETE if (type == MLOG_LIST_END_DELETE
|| type == MLOG_COMP_LIST_END_DELETE) { || type == MLOG_COMP_LIST_END_DELETE) {
page_delete_rec_list_end(page + offset, index, page_delete_rec_list_end(page + offset, block, index,
ULINT_UNDEFINED, ULINT_UNDEFINED, ULINT_UNDEFINED, ULINT_UNDEFINED,
page_zip, mtr); mtr);
} else { } else {
page_delete_rec_list_start(page + offset, index, page_delete_rec_list_start(page + offset, block, index, mtr);
page_zip, mtr);
} }
return(ptr); return(ptr);
...@@ -850,13 +854,13 @@ void ...@@ -850,13 +854,13 @@ void
page_delete_rec_list_end( page_delete_rec_list_end(
/*=====================*/ /*=====================*/
rec_t* rec, /* in: pointer to record on page */ rec_t* rec, /* in: pointer to record on page */
buf_block_t* block, /* in: buffer block of the page */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
ulint n_recs, /* in: number of records to delete, ulint n_recs, /* in: number of records to delete,
or ULINT_UNDEFINED if not known */ or ULINT_UNDEFINED if not known */
ulint size, /* in: the sum of the sizes of the ulint size, /* in: the sum of the sizes of the
records in the end of the chain to records in the end of the chain to
delete, or ULINT_UNDEFINED if not known */ delete, or ULINT_UNDEFINED if not known */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
page_dir_slot_t*slot; page_dir_slot_t*slot;
...@@ -864,6 +868,7 @@ page_delete_rec_list_end( ...@@ -864,6 +868,7 @@ page_delete_rec_list_end(
rec_t* last_rec; rec_t* last_rec;
rec_t* prev_rec; rec_t* prev_rec;
ulint n_owned; ulint n_owned;
page_zip_des_t* page_zip = buf_block_get_page_zip(block);
page_t* page = page_align(rec); page_t* page = page_align(rec);
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint offsets_[REC_OFFS_NORMAL_SIZE];
...@@ -893,7 +898,7 @@ page_delete_rec_list_end( ...@@ -893,7 +898,7 @@ page_delete_rec_list_end(
/* The page gets invalid for optimistic searches: increment the /* The page gets invalid for optimistic searches: increment the
frame modify clock */ frame modify clock */
buf_block_modify_clock_inc(buf_block_align(page)/*TODO*/); buf_block_modify_clock_inc(block);
page_delete_rec_list_write_log(rec, index, page_is_comp(page) page_delete_rec_list_write_log(rec, index, page_is_comp(page)
? MLOG_COMP_LIST_END_DELETE ? MLOG_COMP_LIST_END_DELETE
...@@ -909,7 +914,7 @@ page_delete_rec_list_end( ...@@ -909,7 +914,7 @@ page_delete_rec_list_end(
do { do {
page_cur_t cur; page_cur_t cur;
page_cur_position(rec, &cur); page_cur_position(rec, block, &cur);
offsets = rec_get_offsets(rec, index, offsets, offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &heap); ULINT_UNDEFINED, &heap);
...@@ -917,8 +922,7 @@ page_delete_rec_list_end( ...@@ -917,8 +922,7 @@ page_delete_rec_list_end(
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page)); ut_a(page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
page_cur_delete_rec(&cur, index, offsets, page_cur_delete_rec(&cur, index, offsets, mtr);
page_zip, mtr);
} while (page_offset(rec) != PAGE_NEW_SUPREMUM); } while (page_offset(rec) != PAGE_NEW_SUPREMUM);
if (UNIV_LIKELY_NULL(heap)) { if (UNIV_LIKELY_NULL(heap)) {
...@@ -1026,8 +1030,8 @@ void ...@@ -1026,8 +1030,8 @@ void
page_delete_rec_list_start( page_delete_rec_list_start(
/*=======================*/ /*=======================*/
rec_t* rec, /* in: record on page */ rec_t* rec, /* in: record on page */
buf_block_t* block, /* in: buffer block of the page */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
page_zip_des_t* page_zip,/* in/out: compressed page of rec, or NULL */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
page_cur_t cur1; page_cur_t cur1;
...@@ -1059,7 +1063,7 @@ page_delete_rec_list_start( ...@@ -1059,7 +1063,7 @@ page_delete_rec_list_start(
page_delete_rec_list_write_log(rec, index, type, mtr); page_delete_rec_list_write_log(rec, index, type, mtr);
page_cur_set_before_first(page_align(rec), &cur1); page_cur_set_before_first(block, &cur1);
page_cur_move_to_next(&cur1); page_cur_move_to_next(&cur1);
/* Individual deletes are not logged */ /* Individual deletes are not logged */
...@@ -1069,7 +1073,7 @@ page_delete_rec_list_start( ...@@ -1069,7 +1073,7 @@ page_delete_rec_list_start(
while (page_cur_get_rec(&cur1) != rec) { while (page_cur_get_rec(&cur1) != rec) {
offsets = rec_get_offsets(page_cur_get_rec(&cur1), index, offsets = rec_get_offsets(page_cur_get_rec(&cur1), index,
offsets, ULINT_UNDEFINED, &heap); offsets, ULINT_UNDEFINED, &heap);
page_cur_delete_rec(&cur1, index, offsets, page_zip, mtr); page_cur_delete_rec(&cur1, index, offsets, mtr);
} }
if (UNIV_LIKELY_NULL(heap)) { if (UNIV_LIKELY_NULL(heap)) {
...@@ -1089,19 +1093,15 @@ ibool ...@@ -1089,19 +1093,15 @@ ibool
page_move_rec_list_end( page_move_rec_list_end(
/*===================*/ /*===================*/
/* out: TRUE on success; FALSE on /* out: TRUE on success; FALSE on
compression failure (new_page will compression failure
be decompressed from new_page_zip) */ (new_block will be decompressed) */
buf_block_t* new_block, /* in/out: index page where to move */ buf_block_t* new_block, /* in/out: index page where to move */
buf_block_t* block, /* in: index page from where to move */
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
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 */
{ {
page_t* new_page = buf_block_get_frame(new_block); page_t* new_page = buf_block_get_frame(new_block);
#ifdef UNIV_ZIP_DEBUG
page_zip_des_t* new_page_zip = buf_block_get_page_zip(new_block);
#endif /* UNIV_ZIP_DEBUG */
ulint old_data_size; ulint old_data_size;
ulint new_data_size; ulint new_data_size;
ulint old_n_recs; ulint old_n_recs;
...@@ -1110,12 +1110,21 @@ page_move_rec_list_end( ...@@ -1110,12 +1110,21 @@ page_move_rec_list_end(
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);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!new_page_zip || page_zip_validate(new_page_zip, new_page)); {
ut_a(!page_zip || page_zip_validate(page_zip, page_align(split_rec))); page_zip_des_t* new_page_zip
= buf_block_get_page_zip(new_block);
page_zip_des_t* page_zip
= buf_block_get_page_zip(block);
ut_a(!new_page_zip == !page_zip);
ut_a(!new_page_zip
|| page_zip_validate(new_page_zip, new_page));
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_block, split_rec, if (UNIV_UNLIKELY(!page_copy_rec_list_end(new_block, block,
index, mtr))) { split_rec, index, mtr))) {
return(FALSE); return(FALSE);
} }
...@@ -1124,10 +1133,9 @@ page_move_rec_list_end( ...@@ -1124,10 +1133,9 @@ page_move_rec_list_end(
ut_ad(new_data_size >= old_data_size); ut_ad(new_data_size >= old_data_size);
page_delete_rec_list_end(split_rec, index, page_delete_rec_list_end(split_rec, block, index,
new_n_recs - old_n_recs, new_n_recs - old_n_recs,
new_data_size - old_data_size, new_data_size - old_data_size, mtr);
page_zip, mtr);
return(TRUE); return(TRUE);
} }
...@@ -1142,18 +1150,17 @@ page_move_rec_list_start( ...@@ -1142,18 +1150,17 @@ page_move_rec_list_start(
/* out: TRUE on success; FALSE on /* out: TRUE on success; FALSE on
compression failure */ compression failure */
buf_block_t* new_block, /* in/out: index page where to move */ buf_block_t* new_block, /* in/out: index page where to move */
buf_block_t* block, /* in/out: page containing split_rec */
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
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_block, split_rec, if (UNIV_UNLIKELY(!page_copy_rec_list_start(new_block, block,
index, mtr))) { split_rec, index, mtr))) {
return(FALSE); return(FALSE);
} }
page_delete_rec_list_start(split_rec, index, page_zip, mtr); page_delete_rec_list_start(split_rec, block, index, mtr);
return(TRUE); return(TRUE);
} }
...@@ -1408,7 +1415,7 @@ page_get_middle_rec( ...@@ -1408,7 +1415,7 @@ page_get_middle_rec(
rec_t* rec; rec_t* rec;
/* This many records we must leave behind */ /* This many records we must leave behind */
middle = (page_get_n_recs(page) + 2) / 2; middle = (page_get_n_recs(page) + PAGE_HEAP_NO_USER_LOW) / 2;
count = 0; count = 0;
...@@ -1552,7 +1559,7 @@ page_dir_print( ...@@ -1552,7 +1559,7 @@ page_dir_print(
"PAGE DIRECTORY\n" "PAGE DIRECTORY\n"
"Page address %p\n" "Page address %p\n"
"Directory stack top at offs: %lu; number of slots: %lu\n", "Directory stack top at offs: %lu; number of slots: %lu\n",
page, (ulong)(page_dir_get_nth_slot(page, n - 1) - page), page, (ulong) page_offset(page_dir_get_nth_slot(page, n - 1)),
(ulong) n); (ulong) n);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
slot = page_dir_get_nth_slot(page, i); slot = page_dir_get_nth_slot(page, i);
...@@ -1565,12 +1572,13 @@ page_dir_print( ...@@ -1565,12 +1572,13 @@ page_dir_print(
" rec offs: %lu\n", " rec offs: %lu\n",
(ulong) i, (ulong) i,
(ulong) page_dir_slot_get_n_owned(slot), (ulong) page_dir_slot_get_n_owned(slot),
(ulong)(page_dir_slot_get_rec(slot) - page)); (ulong)
page_offset(page_dir_slot_get_rec(slot)));
} }
} }
fprintf(stderr, "Total of %lu records\n" fprintf(stderr, "Total of %lu records\n"
"--------------------------------\n", "--------------------------------\n",
(ulong) (2 + page_get_n_recs(page))); (ulong) (PAGE_HEAP_NO_USER_LOW + page_get_n_recs(page)));
} }
/******************************************************************* /*******************************************************************
...@@ -1580,10 +1588,11 @@ debugging purposes. */ ...@@ -1580,10 +1588,11 @@ debugging purposes. */
void void
page_print_list( page_print_list(
/*============*/ /*============*/
page_t* page, /* in: index page */ buf_block_t* block, /* in: index page */
dict_index_t* index, /* in: dictionary index of the page */ dict_index_t* index, /* in: dictionary index of the page */
ulint pr_n) /* in: print n first and n last entries */ ulint pr_n) /* in: print n first and n last entries */
{ {
page_t* page = block->frame;
page_cur_t cur; page_cur_t cur;
ulint count; ulint count;
ulint n_recs; ulint n_recs;
...@@ -1601,7 +1610,7 @@ page_print_list( ...@@ -1601,7 +1610,7 @@ page_print_list(
n_recs = page_get_n_recs(page); n_recs = page_get_n_recs(page);
page_cur_set_before_first(page, &cur); page_cur_set_before_first(block, &cur);
count = 0; count = 0;
for (;;) { for (;;) {
offsets = rec_get_offsets(cur.rec, index, offsets, offsets = rec_get_offsets(cur.rec, index, offsets,
...@@ -1649,7 +1658,7 @@ Prints the info in a page header. */ ...@@ -1649,7 +1658,7 @@ Prints the info in a page header. */
void void
page_header_print( page_header_print(
/*==============*/ /*==============*/
page_t* page) const page_t* page)
{ {
fprintf(stderr, fprintf(stderr,
"--------------------------------\n" "--------------------------------\n"
...@@ -1677,16 +1686,18 @@ debugging purposes. */ ...@@ -1677,16 +1686,18 @@ debugging purposes. */
void void
page_print( page_print(
/*=======*/ /*=======*/
page_t* page, /* in: index page */ buf_block_t* block, /* in: index page */
dict_index_t* index, /* in: dictionary index of the page */ dict_index_t* index, /* in: dictionary index of the page */
ulint dn, /* in: print dn first and last entries ulint dn, /* in: print dn first and last entries
in directory */ in directory */
ulint rn) /* in: print rn first and last records ulint rn) /* in: print rn first and last records
in directory */ in directory */
{ {
page_t* page = block->frame;
page_header_print(page); page_header_print(page);
page_dir_print(page, dn); page_dir_print(page, dn);
page_print_list(page, index, rn); page_print_list(block, index, rn);
} }
/******************************************************************* /*******************************************************************
...@@ -1722,14 +1733,14 @@ page_rec_validate( ...@@ -1722,14 +1733,14 @@ page_rec_validate(
if (UNIV_UNLIKELY(!(n_owned <= PAGE_DIR_SLOT_MAX_N_OWNED))) { if (UNIV_UNLIKELY(!(n_owned <= PAGE_DIR_SLOT_MAX_N_OWNED))) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Dir slot of rec %lu, n owned too big %lu\n", "InnoDB: Dir slot of rec %lu, n owned too big %lu\n",
(ulong)(rec - page), (ulong) n_owned); (ulong) page_offset(rec), (ulong) n_owned);
return(FALSE); return(FALSE);
} }
if (UNIV_UNLIKELY(!(heap_no < page_dir_get_n_heap(page)))) { if (UNIV_UNLIKELY(!(heap_no < page_dir_get_n_heap(page)))) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Heap no of rec %lu too big %lu %lu\n", "InnoDB: Heap no of rec %lu too big %lu %lu\n",
(ulong)(rec - page), (ulong) heap_no, (ulong) page_offset(rec), (ulong) heap_no,
(ulong) page_dir_get_n_heap(page)); (ulong) page_dir_get_n_heap(page));
return(FALSE); return(FALSE);
} }
...@@ -1782,7 +1793,6 @@ page_simple_validate_old( ...@@ -1782,7 +1793,6 @@ page_simple_validate_old(
/* out: TRUE if ok */ /* out: TRUE if ok */
page_t* page) /* in: old-style index page */ page_t* page) /* in: old-style index page */
{ {
page_cur_t cur;
page_dir_slot_t* slot; page_dir_slot_t* slot;
ulint slot_no; ulint slot_no;
ulint n_slots; ulint n_slots;
...@@ -1815,10 +1825,9 @@ page_simple_validate_old( ...@@ -1815,10 +1825,9 @@ page_simple_validate_old(
fprintf(stderr, fprintf(stderr,
"InnoDB: Record heap and dir overlap on a page," "InnoDB: Record heap and dir overlap on a page,"
" heap top %lu, dir %lu\n", " heap top %lu, dir %lu\n",
(ulong) page_header_get_field(page, PAGE_HEAP_TOP),
(ulong) (ulong)
(page_header_get_ptr(page, PAGE_HEAP_TOP) - page), page_offset(page_dir_get_nth_slot(page, n_slots - 1)));
(ulong)
(page_dir_get_nth_slot(page, n_slots - 1) - page));
goto func_exit; goto func_exit;
} }
...@@ -1831,11 +1840,9 @@ page_simple_validate_old( ...@@ -1831,11 +1840,9 @@ page_simple_validate_old(
slot_no = 0; slot_no = 0;
slot = page_dir_get_nth_slot(page, slot_no); slot = page_dir_get_nth_slot(page, slot_no);
page_cur_set_before_first(page, &cur); rec = page_get_infimum_rec(page);
for (;;) { for (;;) {
rec = (&cur)->rec;
if (UNIV_UNLIKELY(rec > rec_heap_top)) { if (UNIV_UNLIKELY(rec > rec_heap_top)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Record %lu is above" "InnoDB: Record %lu is above"
...@@ -1873,13 +1880,13 @@ page_simple_validate_old( ...@@ -1873,13 +1880,13 @@ page_simple_validate_old(
own_count = 0; own_count = 0;
if (!page_cur_is_after_last(&cur)) { if (!page_rec_is_supremum(rec)) {
slot_no++; slot_no++;
slot = page_dir_get_nth_slot(page, slot_no); slot = page_dir_get_nth_slot(page, slot_no);
} }
} }
if (page_cur_is_after_last(&cur)) { if (page_rec_is_supremum(rec)) {
break; break;
} }
...@@ -1906,7 +1913,7 @@ page_simple_validate_old( ...@@ -1906,7 +1913,7 @@ page_simple_validate_old(
goto func_exit; goto func_exit;
} }
page_cur_move_to_next(&cur); rec = page_rec_get_next(rec);
own_count++; own_count++;
} }
...@@ -1922,10 +1929,12 @@ page_simple_validate_old( ...@@ -1922,10 +1929,12 @@ page_simple_validate_old(
goto func_exit; goto func_exit;
} }
if (UNIV_UNLIKELY(page_header_get_field(page, PAGE_N_RECS) + 2 if (UNIV_UNLIKELY(page_header_get_field(page, PAGE_N_RECS)
+ PAGE_HEAP_NO_USER_LOW
!= count + 1)) { != count + 1)) {
fprintf(stderr, "InnoDB: n recs wrong %lu %lu\n", fprintf(stderr, "InnoDB: n recs wrong %lu %lu\n",
(ulong) page_header_get_field(page, PAGE_N_RECS) + 2, (ulong) page_header_get_field(page, PAGE_N_RECS)
+ PAGE_HEAP_NO_USER_LOW,
(ulong) (count + 1)); (ulong) (count + 1));
goto func_exit; goto func_exit;
...@@ -1994,7 +2003,6 @@ page_simple_validate_new( ...@@ -1994,7 +2003,6 @@ page_simple_validate_new(
/* out: TRUE if ok */ /* out: TRUE if ok */
page_t* page) /* in: new-style index page */ page_t* page) /* in: new-style index page */
{ {
page_cur_t cur;
page_dir_slot_t* slot; page_dir_slot_t* slot;
ulint slot_no; ulint slot_no;
ulint n_slots; ulint n_slots;
...@@ -2027,10 +2035,9 @@ page_simple_validate_new( ...@@ -2027,10 +2035,9 @@ page_simple_validate_new(
fprintf(stderr, fprintf(stderr,
"InnoDB: Record heap and dir overlap on a page," "InnoDB: Record heap and dir overlap on a page,"
" heap top %lu, dir %lu\n", " heap top %lu, dir %lu\n",
(ulong) page_header_get_field(page, PAGE_HEAP_TOP),
(ulong) (ulong)
(page_header_get_ptr(page, PAGE_HEAP_TOP) - page), page_offset(page_dir_get_nth_slot(page, n_slots - 1)));
(ulong)
(page_dir_get_nth_slot(page, n_slots - 1) - page));
goto func_exit; goto func_exit;
} }
...@@ -2043,17 +2050,15 @@ page_simple_validate_new( ...@@ -2043,17 +2050,15 @@ page_simple_validate_new(
slot_no = 0; slot_no = 0;
slot = page_dir_get_nth_slot(page, slot_no); slot = page_dir_get_nth_slot(page, slot_no);
page_cur_set_before_first(page, &cur); rec = page_get_infimum_rec(page);
for (;;) { for (;;) {
rec = (&cur)->rec;
if (UNIV_UNLIKELY(rec > rec_heap_top)) { if (UNIV_UNLIKELY(rec > rec_heap_top)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Record %lu is above rec" "InnoDB: Record %lu is above rec"
" heap top %lu\n", " heap top %lu\n",
(ulong) (rec - page), (ulong) page_offset(rec),
(ulong) (rec_heap_top - page)); (ulong) page_offset(rec_heap_top));
goto func_exit; goto func_exit;
} }
...@@ -2068,7 +2073,7 @@ page_simple_validate_new( ...@@ -2068,7 +2073,7 @@ page_simple_validate_new(
" rec %lu\n", " rec %lu\n",
(ulong) rec_get_n_owned_new(rec), (ulong) rec_get_n_owned_new(rec),
(ulong) own_count, (ulong) own_count,
(ulong)(rec - page)); (ulong) page_offset(rec));
goto func_exit; goto func_exit;
} }
...@@ -2078,20 +2083,20 @@ page_simple_validate_new( ...@@ -2078,20 +2083,20 @@ page_simple_validate_new(
fprintf(stderr, fprintf(stderr,
"InnoDB: Dir slot does not point" "InnoDB: Dir slot does not point"
" to right rec %lu\n", " to right rec %lu\n",
(ulong)(rec - page)); (ulong) page_offset(rec));
goto func_exit; goto func_exit;
} }
own_count = 0; own_count = 0;
if (!page_cur_is_after_last(&cur)) { if (!page_rec_is_supremum(rec)) {
slot_no++; slot_no++;
slot = page_dir_get_nth_slot(page, slot_no); slot = page_dir_get_nth_slot(page, slot_no);
} }
} }
if (page_cur_is_after_last(&cur)) { if (page_rec_is_supremum(rec)) {
break; break;
} }
...@@ -2103,7 +2108,7 @@ page_simple_validate_new( ...@@ -2103,7 +2108,7 @@ page_simple_validate_new(
"InnoDB: Next record offset nonsensical %lu" "InnoDB: Next record offset nonsensical %lu"
" for rec %lu\n", " for rec %lu\n",
(ulong) rec_get_next_offs(rec, TRUE), (ulong) rec_get_next_offs(rec, TRUE),
(ulong)(rec - page)); (ulong) page_offset(rec));
goto func_exit; goto func_exit;
} }
...@@ -2118,7 +2123,7 @@ page_simple_validate_new( ...@@ -2118,7 +2123,7 @@ page_simple_validate_new(
goto func_exit; goto func_exit;
} }
page_cur_move_to_next(&cur); rec = page_rec_get_next(rec);
own_count++; own_count++;
} }
...@@ -2135,10 +2140,12 @@ page_simple_validate_new( ...@@ -2135,10 +2140,12 @@ page_simple_validate_new(
goto func_exit; goto func_exit;
} }
if (UNIV_UNLIKELY(page_header_get_field(page, PAGE_N_RECS) + 2 if (UNIV_UNLIKELY(page_header_get_field(page, PAGE_N_RECS)
+ PAGE_HEAP_NO_USER_LOW
!= count + 1)) { != count + 1)) {
fprintf(stderr, "InnoDB: n recs wrong %lu %lu\n", fprintf(stderr, "InnoDB: n recs wrong %lu %lu\n",
(ulong) page_header_get_field(page, PAGE_N_RECS) + 2, (ulong) page_header_get_field(page, PAGE_N_RECS)
+ PAGE_HEAP_NO_USER_LOW,
(ulong) (count + 1)); (ulong) (count + 1));
goto func_exit; goto func_exit;
...@@ -2153,7 +2160,7 @@ page_simple_validate_new( ...@@ -2153,7 +2160,7 @@ page_simple_validate_new(
fprintf(stderr, fprintf(stderr,
"InnoDB: Free list record has" "InnoDB: Free list record has"
" a nonsensical offset %lu\n", " a nonsensical offset %lu\n",
(ulong) (rec - page)); (ulong) page_offset(rec));
goto func_exit; goto func_exit;
} }
...@@ -2162,8 +2169,8 @@ page_simple_validate_new( ...@@ -2162,8 +2169,8 @@ page_simple_validate_new(
fprintf(stderr, fprintf(stderr,
"InnoDB: Free list record %lu" "InnoDB: Free list record %lu"
" is above rec heap top %lu\n", " is above rec heap top %lu\n",
(ulong) (rec - page), (ulong) page_offset(rec),
(ulong) (rec_heap_top - page)); (ulong) page_offset(rec_heap_top));
goto func_exit; goto func_exit;
} }
...@@ -2207,9 +2214,8 @@ page_validate( ...@@ -2207,9 +2214,8 @@ page_validate(
dict_index_t* index) /* in: data dictionary index containing dict_index_t* index) /* in: data dictionary index containing
the page record type definition */ the page record type definition */
{ {
page_dir_slot_t* slot; page_dir_slot_t*slot;
mem_heap_t* heap; mem_heap_t* heap;
page_cur_t cur;
byte* buf; byte* buf;
ulint count; ulint count;
ulint own_count; ulint own_count;
...@@ -2274,10 +2280,9 @@ page_validate( ...@@ -2274,10 +2280,9 @@ page_validate(
slot_no = 0; slot_no = 0;
slot = page_dir_get_nth_slot(page, slot_no); slot = page_dir_get_nth_slot(page, slot_no);
page_cur_set_before_first(page, &cur); rec = page_get_infimum_rec(page);
for (;;) { for (;;) {
rec = cur.rec;
offsets = rec_get_offsets(rec, index, offsets, offsets = rec_get_offsets(rec, index, offsets,
ULINT_UNDEFINED, &heap); ULINT_UNDEFINED, &heap);
...@@ -2293,8 +2298,8 @@ page_validate( ...@@ -2293,8 +2298,8 @@ page_validate(
} }
/* Check that the records are in the ascending order */ /* Check that the records are in the ascending order */
if (UNIV_LIKELY(count >= 2) if (UNIV_LIKELY(count >= PAGE_HEAP_NO_USER_LOW)
&& (!page_cur_is_after_last(&cur))) { && !page_rec_is_supremum(rec)) {
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(1 != cmp_rec_rec(rec, old_rec, (1 != cmp_rec_rec(rec, old_rec,
offsets, old_offsets, index))) { offsets, old_offsets, index))) {
...@@ -2318,7 +2323,7 @@ page_validate( ...@@ -2318,7 +2323,7 @@ page_validate(
data_size += rec_offs_size(offsets); data_size += rec_offs_size(offsets);
} }
offs = rec_get_start(rec, offsets) - page; offs = page_offset(rec_get_start(rec, offsets));
for (i = rec_offs_size(offsets); i--; ) { for (i = rec_offs_size(offsets); i--; ) {
if (UNIV_UNLIKELY(buf[offs + i])) { if (UNIV_UNLIKELY(buf[offs + i])) {
...@@ -2358,20 +2363,21 @@ page_validate( ...@@ -2358,20 +2363,21 @@ page_validate(
page_dir_slot_check(slot); page_dir_slot_check(slot);
own_count = 0; own_count = 0;
if (!page_cur_is_after_last(&cur)) { if (!page_rec_is_supremum(rec)) {
slot_no++; slot_no++;
slot = page_dir_get_nth_slot(page, slot_no); slot = page_dir_get_nth_slot(page, slot_no);
} }
} }
if (page_cur_is_after_last(&cur)) { if (page_rec_is_supremum(rec)) {
break; break;
} }
count++; count++;
page_cur_move_to_next(&cur);
own_count++; own_count++;
old_rec = rec; old_rec = rec;
rec = page_rec_get_next(rec);
/* set old_offsets to offsets; recycle offsets */ /* set old_offsets to offsets; recycle offsets */
{ {
ulint* offs = old_offsets; ulint* offs = old_offsets;
...@@ -2397,10 +2403,12 @@ n_owned_zero: ...@@ -2397,10 +2403,12 @@ n_owned_zero:
goto func_exit; goto func_exit;
} }
if (UNIV_UNLIKELY(page_header_get_field(page, PAGE_N_RECS) + 2 if (UNIV_UNLIKELY(page_header_get_field(page, PAGE_N_RECS)
+ PAGE_HEAP_NO_USER_LOW
!= count + 1)) { != count + 1)) {
fprintf(stderr, "InnoDB: n recs wrong %lu %lu\n", fprintf(stderr, "InnoDB: n recs wrong %lu %lu\n",
(ulong) page_header_get_field(page, PAGE_N_RECS) + 2, (ulong) page_header_get_field(page, PAGE_N_RECS)
+ PAGE_HEAP_NO_USER_LOW,
(ulong) (count + 1)); (ulong) (count + 1));
goto func_exit; goto func_exit;
} }
...@@ -2424,7 +2432,7 @@ n_owned_zero: ...@@ -2424,7 +2432,7 @@ n_owned_zero:
} }
count++; count++;
offs = rec_get_start(rec, offsets) - page; offs = page_offset(rec_get_start(rec, offsets));
for (i = rec_offs_size(offsets); i--; ) { for (i = rec_offs_size(offsets); i--; ) {
...@@ -2467,44 +2475,46 @@ func_exit2: ...@@ -2467,44 +2475,46 @@ func_exit2:
/******************************************************************* /*******************************************************************
Looks in the page record list for a record with the given heap number. */ Looks in the page record list for a record with the given heap number. */
rec_t* const rec_t*
page_find_rec_with_heap_no( page_find_rec_with_heap_no(
/*=======================*/ /*=======================*/
/* out: record, NULL if not found */ /* out: record, NULL if not found */
page_t* page, /* in: index page */ const page_t* page, /* in: index page */
ulint heap_no)/* in: heap number */ ulint heap_no)/* in: heap number */
{ {
page_cur_t cur; const rec_t* rec;
page_cur_set_before_first(page, &cur);
if (page_is_comp(page)) { if (page_is_comp(page)) {
for (;;) { rec = page + PAGE_NEW_INFIMUM;
if (rec_get_heap_no_new(cur.rec) == heap_no) {
return(cur.rec); for(;;) {
} ulint rec_heap_no = rec_get_heap_no_new(rec);
if (page_cur_is_after_last(&cur)) { if (rec_heap_no == heap_no) {
return(rec);
} else if (rec_heap_no == PAGE_HEAP_NO_SUPREMUM) {
return(NULL); return(NULL);
} }
page_cur_move_to_next(&cur); rec = page + rec_get_next_offs(rec, TRUE);
} }
} else { } else {
rec = page + PAGE_OLD_INFIMUM;
for (;;) { for (;;) {
if (rec_get_heap_no_old(cur.rec) == heap_no) { ulint rec_heap_no = rec_get_heap_no_old(rec);
return(cur.rec); if (rec_heap_no == heap_no) {
}
if (page_cur_is_after_last(&cur)) { return(rec);
} else if (rec_heap_no == PAGE_HEAP_NO_SUPREMUM) {
return(NULL); return(NULL);
} }
page_cur_move_to_next(&cur); rec = page + rec_get_next_offs(rec, FALSE);
} }
} }
} }
...@@ -89,7 +89,8 @@ page_zip_dir_size( ...@@ -89,7 +89,8 @@ page_zip_dir_size(
{ {
/* Exclude the page infimum and supremum from the record count. */ /* Exclude the page infimum and supremum from the record count. */
ulint size = PAGE_ZIP_DIR_SLOT_SIZE ulint size = PAGE_ZIP_DIR_SLOT_SIZE
* (page_dir_get_n_heap(page_zip->data) - 2); * (page_dir_get_n_heap(page_zip->data)
- PAGE_HEAP_NO_USER_LOW);
return(size); return(size);
} }
...@@ -217,9 +218,9 @@ page_zip_compress_write_log( ...@@ -217,9 +218,9 @@ page_zip_compress_write_log(
return; return;
} }
/* Read the number of user records. /* Read the number of user records. */
Subtract 2 for the infimum and supremum records. */ trailer_size = page_dir_get_n_heap(page_zip->data)
trailer_size = page_dir_get_n_heap(page_zip->data) - 2; - PAGE_HEAP_NO_USER_LOW;
/* Multiply by uncompressed of size stored per record */ /* Multiply by uncompressed of size stored per record */
if (!page_is_leaf(page)) { if (!page_is_leaf(page)) {
trailer_size *= PAGE_ZIP_DIR_SLOT_SIZE + REC_NODE_PTR_SIZE; trailer_size *= PAGE_ZIP_DIR_SLOT_SIZE + REC_NODE_PTR_SIZE;
...@@ -284,8 +285,8 @@ page_zip_get_n_prev_extern( ...@@ -284,8 +285,8 @@ page_zip_get_n_prev_extern(
ut_ad(dict_index_is_clust(index)); ut_ad(dict_index_is_clust(index));
heap_no = rec_get_heap_no_new(rec); heap_no = rec_get_heap_no_new(rec);
ut_ad(heap_no >= 2); /* exclude infimum and supremum */ ut_ad(heap_no >= PAGE_HEAP_NO_USER_LOW);
left = heap_no - 2; left = heap_no - PAGE_HEAP_NO_USER_LOW;
if (UNIV_UNLIKELY(!left)) { if (UNIV_UNLIKELY(!left)) {
return(0); return(0);
} }
...@@ -512,7 +513,7 @@ page_zip_dir_encode( ...@@ -512,7 +513,7 @@ page_zip_dir_encode(
} }
rec = page + offs; rec = page + offs;
heap_no = rec_get_heap_no_new(rec); heap_no = rec_get_heap_no_new(rec);
ut_a(heap_no >= 2); /* not infimum or supremum */ ut_a(heap_no >= PAGE_HEAP_NO_USER_LOW);
ut_a(heap_no < n_heap); ut_a(heap_no < n_heap);
ut_a(offs < UNIV_PAGE_SIZE - PAGE_DIR); ut_a(offs < UNIV_PAGE_SIZE - PAGE_DIR);
ut_a(offs >= PAGE_ZIP_START); ut_a(offs >= PAGE_ZIP_START);
...@@ -537,9 +538,9 @@ page_zip_dir_encode( ...@@ -537,9 +538,9 @@ page_zip_dir_encode(
if (UNIV_LIKELY_NULL(recs)) { if (UNIV_LIKELY_NULL(recs)) {
/* Ensure that each heap_no occurs at most once. */ /* Ensure that each heap_no occurs at most once. */
ut_a(!recs[heap_no - 2]); ut_a(!recs[heap_no - PAGE_HEAP_NO_USER_LOW]);
/* exclude infimum and supremum */ /* exclude infimum and supremum */
recs[heap_no - 2] = rec; recs[heap_no - PAGE_HEAP_NO_USER_LOW] = rec;
} }
ut_a(rec_get_status(rec) == status); ut_a(rec_get_status(rec) == status);
...@@ -553,7 +554,7 @@ page_zip_dir_encode( ...@@ -553,7 +554,7 @@ page_zip_dir_encode(
rec = page + offs; rec = page + offs;
heap_no = rec_get_heap_no_new(rec); heap_no = rec_get_heap_no_new(rec);
ut_a(heap_no >= 2); /* not infimum or supremum */ ut_a(heap_no >= PAGE_HEAP_NO_USER_LOW);
ut_a(heap_no < n_heap); ut_a(heap_no < n_heap);
ut_a(!rec[-REC_N_NEW_EXTRA_BYTES]); /* info_bits and n_owned */ ut_a(!rec[-REC_N_NEW_EXTRA_BYTES]); /* info_bits and n_owned */
...@@ -563,16 +564,16 @@ page_zip_dir_encode( ...@@ -563,16 +564,16 @@ page_zip_dir_encode(
if (UNIV_LIKELY_NULL(recs)) { if (UNIV_LIKELY_NULL(recs)) {
/* Ensure that each heap_no occurs at most once. */ /* Ensure that each heap_no occurs at most once. */
ut_a(!recs[heap_no - 2]); ut_a(!recs[heap_no - PAGE_HEAP_NO_USER_LOW]);
/* exclude infimum and supremum */ /* exclude infimum and supremum */
recs[heap_no - 2] = rec; recs[heap_no - PAGE_HEAP_NO_USER_LOW] = rec;
} }
offs = rec_get_next_offs(rec, TRUE); offs = rec_get_next_offs(rec, TRUE);
} }
/* Ensure that each heap no occurs at least once. */ /* Ensure that each heap no occurs at least once. */
ut_a(i + 2/* infimum and supremum */ == n_heap); ut_a(i + PAGE_HEAP_NO_USER_LOW == n_heap);
} }
/************************************************************************** /**************************************************************************
...@@ -963,7 +964,7 @@ page_zip_compress( ...@@ -963,7 +964,7 @@ page_zip_compress(
} }
/* The dense directory excludes the infimum and supremum records. */ /* The dense directory excludes the infimum and supremum records. */
n_dense = page_dir_get_n_heap(page) - 2; n_dense = page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW;
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
if (UNIV_UNLIKELY(page_zip_compress_dbg)) { if (UNIV_UNLIKELY(page_zip_compress_dbg)) {
fprintf(stderr, "compress %p %p %lu %lu %lu\n", fprintf(stderr, "compress %p %p %lu %lu %lu\n",
...@@ -1421,7 +1422,7 @@ page_zip_set_extra_bytes( ...@@ -1421,7 +1422,7 @@ page_zip_set_extra_bytes(
page[PAGE_NEW_SUPREMUM - REC_N_NEW_EXTRA_BYTES] = n_owned; page[PAGE_NEW_SUPREMUM - REC_N_NEW_EXTRA_BYTES] = n_owned;
/* The dense directory excludes the infimum and supremum records. */ /* The dense directory excludes the infimum and supremum records. */
n = page_dir_get_n_heap(page) - 2; n = page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW;
if (i >= n) { if (i >= n) {
...@@ -1467,7 +1468,8 @@ page_zip_apply_log( ...@@ -1467,7 +1468,8 @@ page_zip_apply_log(
const byte* data, /* in: modification log */ const byte* data, /* in: modification log */
ulint size, /* in: maximum length of the log, in bytes */ ulint size, /* in: maximum length of the log, in bytes */
rec_t** recs, /* in: dense page directory, rec_t** recs, /* in: dense page directory,
sorted by address (indexed by heap_no - 2) */ sorted by address (indexed by
heap_no - PAGE_HEAP_NO_USER_LOW) */
ulint n_dense,/* in: size of recs[] */ ulint n_dense,/* in: size of recs[] */
ulint trx_id_col,/* in: column number of trx_id in the index, ulint trx_id_col,/* in: column number of trx_id in the index,
or ULINT_UNDEFINED if none */ or ULINT_UNDEFINED if none */
...@@ -1646,7 +1648,7 @@ page_zip_decompress_node_ptrs( ...@@ -1646,7 +1648,7 @@ page_zip_decompress_node_ptrs(
mem_heap_t* heap) /* in: temporary memory heap */ mem_heap_t* heap) /* in: temporary memory heap */
{ {
ulint heap_status = REC_STATUS_NODE_PTR ulint heap_status = REC_STATUS_NODE_PTR
| 2 << REC_HEAP_NO_SHIFT; | PAGE_HEAP_NO_USER_LOW << REC_HEAP_NO_SHIFT;
ulint slot; ulint slot;
const byte* storage; const byte* storage;
...@@ -1811,7 +1813,8 @@ page_zip_decompress_sec( ...@@ -1811,7 +1813,8 @@ page_zip_decompress_sec(
dict_index_t* index, /* in: the index of the page */ dict_index_t* index, /* in: the index of the page */
ulint* offsets) /* in/out: temporary offsets */ ulint* offsets) /* in/out: temporary offsets */
{ {
ulint heap_status = REC_STATUS_ORDINARY | 2 << REC_HEAP_NO_SHIFT; ulint heap_status = REC_STATUS_ORDINARY
| PAGE_HEAP_NO_USER_LOW << REC_HEAP_NO_SHIFT;
ulint slot; ulint slot;
/* Subtract the space reserved for uncompressed data. */ /* Subtract the space reserved for uncompressed data. */
...@@ -1935,7 +1938,7 @@ page_zip_decompress_clust( ...@@ -1935,7 +1938,7 @@ page_zip_decompress_clust(
int err; int err;
ulint slot; ulint slot;
ulint heap_status = REC_STATUS_ORDINARY ulint heap_status = REC_STATUS_ORDINARY
| 2 << REC_HEAP_NO_SHIFT; | PAGE_HEAP_NO_USER_LOW << REC_HEAP_NO_SHIFT;
const byte* storage; const byte* storage;
const byte* externs; const byte* externs;
...@@ -2225,7 +2228,7 @@ page_zip_decompress( ...@@ -2225,7 +2228,7 @@ page_zip_decompress(
ut_ad(page_zip_simple_validate(page_zip)); ut_ad(page_zip_simple_validate(page_zip));
/* The dense directory excludes the infimum and supremum records. */ /* The dense directory excludes the infimum and supremum records. */
n_dense = page_dir_get_n_heap(page_zip->data) - 2; n_dense = page_dir_get_n_heap(page_zip->data) - PAGE_HEAP_NO_USER_LOW;
if (UNIV_UNLIKELY(n_dense * PAGE_ZIP_DIR_SLOT_SIZE if (UNIV_UNLIKELY(n_dense * PAGE_ZIP_DIR_SLOT_SIZE
>= page_zip->size)) { >= page_zip->size)) {
return(FALSE); return(FALSE);
...@@ -2508,7 +2511,7 @@ page_zip_write_rec( ...@@ -2508,7 +2511,7 @@ page_zip_write_rec(
* page_dir_get_n_slots(page)); * page_dir_get_n_slots(page));
heap_no = rec_get_heap_no_new(rec); heap_no = rec_get_heap_no_new(rec);
ut_ad(heap_no >= 2); /* not infimum or supremum */ ut_ad(heap_no >= PAGE_HEAP_NO_USER_LOW); /* not infimum or supremum */
ut_ad(heap_no < page_dir_get_n_heap(page)); ut_ad(heap_no < page_dir_get_n_heap(page));
/* Append to the modification log. */ /* Append to the modification log. */
...@@ -2542,7 +2545,7 @@ page_zip_write_rec( ...@@ -2542,7 +2545,7 @@ page_zip_write_rec(
/* Write the data bytes. Store the uncompressed bytes separately. */ /* Write the data bytes. Store the uncompressed bytes separately. */
storage = page_zip->data + page_zip->size storage = page_zip->data + page_zip->size
- (page_dir_get_n_heap(page) - 2) - (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW)
* PAGE_ZIP_DIR_SLOT_SIZE; * PAGE_ZIP_DIR_SLOT_SIZE;
if (page_is_leaf(page)) { if (page_is_leaf(page)) {
...@@ -2560,7 +2563,8 @@ page_zip_write_rec( ...@@ -2560,7 +2563,8 @@ page_zip_write_rec(
ut_ad(trx_id_col != ULINT_UNDEFINED); ut_ad(trx_id_col != ULINT_UNDEFINED);
externs -= (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN) externs -= (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN)
* (page_dir_get_n_heap(page) - 2); * (page_dir_get_n_heap(page)
- PAGE_HEAP_NO_USER_LOW);
/* Note that this will not take into account /* Note that this will not take into account
the BLOB columns of rec if create==TRUE */ the BLOB columns of rec if create==TRUE */
...@@ -2681,7 +2685,7 @@ page_zip_write_rec( ...@@ -2681,7 +2685,7 @@ page_zip_write_rec(
/* Copy the data bytes, except node_ptr. */ /* Copy the data bytes, except node_ptr. */
len = rec_offs_data_size(offsets) - REC_NODE_PTR_SIZE; len = rec_offs_data_size(offsets) - REC_NODE_PTR_SIZE;
ut_ad(data + len < storage - REC_NODE_PTR_SIZE ut_ad(data + len < storage - REC_NODE_PTR_SIZE
* (page_dir_get_n_heap(page) - 2)); * (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW));
ut_ad(!memcmp(data, zero, ut_min(len, sizeof zero))); ut_ad(!memcmp(data, zero, ut_min(len, sizeof zero)));
memcpy(data, rec, len); memcpy(data, rec, len);
data += len; data += len;
...@@ -2801,9 +2805,8 @@ page_zip_write_blob_ptr( ...@@ -2801,9 +2805,8 @@ page_zip_write_blob_ptr(
+ rec_get_n_extern_new(rec, index, n); + rec_get_n_extern_new(rec, index, n);
ut_a(blob_no < page_zip->n_blobs); ut_a(blob_no < page_zip->n_blobs);
/* The heap number of the first user record is 2. */
externs = page_zip->data + page_zip->size externs = page_zip->data + page_zip->size
- (page_dir_get_n_heap(page) - 2) - (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW)
* (PAGE_ZIP_DIR_SLOT_SIZE * (PAGE_ZIP_DIR_SLOT_SIZE
+ DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
...@@ -2891,13 +2894,13 @@ corrupt: ...@@ -2891,13 +2894,13 @@ corrupt:
storage = page_zip->data + z_offset; storage = page_zip->data + z_offset;
storage_end = page_zip->data + page_zip->size storage_end = page_zip->data + page_zip->size
- (page_dir_get_n_heap(page) - 2) - (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW)
* PAGE_ZIP_DIR_SLOT_SIZE; * PAGE_ZIP_DIR_SLOT_SIZE;
heap_no = 1 + (storage_end - storage) / REC_NODE_PTR_SIZE; heap_no = 1 + (storage_end - storage) / REC_NODE_PTR_SIZE;
if (UNIV_UNLIKELY((storage_end - storage) % REC_NODE_PTR_SIZE) if (UNIV_UNLIKELY((storage_end - storage) % REC_NODE_PTR_SIZE)
|| UNIV_UNLIKELY(heap_no < 2) || UNIV_UNLIKELY(heap_no < PAGE_HEAP_NO_USER_LOW)
|| UNIV_UNLIKELY(heap_no >= page_dir_get_n_heap(page))) { || UNIV_UNLIKELY(heap_no >= page_dir_get_n_heap(page))) {
goto corrupt; goto corrupt;
...@@ -2941,9 +2944,8 @@ page_zip_write_node_ptr( ...@@ -2941,9 +2944,8 @@ page_zip_write_node_ptr(
ut_ad(!page_is_leaf(page)); ut_ad(!page_is_leaf(page));
/* The heap number of the first user record is 2. */
storage = page_zip->data + page_zip->size storage = page_zip->data + page_zip->size
- (page_dir_get_n_heap(page) - 2) - (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW)
* PAGE_ZIP_DIR_SLOT_SIZE * PAGE_ZIP_DIR_SLOT_SIZE
- (rec_get_heap_no_new(rec) - 1) * REC_NODE_PTR_SIZE; - (rec_get_heap_no_new(rec) - 1) * REC_NODE_PTR_SIZE;
field = rec + size - REC_NODE_PTR_SIZE; field = rec + size - REC_NODE_PTR_SIZE;
...@@ -3006,9 +3008,8 @@ page_zip_write_trx_id_and_roll_ptr( ...@@ -3006,9 +3008,8 @@ page_zip_write_trx_id_and_roll_ptr(
ut_ad(page_is_leaf(page)); ut_ad(page_is_leaf(page));
/* The heap number of the first user record is 2. */
storage = page_zip->data + page_zip->size storage = page_zip->data + page_zip->size
- (page_dir_get_n_heap(page) - 2) - (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW)
* PAGE_ZIP_DIR_SLOT_SIZE * PAGE_ZIP_DIR_SLOT_SIZE
- (rec_get_heap_no_new(rec) - 1) - (rec_get_heap_no_new(rec) - 1)
* (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); * (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
...@@ -3065,7 +3066,7 @@ page_zip_clear_rec( ...@@ -3065,7 +3066,7 @@ page_zip_clear_rec(
ut_ad(page_zip_header_cmp(page_zip, page)); ut_ad(page_zip_header_cmp(page_zip, page));
heap_no = rec_get_heap_no_new(rec); heap_no = rec_get_heap_no_new(rec);
ut_ad(heap_no >= 2); /* exclude infimum and supremum */ ut_ad(heap_no >= PAGE_HEAP_NO_USER_LOW);
if ( if (
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
...@@ -3084,7 +3085,8 @@ page_zip_clear_rec( ...@@ -3084,7 +3085,8 @@ page_zip_clear_rec(
if (!page_is_leaf(page)) { if (!page_is_leaf(page)) {
/* Clear node_ptr on the compressed page. */ /* Clear node_ptr on the compressed page. */
byte* storage = page_zip->data + page_zip->size byte* storage = page_zip->data + page_zip->size
- (page_dir_get_n_heap(page) - 2) - (page_dir_get_n_heap(page)
- PAGE_HEAP_NO_USER_LOW)
* PAGE_ZIP_DIR_SLOT_SIZE; * PAGE_ZIP_DIR_SLOT_SIZE;
memset(storage - (heap_no - 1) * REC_NODE_PTR_SIZE, memset(storage - (heap_no - 1) * REC_NODE_PTR_SIZE,
...@@ -3092,7 +3094,8 @@ page_zip_clear_rec( ...@@ -3092,7 +3094,8 @@ page_zip_clear_rec(
} else if (dict_index_is_clust(index)) { } else if (dict_index_is_clust(index)) {
/* Clear trx_id and roll_ptr on the compressed page. */ /* Clear trx_id and roll_ptr on the compressed page. */
byte* storage = page_zip->data + page_zip->size byte* storage = page_zip->data + page_zip->size
- (page_dir_get_n_heap(page) - 2) - (page_dir_get_n_heap(page)
- PAGE_HEAP_NO_USER_LOW)
* PAGE_ZIP_DIR_SLOT_SIZE; * PAGE_ZIP_DIR_SLOT_SIZE;
memset(storage - (heap_no - 1) memset(storage - (heap_no - 1)
...@@ -3214,9 +3217,9 @@ page_zip_dir_insert( ...@@ -3214,9 +3217,9 @@ page_zip_dir_insert(
ut_a(slot_rec); ut_a(slot_rec);
} }
/* Read the old n_dense (n_heap may have been incremented). /* Read the old n_dense (n_heap may have been incremented). */
Subtract 2 for the infimum and supremum records. */ n_dense = page_dir_get_n_heap(page_zip->data)
n_dense = page_dir_get_n_heap(page_zip->data) - 3; - (PAGE_HEAP_NO_USER_LOW + 1);
if (UNIV_LIKELY_NULL(free_rec)) { if (UNIV_LIKELY_NULL(free_rec)) {
/* The record was allocated from the free list. /* The record was allocated from the free list.
...@@ -3225,7 +3228,7 @@ page_zip_dir_insert( ...@@ -3225,7 +3228,7 @@ page_zip_dir_insert(
off by one, because page_cur_insert_rec_low() off by one, because page_cur_insert_rec_low()
did not increment n_heap. */ did not increment n_heap. */
ut_ad(rec_get_heap_no_new(rec) < n_dense + 1 ut_ad(rec_get_heap_no_new(rec) < n_dense + 1
+ 2/* infimum and supremum */); + PAGE_HEAP_NO_USER_LOW);
ut_ad(rec >= free_rec); ut_ad(rec >= free_rec);
slot_free = page_zip_dir_find(page_zip, page_offset(free_rec)); slot_free = page_zip_dir_find(page_zip, page_offset(free_rec));
ut_ad(slot_free); ut_ad(slot_free);
...@@ -3234,7 +3237,7 @@ page_zip_dir_insert( ...@@ -3234,7 +3237,7 @@ page_zip_dir_insert(
/* The record was allocated from the heap. /* The record was allocated from the heap.
Shift the entire dense directory. */ Shift the entire dense directory. */
ut_ad(rec_get_heap_no_new(rec) == n_dense ut_ad(rec_get_heap_no_new(rec) == n_dense
+ 2/* infimum and supremum */); + PAGE_HEAP_NO_USER_LOW);
/* Shift to the end of the dense page directory. */ /* Shift to the end of the dense page directory. */
slot_free = page_zip->data + page_zip->size slot_free = page_zip->data + page_zip->size
...@@ -3283,7 +3286,8 @@ page_zip_dir_delete( ...@@ -3283,7 +3286,8 @@ page_zip_dir_delete(
/* Make the last slot the start of the free list. */ /* Make the last slot the start of the free list. */
slot_free = page_zip->data + page_zip->size slot_free = page_zip->data + page_zip->size
- PAGE_ZIP_DIR_SLOT_SIZE - PAGE_ZIP_DIR_SLOT_SIZE
* (page_dir_get_n_heap(page_zip->data) - 2); * (page_dir_get_n_heap(page_zip->data)
- PAGE_HEAP_NO_USER_LOW);
} else { } else {
slot_free = page_zip_dir_find_free(page_zip, slot_free = page_zip_dir_find_free(page_zip,
page_offset(free)); page_offset(free));
...@@ -3318,7 +3322,7 @@ page_zip_dir_delete( ...@@ -3318,7 +3322,7 @@ page_zip_dir_delete(
ut_a(blob_no + n_ext <= page_zip->n_blobs); ut_a(blob_no + n_ext <= page_zip->n_blobs);
externs = page_zip->data + page_zip->size externs = page_zip->data + page_zip->size
- (page_dir_get_n_heap(page) - 2) - (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW)
* (PAGE_ZIP_DIR_SLOT_SIZE * (PAGE_ZIP_DIR_SLOT_SIZE
+ DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
...@@ -3358,9 +3362,9 @@ page_zip_dir_add_slot( ...@@ -3358,9 +3362,9 @@ page_zip_dir_add_slot(
ut_ad(page_is_comp(page_zip->data)); ut_ad(page_is_comp(page_zip->data));
/* Read the old n_dense (n_heap has already been incremented). /* Read the old n_dense (n_heap has already been incremented). */
Subtract 2 for the infimum and supremum records. */ n_dense = page_dir_get_n_heap(page_zip->data)
n_dense = page_dir_get_n_heap(page_zip->data) - 3; - (PAGE_HEAP_NO_USER_LOW + 1);
dir = page_zip->data + page_zip->size dir = page_zip->data + page_zip->size
- PAGE_ZIP_DIR_SLOT_SIZE * n_dense; - PAGE_ZIP_DIR_SLOT_SIZE * n_dense;
...@@ -3536,7 +3540,8 @@ page_zip_reorganize( ...@@ -3536,7 +3540,8 @@ page_zip_reorganize(
/* Copy the records from the temporary space to the recreated page; /* Copy the records from the temporary space to the recreated page;
do not copy the lock bits yet */ do not copy the lock bits yet */
page_copy_rec_list_end_no_locks(page, page_get_infimum_rec(temp_page), page_copy_rec_list_end_no_locks(block, temp_block,
page_get_infimum_rec(temp_page),
index, mtr); index, mtr);
/* Copy max trx id to recreated page */ /* Copy max trx id to recreated page */
page_set_max_trx_id(page, NULL, page_get_max_trx_id(temp_page)); page_set_max_trx_id(page, NULL, page_get_max_trx_id(temp_page));
......
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