Commit 29d67d05 authored by Marko Mäkelä's avatar Marko Mäkelä

Cleanup btr_page_get_prev(), btr_page_get_next()

Remove the redundant parameter mtr_t*.

Make use of page_has_prev(), page_has_next() whenever possible.
parent 1d2458f8
......@@ -2480,8 +2480,8 @@ btr_attach_half_pages(
}
/* Get the previous and next pages of page */
prev_page_no = btr_page_get_prev(page, mtr);
next_page_no = btr_page_get_next(page, mtr);
prev_page_no = btr_page_get_prev(page);
next_page_no = btr_page_get_next(page);
const ulint space = block->page.id.space();
......@@ -2522,7 +2522,7 @@ btr_attach_half_pages(
if (prev_block) {
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(prev_block->frame) == page_is_comp(page));
ut_a(btr_page_get_next(prev_block->frame, mtr)
ut_a(btr_page_get_next(prev_block->frame)
== block->page.id.page_no());
#endif /* UNIV_BTR_DEBUG */
......@@ -2534,7 +2534,7 @@ btr_attach_half_pages(
if (next_block) {
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(next_block->frame) == page_is_comp(page));
ut_a(btr_page_get_prev(next_block->frame, mtr)
ut_a(btr_page_get_prev(next_block->frame)
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
......@@ -2548,7 +2548,7 @@ btr_attach_half_pages(
btr_page_set_prev(lower_page, lower_page_zip,
prev_page_no, mtr);
} else {
ut_ad(btr_page_get_prev(lower_page, mtr) == prev_page_no);
ut_ad(btr_page_get_prev(lower_page) == prev_page_no);
}
btr_page_set_next(lower_page, lower_page_zip, upper_page_no, mtr);
......@@ -2559,7 +2559,7 @@ btr_attach_half_pages(
btr_page_set_next(upper_page, upper_page_zip,
next_page_no, mtr);
} else {
ut_ad(btr_page_get_next(upper_page, mtr) == next_page_no);
ut_ad(btr_page_get_next(upper_page) == next_page_no);
}
}
......@@ -2620,7 +2620,7 @@ btr_insert_into_right_sibling(
{
buf_block_t* block = btr_cur_get_block(cursor);
page_t* page = buf_block_get_frame(block);
ulint next_page_no = btr_page_get_next(page, mtr);
const uint32_t next_page_no = btr_page_get_next(page);
ut_ad(mtr_memo_contains_flagged(
mtr, dict_index_get_lock(cursor->index),
......@@ -3161,8 +3161,8 @@ btr_level_list_remove_func(
ut_ad(space == page_get_space_id(page));
/* Get the previous and next page numbers of page */
const ulint prev_page_no = btr_page_get_prev(page, mtr);
const ulint next_page_no = btr_page_get_next(page, mtr);
const uint32_t prev_page_no = btr_page_get_prev(page);
const uint32_t next_page_no = btr_page_get_next(page);
/* Update page links of the level */
......@@ -3175,8 +3175,8 @@ btr_level_list_remove_func(
= buf_block_get_frame(prev_block);
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(prev_page) == page_is_comp(page));
ut_a(btr_page_get_next(prev_page, mtr)
== page_get_page_no(page));
ut_a(!memcmp(prev_page + FIL_PAGE_NEXT, page + FIL_PAGE_OFFSET,
4));
#endif /* UNIV_BTR_DEBUG */
btr_page_set_next(prev_page,
......@@ -3194,8 +3194,8 @@ btr_level_list_remove_func(
= buf_block_get_frame(next_block);
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(next_page) == page_is_comp(page));
ut_a(btr_page_get_prev(next_page, mtr)
== page_get_page_no(page));
ut_a(!memcmp(next_page + FIL_PAGE_PREV, page + FIL_PAGE_OFFSET,
4));
#endif /* UNIV_BTR_DEBUG */
btr_page_set_prev(next_page,
......@@ -3527,8 +3527,8 @@ btr_compress(
MONITOR_INC(MONITOR_INDEX_MERGE_ATTEMPTS);
left_page_no = btr_page_get_prev(page, mtr);
right_page_no = btr_page_get_next(page, mtr);
left_page_no = btr_page_get_prev(page);
right_page_no = btr_page_get_next(page);
#ifdef UNIV_DEBUG
if (!page_is_leaf(page) && left_page_no == FIL_NULL) {
......@@ -3602,10 +3602,10 @@ btr_compress(
#ifdef UNIV_BTR_DEBUG
if (is_left) {
ut_a(btr_page_get_next(merge_page, mtr)
ut_a(btr_page_get_next(merge_page)
== block->page.id.page_no());
} else {
ut_a(btr_page_get_prev(merge_page, mtr)
ut_a(btr_page_get_prev(merge_page)
== block->page.id.page_no());
}
#endif /* UNIV_BTR_DEBUG */
......@@ -4126,8 +4126,8 @@ btr_discard_page(
/* Decide the page which will inherit the locks */
left_page_no = btr_page_get_prev(buf_block_get_frame(block), mtr);
right_page_no = btr_page_get_next(buf_block_get_frame(block), mtr);
left_page_no = btr_page_get_prev(buf_block_get_frame(block));
right_page_no = btr_page_get_next(buf_block_get_frame(block));
const page_size_t page_size(dict_table_page_size(index->table));
ut_d(bool parent_is_different = false);
......@@ -4138,7 +4138,7 @@ btr_discard_page(
merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(merge_page, mtr)
ut_a(btr_page_get_next(merge_page)
== block->page.id.page_no());
#endif /* UNIV_BTR_DEBUG */
ut_d(parent_is_different =
......@@ -4154,7 +4154,7 @@ btr_discard_page(
merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(merge_page, mtr)
ut_a(btr_page_get_prev(merge_page)
== block->page.id.page_no());
#endif /* UNIV_BTR_DEBUG */
ut_d(parent_is_different = page_rec_is_supremum(
......@@ -4776,7 +4776,7 @@ btr_validate_level(
does not use such scan for any of its DML or query
operations */
if (dict_index_is_spatial(index)) {
left_page_no = btr_page_get_prev(page, &mtr);
left_page_no = btr_page_get_prev(page);
while (left_page_no != FIL_NULL) {
page_id_t left_page_id(
......@@ -4793,7 +4793,7 @@ btr_validate_level(
table_page_size,
RW_SX_LATCH, index, &mtr);
page = buf_block_get_frame(block);
left_page_no = btr_page_get_prev(page, &mtr);
left_page_no = btr_page_get_prev(page);
}
}
}
......@@ -4848,8 +4848,8 @@ btr_validate_level(
ut_a(btr_page_get_level(page, &mtr) == level);
right_page_no = btr_page_get_next(page, &mtr);
left_page_no = btr_page_get_prev(page, &mtr);
right_page_no = btr_page_get_next(page);
left_page_no = btr_page_get_prev(page);
ut_a(!page_is_empty(page)
|| (level == 0
......@@ -4866,9 +4866,7 @@ btr_validate_level(
right_page = buf_block_get_frame(right_block);
if (btr_page_get_prev(right_page, &mtr)
!= page_get_page_no(page)) {
if (btr_page_get_prev(right_page) != page_get_page_no(page)) {
btr_validate_report2(index, level, block, right_block);
fputs("InnoDB: broken FIL_PAGE_NEXT"
" or FIL_PAGE_PREV links\n", stderr);
......@@ -4949,7 +4947,7 @@ btr_validate_level(
node_ptr = btr_cur_get_rec(&node_cur);
parent_page_no = page_get_page_no(father_page);
parent_right_page_no = btr_page_get_next(father_page, &mtr);
parent_right_page_no = btr_page_get_next(father_page);
rightmost_child = page_rec_is_supremum(
page_rec_get_next(node_ptr));
......@@ -5090,7 +5088,7 @@ btr_validate_level(
}
if (page_get_page_no(right_father_page)
!= btr_page_get_next(father_page, &mtr)) {
!= btr_page_get_next(father_page)) {
ret = false;
fputs("InnoDB: node pointer 3 to"
......
......@@ -279,7 +279,7 @@ btr_cur_latch_leaves(
dict_index_get_lock(cursor->index),
MTR_MEMO_X_LOCK | MTR_MEMO_SX_LOCK));
/* x-latch also siblings from left to right */
left_page_no = btr_page_get_prev(page, mtr);
left_page_no = btr_page_get_prev(page);
mode = latch_mode;
if (left_page_no != FIL_NULL) {
......@@ -316,8 +316,7 @@ btr_cur_latch_leaves(
if (latch_leaves.blocks[0] != NULL) {
ut_a(page_is_comp(latch_leaves.blocks[0]->frame)
== page_is_comp(page));
ut_a(btr_page_get_next(
latch_leaves.blocks[0]->frame, mtr)
ut_a(btr_page_get_next(latch_leaves.blocks[0]->frame)
== page_get_page_no(page));
}
ut_a(page_is_comp(get_block->frame) == page_is_comp(page));
......@@ -328,7 +327,7 @@ btr_cur_latch_leaves(
= get_block;
}
right_page_no = btr_page_get_next(page, mtr);
right_page_no = btr_page_get_next(page);
if (right_page_no != FIL_NULL) {
if (spatial) {
......@@ -344,7 +343,7 @@ btr_cur_latch_leaves(
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(get_block->frame)
== page_is_comp(page));
ut_a(btr_page_get_prev(get_block->frame, mtr)
ut_a(btr_page_get_prev(get_block->frame)
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
if (spatial) {
......@@ -360,7 +359,7 @@ btr_cur_latch_leaves(
mode = latch_mode == BTR_SEARCH_PREV ? RW_S_LATCH : RW_X_LATCH;
/* latch also left sibling */
rw_lock_s_lock(&block->lock);
left_page_no = btr_page_get_prev(page, mtr);
left_page_no = btr_page_get_prev(page);
rw_lock_s_unlock(&block->lock);
if (left_page_no != FIL_NULL) {
......@@ -373,7 +372,7 @@ btr_cur_latch_leaves(
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(get_block->frame)
== page_is_comp(page));
ut_a(btr_page_get_next(get_block->frame, mtr)
ut_a(btr_page_get_next(get_block->frame)
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
}
......@@ -443,7 +442,7 @@ btr_cur_optimistic_latch_leaves(
goto unpin_failed;
}
left_page_no = btr_page_get_prev(
buf_block_get_frame(block), mtr);
buf_block_get_frame(block));
rw_lock_s_unlock(&block->lock);
if (left_page_no != FIL_NULL) {
......@@ -461,7 +460,7 @@ btr_cur_optimistic_latch_leaves(
if (buf_page_optimistic_get(mode, block, modify_clock,
file, line, mtr)) {
if (btr_page_get_prev(buf_block_get_frame(block), mtr)
if (btr_page_get_prev(buf_block_get_frame(block))
== left_page_no) {
buf_block_buf_fix_dec(block);
*latch_mode = mode;
......@@ -1341,8 +1340,7 @@ btr_cur_search_to_nth_level(
rw_latch = upper_rw_latch;
rw_lock_s_lock(&block->lock);
left_page_no = btr_page_get_prev(
buf_block_get_frame(block), mtr);
left_page_no = btr_page_get_prev(buf_block_get_frame(block));
rw_lock_s_unlock(&block->lock);
if (left_page_no != FIL_NULL) {
......@@ -3419,10 +3417,7 @@ btr_cur_pessimistic_insert(
}
if (!page_rec_is_infimum(btr_cur_get_rec(cursor))
|| btr_page_get_prev(
buf_block_get_frame(
btr_cur_get_block(cursor)), mtr)
== FIL_NULL) {
|| !page_has_prev(btr_cur_get_page(cursor))) {
/* split and inserted need to call
lock_update_insert() always. */
inherit = TRUE;
......@@ -4212,15 +4207,14 @@ btr_cur_pess_upd_restore_supremum(
return;
}
const ulint prev_page_no = btr_page_get_prev(page, mtr);
const uint32_t prev_page_no = btr_page_get_prev(page);
const page_id_t page_id(block->page.id.space(), prev_page_no);
ut_ad(prev_page_no != FIL_NULL);
prev_block = buf_page_get_with_no_latch(page_id, block->page.size, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(prev_block->frame, mtr)
== page_get_page_no(page));
ut_a(btr_page_get_next(prev_block->frame) == block->page.id.page_no());
#endif /* UNIV_BTR_DEBUG */
/* We must already have an x-latch on prev_block! */
......@@ -5627,7 +5621,7 @@ btr_estimate_n_rows_in_range_on_level(
n_rows += page_get_n_recs(page);
}
page_id.set_page_no(btr_page_get_next(page, &mtr));
page_id.set_page_no(btr_page_get_next(page));
mtr_commit(&mtr);
......
......@@ -586,7 +586,7 @@ btr_defragment_n_pages(
blocks[0] = block;
for (uint i = 1; i <= n_pages; i++) {
page_t* page = buf_block_get_frame(blocks[i-1]);
ulint page_no = btr_page_get_next(page, mtr);
ulint page_no = btr_page_get_next(page);
total_data_size += page_get_data_size(page);
total_n_recs += page_get_n_recs(page);
if (page_no == FIL_NULL) {
......
......@@ -420,7 +420,7 @@ btr_pcur_move_to_next_page(
return;
}
next_page_no = btr_page_get_next(page, mtr);
next_page_no = btr_page_get_next(page);
ut_ad(next_page_no != FIL_NULL);
......@@ -447,7 +447,7 @@ btr_pcur_move_to_next_page(
next_page = buf_block_get_frame(next_block);
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(next_page) == page_is_comp(page));
ut_a(btr_page_get_prev(next_page, mtr)
ut_a(btr_page_get_prev(next_page)
== btr_pcur_get_block(cursor)->page.id.page_no());
#endif /* UNIV_BTR_DEBUG */
......@@ -509,7 +509,7 @@ btr_pcur_move_backward_from_page(
page = btr_pcur_get_page(cursor);
prev_page_no = btr_page_get_prev(page, mtr);
prev_page_no = btr_page_get_prev(page);
if (prev_page_no == FIL_NULL) {
} else if (btr_pcur_is_before_first_on_page(cursor)) {
......
......@@ -433,8 +433,8 @@ btr_pessimistic_scrub(
/* read block variables */
const ulint page_no = mach_read_from_4(page + FIL_PAGE_OFFSET);
const page_id_t page_id(dict_index_get_space(index), page_no);
const ulint left_page_no = btr_page_get_prev(page, mtr);
const ulint right_page_no = btr_page_get_next(page, mtr);
const uint32_t left_page_no = btr_page_get_prev(page);
const uint32_t right_page_no = btr_page_get_next(page);
const page_id_t lpage_id(dict_index_get_space(index), left_page_no);
const page_id_t rpage_id(dict_index_get_space(index), right_page_no);
const page_size_t page_size(dict_table_page_size(index->table));
......@@ -468,8 +468,8 @@ btr_pessimistic_scrub(
/**
* structure should be unchanged
*/
ut_a(left_page_no == btr_page_get_prev(page, mtr));
ut_a(right_page_no == btr_page_get_next(page, mtr));
ut_a(left_page_no == btr_page_get_prev(page));
ut_a(right_page_no == btr_page_get_next(page));
}
if (right_page_no != FIL_NULL) {
......
......@@ -802,9 +802,7 @@ btr_search_check_guess(
prev_rec = page_rec_get_prev(rec);
if (page_rec_is_infimum(prev_rec)) {
success = btr_page_get_prev(page_align(prev_rec), mtr)
== FIL_NULL;
success = !page_has_prev(page_align(prev_rec));
goto exit_func;
}
......@@ -827,9 +825,7 @@ btr_search_check_guess(
next_rec = page_rec_get_next(rec);
if (page_rec_is_supremum(next_rec)) {
if (btr_page_get_next(page_align(next_rec), mtr)
== FIL_NULL) {
if (!page_has_next(page_align(next_rec))) {
cursor->up_match = 0;
success = TRUE;
}
......
......@@ -605,16 +605,10 @@ rtr_update_mbr_field(
}
}
#ifdef UNIV_DEBUG
ulint left_page_no = btr_page_get_prev(page, mtr);
if (left_page_no == FIL_NULL) {
ut_a(REC_INFO_MIN_REC_FLAG & rec_get_info_bits(
ut_ad(page_has_prev(page)
|| (REC_INFO_MIN_REC_FLAG & rec_get_info_bits(
page_rec_get_next(page_get_infimum_rec(page)),
page_is_comp(page)));
}
#endif /* UNIV_DEBUG */
page_is_comp(page))));
mem_heap_free(heap);
......@@ -649,8 +643,6 @@ rtr_adjust_upper_level(
mem_heap_t* heap;
ulint level;
dtuple_t* node_ptr_upper;
ulint next_page_no;
ulint space;
page_cur_t* page_cursor;
rtr_mbr_t parent_mbr;
lock_prdt_t prdt;
......@@ -759,19 +751,19 @@ rtr_adjust_upper_level(
mem_heap_free(heap);
/* Get the previous and next pages of page */
next_page_no = btr_page_get_next(page, mtr);
space = block->page.id.space();
const page_size_t& page_size = dict_table_page_size(index->table);
const uint32_t next_page_no = btr_page_get_next(page);
if (next_page_no != FIL_NULL) {
page_id_t next_page_id(space, next_page_no);
page_id_t next_page_id(block->page.id.space(),
next_page_no);
buf_block_t* next_block = btr_block_get(
next_page_id, page_size, RW_X_LATCH, index, mtr);
next_page_id, dict_table_page_size(index->table),
RW_X_LATCH, index, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(next_block->frame) == page_is_comp(page));
ut_a(btr_page_get_prev(next_block->frame, mtr)
== page_get_page_no(page));
ut_a(btr_page_get_prev(next_block->frame)
== block->page.id.page_no());
#endif /* UNIV_BTR_DEBUG */
btr_page_set_prev(buf_block_get_frame(next_block),
......
......@@ -289,7 +289,7 @@ rtr_pcur_getnext_from_path(
Note that we have SX lock on index->lock, there
should not be any split/shrink happening here */
if (page_ssn > path_ssn) {
ulint next_page_no = btr_page_get_next(page, mtr);
uint32_t next_page_no = btr_page_get_next(page);
rtr_non_leaf_stack_push(
rtr_info->path, next_page_no, path_ssn,
level, 0, NULL, 0);
......@@ -1407,7 +1407,7 @@ rtr_cur_restore_position(
/* Check the page SSN to see if it has been splitted, if so, search
the right page */
if (!ret && page_ssn > path_ssn) {
page_no = btr_page_get_next(page, mtr);
page_no = btr_page_get_next(page);
goto search_again;
}
......
......@@ -2989,7 +2989,7 @@ ibuf_get_volume_buffered(
/* Look at the previous page */
prev_page_no = btr_page_get_prev(page, mtr);
prev_page_no = btr_page_get_prev(page);
if (prev_page_no == FIL_NULL) {
......@@ -3010,7 +3010,7 @@ ibuf_get_volume_buffered(
}
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(prev_page, mtr) == page_get_page_no(page));
ut_a(!memcmp(prev_page + FIL_PAGE_NEXT, page + FIL_PAGE_OFFSET, 4));
#endif /* UNIV_BTR_DEBUG */
rec = page_get_supremum_rec(prev_page);
......@@ -3061,7 +3061,7 @@ ibuf_get_volume_buffered(
/* Look at the next page */
next_page_no = btr_page_get_next(page, mtr);
next_page_no = btr_page_get_next(page);
if (next_page_no == FIL_NULL) {
......@@ -3082,7 +3082,7 @@ ibuf_get_volume_buffered(
}
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(next_page, mtr) == page_get_page_no(page));
ut_a(!memcmp(next_page + FIL_PAGE_PREV, page + FIL_PAGE_OFFSET, 4));
#endif /* UNIV_BTR_DEBUG */
rec = page_get_infimum_rec(next_page);
......
......@@ -265,26 +265,23 @@ btr_page_get_level_low(
const page_t* page) /*!< in: index page */
MY_ATTRIBUTE((warn_unused_result));
#define btr_page_get_level(page, mtr) btr_page_get_level_low(page)
/********************************************************//**
Gets the next index page number.
@return next page number */
UNIV_INLINE
ulint
btr_page_get_next(
/*==============*/
const page_t* page, /*!< in: index page */
mtr_t* mtr) /*!< in: mini-transaction handle */
MY_ATTRIBUTE((warn_unused_result));
/********************************************************//**
Gets the previous index page number.
@return prev page number */
UNIV_INLINE
ulint
btr_page_get_prev(
/*==============*/
const page_t* page, /*!< in: index page */
mtr_t* mtr) /*!< in: mini-transaction handle */
MY_ATTRIBUTE((warn_unused_result));
/** Read FIL_PAGE_NEXT.
@param page buffer pool page
@return previous page number */
inline uint32_t btr_page_get_next(const page_t* page)
{
return mach_read_from_4(page + FIL_PAGE_NEXT);
}
/** Read FIL_PAGE_PREV.
@param page buffer pool page
@return previous page number */
inline uint32_t btr_page_get_prev(const page_t* page)
{
return mach_read_from_4(page + FIL_PAGE_PREV);
}
/**************************************************************//**
Releases the latch on a leaf page and bufferunfixes it. */
UNIV_INLINE
......
......@@ -160,23 +160,6 @@ btr_page_set_level(
}
}
/********************************************************//**
Gets the next index page number.
@return next page number */
UNIV_INLINE
ulint
btr_page_get_next(
/*==============*/
const page_t* page, /*!< in: index page */
mtr_t* mtr MY_ATTRIBUTE((unused)))
/*!< in: mini-transaction handle */
{
ut_ad(page != NULL);
ut_ad(mtr != NULL);
return(mach_read_from_4(page + FIL_PAGE_NEXT));
}
/********************************************************//**
Sets the next index page field. */
UNIV_INLINE
......@@ -200,22 +183,6 @@ btr_page_set_next(
}
}
/********************************************************//**
Gets the previous index page number.
@return prev page number */
UNIV_INLINE
ulint
btr_page_get_prev(
/*==============*/
const page_t* page, /*!< in: index page */
mtr_t* mtr MY_ATTRIBUTE((unused))) /*!< in: mini-transaction handle */
{
ut_ad(page != NULL);
ut_ad(mtr != NULL);
return(mach_read_from_4(page + FIL_PAGE_PREV));
}
/********************************************************//**
Sets the previous index page field. */
UNIV_INLINE
......
......@@ -775,7 +775,7 @@ page_cur_search_with_match_bytes(
ulint rec_info = rec_get_info_bits(mid_rec,
rec_offs_comp(offsets));
ut_ad(rec_info & REC_INFO_MIN_REC_FLAG);
ut_ad(btr_page_get_prev(page, &mtr) == FIL_NULL);
ut_ad(!page_has_prev(page));
mtr_commit(&mtr);
#endif
......
......@@ -2011,7 +2011,7 @@ row_merge_read_clustered_index(
buf_block_t* block;
next_page_no = btr_page_get_next(
page_cur_get_page(cur), &mtr);
page_cur_get_page(cur));
if (next_page_no == FIL_NULL) {
goto end_of_index;
......
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