Commit a340af92 authored by Marko Mäkelä's avatar Marko Mäkelä

btr_block_get(): Remove redundant parameters

parent 5d0bab47
...@@ -215,7 +215,7 @@ buf_block_t* ...@@ -215,7 +215,7 @@ buf_block_t*
btr_root_block_get( btr_root_block_get(
/*===============*/ /*===============*/
const dict_index_t* index, /*!< in: index tree */ const dict_index_t* index, /*!< in: index tree */
ulint mode, /*!< in: either RW_S_LATCH rw_lock_type_t mode, /*!< in: either RW_S_LATCH
or RW_X_LATCH */ or RW_X_LATCH */
mtr_t* mtr) /*!< in: mtr */ mtr_t* mtr) /*!< in: mtr */
{ {
...@@ -223,10 +223,7 @@ btr_root_block_get( ...@@ -223,10 +223,7 @@ btr_root_block_get(
return NULL; return NULL;
} }
buf_block_t* block = btr_block_get( buf_block_t* block = btr_block_get(*index, index->page, mode, mtr);
page_id_t(index->table->space_id, index->page),
index->table->space->zip_size(), mode,
*index, mtr);
if (!block) { if (!block) {
index->table->file_unreadable = true; index->table->file_unreadable = true;
...@@ -354,11 +351,8 @@ btr_root_adjust_on_import( ...@@ -354,11 +351,8 @@ btr_root_adjust_on_import(
dberr_t err; dberr_t err;
mtr_t mtr; mtr_t mtr;
page_t* page; page_t* page;
buf_block_t* block;
page_zip_des_t* page_zip; page_zip_des_t* page_zip;
dict_table_t* table = index->table; dict_table_t* table = index->table;
const page_id_t page_id(table->space_id, index->page);
const ulint zip_size = table->space->zip_size();
DBUG_EXECUTE_IF("ib_import_trigger_corruption_3", DBUG_EXECUTE_IF("ib_import_trigger_corruption_3",
return(DB_CORRUPTION);); return(DB_CORRUPTION););
...@@ -367,7 +361,17 @@ btr_root_adjust_on_import( ...@@ -367,7 +361,17 @@ btr_root_adjust_on_import(
mtr_set_log_mode(&mtr, MTR_LOG_NO_REDO); mtr_set_log_mode(&mtr, MTR_LOG_NO_REDO);
block = btr_block_get(page_id, zip_size, RW_X_LATCH, *index, &mtr); buf_block_t* block = buf_page_get_gen(
page_id_t(table->space->id, index->page),
table->space->zip_size(), RW_X_LATCH, NULL, BUF_GET,
__FILE__, __LINE__,
&mtr, &err);
if (!block) {
ut_ad(err != DB_SUCCESS);
goto func_exit;
}
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
page = buf_block_get_frame(block); page = buf_block_get_frame(block);
page_zip = buf_block_get_page_zip(block); page_zip = buf_block_get_page_zip(block);
...@@ -418,6 +422,7 @@ btr_root_adjust_on_import( ...@@ -418,6 +422,7 @@ btr_root_adjust_on_import(
err = DB_CORRUPTION; err = DB_CORRUPTION;
} }
func_exit:
mtr_commit(&mtr); mtr_commit(&mtr);
return(err); return(err);
...@@ -827,10 +832,8 @@ btr_node_ptr_get_child( ...@@ -827,10 +832,8 @@ btr_node_ptr_get_child(
== page_get_space_id(page_align(node_ptr))); == page_get_space_id(page_align(node_ptr)));
return btr_block_get( return btr_block_get(
page_id_t(index->table->space_id, *index, btr_node_ptr_get_child_page_no(node_ptr, offsets),
btr_node_ptr_get_child_page_no(node_ptr, offsets)), RW_SX_LATCH, mtr);
index->table->space->zip_size(),
RW_SX_LATCH, *index, mtr);
} }
/************************************************************//** /************************************************************//**
...@@ -2564,18 +2567,14 @@ btr_attach_half_pages( ...@@ -2564,18 +2567,14 @@ btr_attach_half_pages(
prev_page_no = btr_page_get_prev(page, mtr); prev_page_no = btr_page_get_prev(page, mtr);
next_page_no = btr_page_get_next(page, mtr); next_page_no = btr_page_get_next(page, mtr);
const ulint space = block->page.id.space();
/* for consistency, both blocks should be locked, before change */ /* for consistency, both blocks should be locked, before change */
if (prev_page_no != FIL_NULL && direction == FSP_DOWN) { if (prev_page_no != FIL_NULL && direction == FSP_DOWN) {
prev_block = btr_block_get( prev_block = btr_block_get(*index, prev_page_no, RW_X_LATCH,
page_id_t(space, prev_page_no), block->zip_size(), mtr);
RW_X_LATCH, *index, mtr);
} }
if (next_page_no != FIL_NULL && direction != FSP_DOWN) { if (next_page_no != FIL_NULL && direction != FSP_DOWN) {
next_block = btr_block_get( next_block = btr_block_get(*index, next_page_no, RW_X_LATCH,
page_id_t(space, next_page_no), block->zip_size(), mtr);
RW_X_LATCH, *index, mtr);
} }
/* Get the level of the split pages */ /* Get the level of the split pages */
...@@ -2721,11 +2720,11 @@ btr_insert_into_right_sibling( ...@@ -2721,11 +2720,11 @@ btr_insert_into_right_sibling(
rec_t* rec = NULL; rec_t* rec = NULL;
ulint max_size; ulint max_size;
const ulint space = block->page.id.space(); next_block = btr_block_get(*cursor->index, next_page_no, RW_X_LATCH,
mtr);
next_block = btr_block_get( if (UNIV_UNLIKELY(!next_block)) {
page_id_t(space, next_page_no), block->zip_size(), return NULL;
RW_X_LATCH, *cursor->index, mtr); }
next_page = buf_block_get_frame(next_block); next_page = buf_block_get_frame(next_block);
bool is_leaf = page_is_leaf(next_page); bool is_leaf = page_is_leaf(next_page);
...@@ -3262,12 +3261,8 @@ void btr_level_list_remove(const buf_block_t& block, const dict_index_t& index, ...@@ -3262,12 +3261,8 @@ void btr_level_list_remove(const buf_block_t& block, const dict_index_t& index,
/* Update page links of the level */ /* Update page links of the level */
if (prev_page_no != FIL_NULL) { if (prev_page_no != FIL_NULL) {
buf_block_t* prev_block buf_block_t* prev_block = btr_block_get(
= btr_block_get(page_id_t(index.table->space->id, index, prev_page_no, RW_X_LATCH, mtr);
prev_page_no),
block.zip_size(), RW_X_LATCH,
index, mtr);
page_t* prev_page page_t* prev_page
= buf_block_get_frame(prev_block); = buf_block_get_frame(prev_block);
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
...@@ -3283,9 +3278,7 @@ void btr_level_list_remove(const buf_block_t& block, const dict_index_t& index, ...@@ -3283,9 +3278,7 @@ void btr_level_list_remove(const buf_block_t& block, const dict_index_t& index,
if (next_page_no != FIL_NULL) { if (next_page_no != FIL_NULL) {
buf_block_t* next_block = btr_block_get( buf_block_t* next_block = btr_block_get(
page_id_t(index.table->space->id, next_page_no), index, next_page_no, RW_X_LATCH, mtr);
block.zip_size(), RW_X_LATCH, index, mtr);
page_t* next_page page_t* next_page
= buf_block_get_frame(next_block); = buf_block_get_frame(next_block);
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
...@@ -4250,13 +4243,10 @@ btr_discard_page( ...@@ -4250,13 +4243,10 @@ btr_discard_page(
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), mtr);
right_page_no = btr_page_get_next(buf_block_get_frame(block), mtr); right_page_no = btr_page_get_next(buf_block_get_frame(block), mtr);
const ulint zip_size = index->table->space->zip_size();
ut_d(bool parent_is_different = false); ut_d(bool parent_is_different = false);
if (left_page_no != FIL_NULL) { if (left_page_no != FIL_NULL) {
merge_block = btr_block_get( merge_block = btr_block_get(*index, left_page_no, RW_X_LATCH,
page_id_t(index->table->space_id, left_page_no), mtr);
zip_size, RW_X_LATCH, *index, mtr);
merge_page = buf_block_get_frame(merge_block); merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(merge_page, mtr) ut_a(btr_page_get_next(merge_page, mtr)
...@@ -4269,10 +4259,8 @@ btr_discard_page( ...@@ -4269,10 +4259,8 @@ btr_discard_page(
&parent_cursor))) &parent_cursor)))
== btr_cur_get_rec(&parent_cursor))); == btr_cur_get_rec(&parent_cursor)));
} else if (right_page_no != FIL_NULL) { } else if (right_page_no != FIL_NULL) {
merge_block = btr_block_get( merge_block = btr_block_get(*index, right_page_no, RW_X_LATCH,
page_id_t(index->table->space_id, right_page_no), mtr);
zip_size, RW_X_LATCH, *index, mtr);
merge_page = buf_block_get_frame(merge_block); merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(merge_page, mtr) ut_a(btr_page_get_prev(merge_page, mtr)
...@@ -4875,7 +4863,6 @@ btr_validate_level( ...@@ -4875,7 +4863,6 @@ btr_validate_level(
page = buf_block_get_frame(block); page = buf_block_get_frame(block);
fil_space_t* space = index->table->space; fil_space_t* space = index->table->space;
const ulint zip_size = space->zip_size();
while (level != btr_page_get_level(page)) { while (level != btr_page_get_level(page)) {
const rec_t* node_ptr; const rec_t* node_ptr;
...@@ -4925,11 +4912,8 @@ btr_validate_level( ...@@ -4925,11 +4912,8 @@ btr_validate_level(
&mtr, savepoint2, block); &mtr, savepoint2, block);
savepoint2 = mtr_set_savepoint(&mtr); savepoint2 = mtr_set_savepoint(&mtr);
block = btr_block_get( block = btr_block_get(*index, left_page_no,
page_id_t(index->table->space_id, RW_SX_LATCH, &mtr);
left_page_no),
zip_size,
RW_SX_LATCH, *index, &mtr);
page = buf_block_get_frame(block); page = buf_block_get_frame(block);
left_page_no = btr_page_get_prev(page, &mtr); left_page_no = btr_page_get_prev(page, &mtr);
} }
...@@ -4997,11 +4981,8 @@ btr_validate_level( ...@@ -4997,11 +4981,8 @@ btr_validate_level(
const rec_t* right_rec; const rec_t* right_rec;
savepoint = mtr_set_savepoint(&mtr); savepoint = mtr_set_savepoint(&mtr);
right_block = btr_block_get( right_block = btr_block_get(*index, right_page_no, RW_SX_LATCH,
page_id_t(index->table->space_id, right_page_no), &mtr);
zip_size,
RW_SX_LATCH, *index, &mtr);
right_page = buf_block_get_frame(right_block); right_page = buf_block_get_frame(right_block);
if (btr_page_get_prev(right_page, &mtr) if (btr_page_get_prev(right_page, &mtr)
...@@ -5174,17 +5155,11 @@ btr_validate_level( ...@@ -5174,17 +5155,11 @@ btr_validate_level(
mtr_release_block_at_savepoint( mtr_release_block_at_savepoint(
&mtr, savepoint, right_block); &mtr, savepoint, right_block);
btr_block_get( btr_block_get(*index, parent_right_page_no,
page_id_t(index->table->space_id, RW_SX_LATCH, &mtr);
parent_right_page_no), right_block = btr_block_get(*index,
zip_size, right_page_no,
RW_SX_LATCH, *index, &mtr); RW_SX_LATCH, &mtr);
right_block = btr_block_get(
page_id_t(index->table->space_id,
right_page_no),
zip_size,
RW_SX_LATCH, *index, &mtr);
} }
btr_cur_position( btr_cur_position(
...@@ -5257,27 +5232,18 @@ btr_validate_level( ...@@ -5257,27 +5232,18 @@ btr_validate_level(
if (!lockout) { if (!lockout) {
if (rightmost_child) { if (rightmost_child) {
if (parent_right_page_no != FIL_NULL) { if (parent_right_page_no != FIL_NULL) {
btr_block_get( btr_block_get(*index,
page_id_t( parent_right_page_no,
index->table->space_id, RW_SX_LATCH, &mtr);
parent_right_page_no),
zip_size,
RW_SX_LATCH, *index, &mtr);
} }
} else if (parent_page_no != FIL_NULL) { } else if (parent_page_no != FIL_NULL) {
btr_block_get( btr_block_get(*index, parent_page_no,
page_id_t(index->table->space_id, RW_SX_LATCH, &mtr);
parent_page_no),
zip_size,
RW_SX_LATCH, *index, &mtr);
} }
} }
block = btr_block_get( block = btr_block_get(*index, right_page_no, RW_SX_LATCH,
page_id_t(index->table->space_id, right_page_no), &mtr);
zip_size,
RW_SX_LATCH, *index, &mtr);
page = buf_block_get_frame(block); page = buf_block_get_frame(block);
goto loop; goto loop;
...@@ -5380,10 +5346,7 @@ btr_can_merge_with_page( ...@@ -5380,10 +5346,7 @@ btr_can_merge_with_page(
index = btr_cur_get_index(cursor); index = btr_cur_get_index(cursor);
page = btr_cur_get_page(cursor); page = btr_cur_get_page(cursor);
const page_id_t page_id(index->table->space_id, page_no); mblock = btr_block_get(*index, page_no, RW_X_LATCH, mtr);
const ulint zip_size = index->table->space->zip_size();
mblock = btr_block_get(page_id, zip_size, RW_X_LATCH, *index, mtr);
mpage = buf_block_get_frame(mblock); mpage = buf_block_get_frame(mblock);
n_recs = page_get_n_recs(page); n_recs = page_get_n_recs(page);
...@@ -5399,7 +5362,7 @@ btr_can_merge_with_page( ...@@ -5399,7 +5362,7 @@ btr_can_merge_with_page(
/* If compression padding tells us that merging will result in /* If compression padding tells us that merging will result in
too packed up page i.e.: which is likely to cause compression too packed up page i.e.: which is likely to cause compression
failure then don't merge the pages. */ failure then don't merge the pages. */
if (zip_size && page_is_leaf(mpage) if (mblock->page.zip.data && page_is_leaf(mpage)
&& (page_get_data_size(mpage) + data_size && (page_get_data_size(mpage) + data_size
>= dict_index_zip_pad_optimal_page_size(index))) { >= dict_index_zip_pad_optimal_page_size(index))) {
......
...@@ -119,10 +119,8 @@ PageBulk::init() ...@@ -119,10 +119,8 @@ PageBulk::init()
m_index->id, &m_mtr); m_index->id, &m_mtr);
} }
} else { } else {
new_block = btr_block_get( new_block = btr_block_get(*m_index, m_page_no, RW_X_LATCH,
page_id_t(m_index->table->space_id, m_page_no), &m_mtr);
m_index->table->space->zip_size(),
RW_X_LATCH, *m_index, &m_mtr);
new_page = buf_block_get_frame(new_block); new_page = buf_block_get_frame(new_block);
new_page_zip = buf_block_get_page_zip(new_block); new_page_zip = buf_block_get_page_zip(new_block);
...@@ -1015,10 +1013,8 @@ BtrBulk::finish(dberr_t err) ...@@ -1015,10 +1013,8 @@ BtrBulk::finish(dberr_t err)
mtr_x_lock(&m_index->lock, &mtr); mtr_x_lock(&m_index->lock, &mtr);
ut_ad(last_page_no != FIL_NULL); ut_ad(last_page_no != FIL_NULL);
last_block = btr_block_get( last_block = btr_block_get(*m_index, last_page_no, RW_X_LATCH,
page_id_t(m_index->table->space_id, last_page_no), &mtr);
m_index->table->space->zip_size(),
RW_X_LATCH, *m_index, &mtr);
first_rec = page_rec_get_next( first_rec = page_rec_get_next(
page_get_infimum_rec(last_block->frame)); page_get_infimum_rec(last_block->frame));
ut_ad(page_rec_is_user_rec(first_rec)); ut_ad(page_rec_is_user_rec(first_rec));
......
...@@ -209,8 +209,6 @@ btr_rec_free_externally_stored_fields( ...@@ -209,8 +209,6 @@ btr_rec_free_externally_stored_fields(
/** Latches the leaf page or pages requested. /** Latches the leaf page or pages requested.
@param[in] block leaf page where the search converged @param[in] block leaf page where the search converged
@param[in] page_id page id of the leaf
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] latch_mode BTR_SEARCH_LEAF, ... @param[in] latch_mode BTR_SEARCH_LEAF, ...
@param[in] cursor cursor @param[in] cursor cursor
@param[in] mtr mini-transaction @param[in] mtr mini-transaction
...@@ -218,13 +216,11 @@ btr_rec_free_externally_stored_fields( ...@@ -218,13 +216,11 @@ btr_rec_free_externally_stored_fields(
btr_latch_leaves_t btr_latch_leaves_t
btr_cur_latch_leaves( btr_cur_latch_leaves(
buf_block_t* block, buf_block_t* block,
const page_id_t page_id,
ulint zip_size,
ulint latch_mode, ulint latch_mode,
btr_cur_t* cursor, btr_cur_t* cursor,
mtr_t* mtr) mtr_t* mtr)
{ {
ulint mode; rw_lock_type_t mode;
ulint left_page_no; ulint left_page_no;
ulint right_page_no; ulint right_page_no;
buf_block_t* get_block; buf_block_t* get_block;
...@@ -235,6 +231,7 @@ btr_cur_latch_leaves( ...@@ -235,6 +231,7 @@ btr_cur_latch_leaves(
compile_time_assert(int(MTR_MEMO_PAGE_S_FIX) == int(RW_S_LATCH)); compile_time_assert(int(MTR_MEMO_PAGE_S_FIX) == int(RW_S_LATCH));
compile_time_assert(int(MTR_MEMO_PAGE_X_FIX) == int(RW_X_LATCH)); compile_time_assert(int(MTR_MEMO_PAGE_X_FIX) == int(RW_X_LATCH));
compile_time_assert(int(MTR_MEMO_PAGE_SX_FIX) == int(RW_SX_LATCH)); compile_time_assert(int(MTR_MEMO_PAGE_SX_FIX) == int(RW_SX_LATCH));
ut_ad(block->page.id.space() == cursor->index->table->space->id);
spatial = dict_index_is_spatial(cursor->index) && cursor->rtr_info; spatial = dict_index_is_spatial(cursor->index) && cursor->rtr_info;
ut_ad(buf_page_in_file(&block->page)); ut_ad(buf_page_in_file(&block->page));
...@@ -250,8 +247,8 @@ btr_cur_latch_leaves( ...@@ -250,8 +247,8 @@ btr_cur_latch_leaves(
mode = latch_mode == BTR_MODIFY_LEAF ? RW_X_LATCH : RW_S_LATCH; mode = latch_mode == BTR_MODIFY_LEAF ? RW_X_LATCH : RW_S_LATCH;
latch_leaves.savepoints[1] = mtr_set_savepoint(mtr); latch_leaves.savepoints[1] = mtr_set_savepoint(mtr);
get_block = btr_block_get(page_id, zip_size, mode, get_block = btr_block_get(*cursor->index,
*cursor->index, mtr); block->page.id.page_no(), mode, mtr);
latch_leaves.blocks[1] = get_block; latch_leaves.blocks[1] = get_block;
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(get_block->frame) == page_is_comp(page)); ut_a(page_is_comp(get_block->frame) == page_is_comp(page));
...@@ -271,7 +268,6 @@ btr_cur_latch_leaves( ...@@ -271,7 +268,6 @@ btr_cur_latch_leaves(
MTR_MEMO_X_LOCK | MTR_MEMO_SX_LOCK)); MTR_MEMO_X_LOCK | MTR_MEMO_SX_LOCK));
/* x-latch also siblings from left to right */ /* 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, mtr);
mode = latch_mode;
if (left_page_no != FIL_NULL) { if (left_page_no != FIL_NULL) {
...@@ -282,8 +278,7 @@ btr_cur_latch_leaves( ...@@ -282,8 +278,7 @@ btr_cur_latch_leaves(
latch_leaves.savepoints[0] = mtr_set_savepoint(mtr); latch_leaves.savepoints[0] = mtr_set_savepoint(mtr);
get_block = btr_block_get( get_block = btr_block_get(
page_id_t(page_id.space(), left_page_no), *cursor->index, left_page_no, RW_X_LATCH, mtr);
zip_size, RW_X_LATCH, *cursor->index, mtr);
latch_leaves.blocks[0] = get_block; latch_leaves.blocks[0] = get_block;
if (spatial) { if (spatial) {
...@@ -299,7 +294,8 @@ btr_cur_latch_leaves( ...@@ -299,7 +294,8 @@ btr_cur_latch_leaves(
latch_leaves.savepoints[1] = mtr_set_savepoint(mtr); latch_leaves.savepoints[1] = mtr_set_savepoint(mtr);
get_block = btr_block_get( get_block = btr_block_get(
page_id, zip_size, RW_X_LATCH, *cursor->index, mtr); *cursor->index, block->page.id.page_no(),
RW_X_LATCH, mtr);
latch_leaves.blocks[1] = get_block; latch_leaves.blocks[1] = get_block;
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
...@@ -328,9 +324,9 @@ btr_cur_latch_leaves( ...@@ -328,9 +324,9 @@ btr_cur_latch_leaves(
mtr); mtr);
} }
latch_leaves.savepoints[2] = mtr_set_savepoint(mtr); latch_leaves.savepoints[2] = mtr_set_savepoint(mtr);
get_block = btr_block_get( get_block = btr_block_get(*cursor->index,
page_id_t(page_id.space(), right_page_no), right_page_no, RW_X_LATCH,
zip_size, RW_X_LATCH, *cursor->index, mtr); mtr);
latch_leaves.blocks[2] = get_block; latch_leaves.blocks[2] = get_block;
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(get_block->frame) ut_a(page_is_comp(get_block->frame)
...@@ -357,8 +353,7 @@ btr_cur_latch_leaves( ...@@ -357,8 +353,7 @@ btr_cur_latch_leaves(
if (left_page_no != FIL_NULL) { if (left_page_no != FIL_NULL) {
latch_leaves.savepoints[0] = mtr_set_savepoint(mtr); latch_leaves.savepoints[0] = mtr_set_savepoint(mtr);
get_block = btr_block_get( get_block = btr_block_get(
page_id_t(page_id.space(), left_page_no), *cursor->index, left_page_no, mode, mtr);
zip_size, mode, *cursor->index, mtr);
latch_leaves.blocks[0] = get_block; latch_leaves.blocks[0] = get_block;
cursor->left_block = get_block; cursor->left_block = get_block;
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
...@@ -370,8 +365,8 @@ btr_cur_latch_leaves( ...@@ -370,8 +365,8 @@ btr_cur_latch_leaves(
} }
latch_leaves.savepoints[1] = mtr_set_savepoint(mtr); latch_leaves.savepoints[1] = mtr_set_savepoint(mtr);
get_block = btr_block_get(page_id, zip_size, mode, get_block = btr_block_get(*cursor->index,
*cursor->index, mtr); block->page.id.page_no(), mode, mtr);
latch_leaves.blocks[1] = get_block; latch_leaves.blocks[1] = get_block;
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(get_block->frame) == page_is_comp(page)); ut_a(page_is_comp(get_block->frame) == page_is_comp(page));
...@@ -729,7 +724,7 @@ btr_cur_optimistic_latch_leaves( ...@@ -729,7 +724,7 @@ btr_cur_optimistic_latch_leaves(
unsigned line, unsigned line,
mtr_t* mtr) mtr_t* mtr)
{ {
ulint mode; rw_lock_type_t mode;
ulint left_page_no; ulint left_page_no;
switch (*latch_mode) { switch (*latch_mode) {
...@@ -761,15 +756,10 @@ btr_cur_optimistic_latch_leaves( ...@@ -761,15 +756,10 @@ btr_cur_optimistic_latch_leaves(
buf_block_get_frame(block), mtr); buf_block_get_frame(block), mtr);
rw_lock_s_unlock(&block->lock); rw_lock_s_unlock(&block->lock);
if (left_page_no != FIL_NULL) { cursor->left_block = left_page_no != FIL_NULL
cursor->left_block = btr_block_get( ? btr_block_get(*cursor->index, left_page_no, mode,
page_id_t(cursor->index->table->space_id, mtr)
left_page_no), : NULL;
cursor->index->table->space->zip_size(),
mode, *cursor->index, mtr);
} else {
cursor->left_block = NULL;
}
if (buf_page_optimistic_get(mode, block, modify_clock, if (buf_page_optimistic_get(mode, block, modify_clock,
file, line, mtr)) { file, line, mtr)) {
...@@ -1787,10 +1777,8 @@ btr_cur_search_to_nth_level_func( ...@@ -1787,10 +1777,8 @@ btr_cur_search_to_nth_level_func(
if (height == 0) { if (height == 0) {
if (rw_latch == RW_NO_LATCH) { if (rw_latch == RW_NO_LATCH) {
latch_leaves = btr_cur_latch_leaves( latch_leaves = btr_cur_latch_leaves(
block, page_id, zip_size, latch_mode, block, latch_mode, cursor, mtr);
cursor, mtr);
} }
switch (latch_mode) { switch (latch_mode) {
...@@ -2346,20 +2334,12 @@ btr_cur_search_to_nth_level_func( ...@@ -2346,20 +2334,12 @@ btr_cur_search_to_nth_level_func(
ut_ad(!autoinc); ut_ad(!autoinc);
if (upper_rw_latch == RW_NO_LATCH) { if (upper_rw_latch == RW_NO_LATCH) {
/* latch the page */ ut_ad(latch_mode == BTR_CONT_MODIFY_TREE
buf_block_t* child_block; || latch_mode == BTR_CONT_SEARCH_TREE);
buf_block_t* child_block = btr_block_get(
if (latch_mode == BTR_CONT_MODIFY_TREE) { *index, page_id.page_no(),
child_block = btr_block_get( latch_mode == BTR_CONT_MODIFY_TREE
page_id, zip_size, RW_X_LATCH, ? RW_X_LATCH : RW_SX_LATCH, mtr);
*index, mtr);
} else {
ut_ad(latch_mode == BTR_CONT_SEARCH_TREE);
child_block = btr_block_get(
page_id, zip_size, RW_SX_LATCH,
*index, mtr);
}
btr_assert_not_corrupted(child_block, index); btr_assert_not_corrupted(child_block, index);
} else { } else {
ut_ad(mtr_memo_contains(mtr, block, upper_rw_latch)); ut_ad(mtr_memo_contains(mtr, block, upper_rw_latch));
...@@ -2653,13 +2633,11 @@ btr_cur_open_at_index_side_func( ...@@ -2653,13 +2633,11 @@ btr_cur_open_at_index_side_func(
if (height == level) { if (height == level) {
if (srv_read_only_mode) { if (srv_read_only_mode) {
btr_cur_latch_leaves( btr_cur_latch_leaves(
block, page_id, zip_size, block, latch_mode, cursor, mtr);
latch_mode, cursor, mtr);
} else if (height == 0) { } else if (height == 0) {
if (rw_latch == RW_NO_LATCH) { if (rw_latch == RW_NO_LATCH) {
btr_cur_latch_leaves( btr_cur_latch_leaves(block, latch_mode,
block, page_id, zip_size, cursor, mtr);
latch_mode, cursor, mtr);
} }
/* In versions <= 3.23.52 we had /* In versions <= 3.23.52 we had
forgotten to release the tree latch forgotten to release the tree latch
...@@ -3007,9 +2985,8 @@ btr_cur_open_at_rnd_pos_func( ...@@ -3007,9 +2985,8 @@ btr_cur_open_at_rnd_pos_func(
if (height == 0) { if (height == 0) {
if (rw_latch == RW_NO_LATCH if (rw_latch == RW_NO_LATCH
|| srv_read_only_mode) { || srv_read_only_mode) {
btr_cur_latch_leaves( btr_cur_latch_leaves(block, latch_mode, cursor,
block, page_id, zip_size, mtr);
latch_mode, cursor, mtr);
} }
/* btr_cur_open_at_index_side_func() and /* btr_cur_open_at_index_side_func() and
...@@ -7474,9 +7451,7 @@ struct btr_blob_log_check_t { ...@@ -7474,9 +7451,7 @@ struct btr_blob_log_check_t {
if (m_op == BTR_STORE_INSERT_BULK) { if (m_op == BTR_STORE_INSERT_BULK) {
mtr_x_lock(dict_index_get_lock(index), m_mtr); mtr_x_lock(dict_index_get_lock(index), m_mtr);
m_pcur->btr_cur.page_cur.block = btr_block_get( m_pcur->btr_cur.page_cur.block = btr_block_get(
page_id_t(index->table->space_id, page_no), *index, page_no, RW_X_LATCH, m_mtr);
index->table->space->zip_size(),
RW_X_LATCH, *index, m_mtr);
m_pcur->btr_cur.page_cur.rec m_pcur->btr_cur.page_cur.rec
= m_pcur->btr_cur.page_cur.block->frame = m_pcur->btr_cur.page_cur.block->frame
+ offs; + offs;
......
...@@ -162,11 +162,7 @@ btr_defragment_add_index( ...@@ -162,11 +162,7 @@ btr_defragment_add_index(
*err = DB_SUCCESS; *err = DB_SUCCESS;
mtr_start(&mtr); mtr_start(&mtr);
// Load index rood page. buf_block_t* block = btr_root_block_get(index, RW_NO_LATCH, &mtr);
buf_block_t* block = btr_block_get(
page_id_t(index->table->space_id, index->page),
index->table->space->zip_size(),
RW_NO_LATCH, *index, &mtr);
page_t* page = NULL; page_t* page = NULL;
if (block) { if (block) {
...@@ -369,7 +365,7 @@ btr_defragment_calc_n_recs_for_size( ...@@ -369,7 +365,7 @@ btr_defragment_calc_n_recs_for_size(
Merge as many records from the from_block to the to_block. Delete Merge as many records from the from_block to the to_block. Delete
the from_block if all records are successfully merged to to_block. the from_block if all records are successfully merged to to_block.
@return the to_block to target for next merge operation. */ @return the to_block to target for next merge operation. */
UNIV_INTERN static
buf_block_t* buf_block_t*
btr_defragment_merge_pages( btr_defragment_merge_pages(
dict_index_t* index, /*!< in: index tree */ dict_index_t* index, /*!< in: index tree */
...@@ -589,9 +585,7 @@ btr_defragment_n_pages( ...@@ -589,9 +585,7 @@ btr_defragment_n_pages(
break; break;
} }
blocks[i] = btr_block_get(page_id_t(index->table->space_id, blocks[i] = btr_block_get(*index, page_no, RW_X_LATCH, mtr);
page_no), zip_size,
RW_X_LATCH, *index, mtr);
} }
if (n_pages == 1) { if (n_pages == 1) {
......
...@@ -439,29 +439,23 @@ btr_pcur_move_to_next_page( ...@@ -439,29 +439,23 @@ btr_pcur_move_to_next_page(
last record of the current page */ last record of the current page */
mtr_t* mtr) /*!< in: mtr */ mtr_t* mtr) /*!< in: mtr */
{ {
ulint next_page_no;
page_t* page;
buf_block_t* next_block;
page_t* next_page;
ulint mode;
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
ut_ad(btr_pcur_is_after_last_on_page(cursor)); ut_ad(btr_pcur_is_after_last_on_page(cursor));
cursor->old_stored = false; cursor->old_stored = false;
page = btr_pcur_get_page(cursor); const page_t* page = btr_pcur_get_page(cursor);
if (UNIV_UNLIKELY(!page)) { if (UNIV_UNLIKELY(!page)) {
return; return;
} }
next_page_no = btr_page_get_next(page, mtr); const ulint next_page_no = mach_read_from_4(page + FIL_PAGE_NEXT);
ut_ad(next_page_no != FIL_NULL); ut_ad(next_page_no != FIL_NULL);
mode = cursor->latch_mode; ulint mode = cursor->latch_mode;
switch (mode) { switch (mode) {
case BTR_SEARCH_TREE: case BTR_SEARCH_TREE:
mode = BTR_SEARCH_LEAF; mode = BTR_SEARCH_LEAF;
...@@ -470,18 +464,14 @@ btr_pcur_move_to_next_page( ...@@ -470,18 +464,14 @@ btr_pcur_move_to_next_page(
mode = BTR_MODIFY_LEAF; mode = BTR_MODIFY_LEAF;
} }
buf_block_t* block = btr_pcur_get_block(cursor); buf_block_t* next_block = btr_block_get(
*btr_pcur_get_btr_cur(cursor)->index, next_page_no, mode, mtr);
next_block = btr_block_get(
page_id_t(block->page.id.space(), next_page_no),
block->zip_size(), mode,
*btr_pcur_get_btr_cur(cursor)->index, mtr);
if (UNIV_UNLIKELY(!next_block)) { if (UNIV_UNLIKELY(!next_block)) {
return; return;
} }
next_page = buf_block_get_frame(next_block); const page_t* next_page = buf_block_get_frame(next_block);
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(next_page) == page_is_comp(page)); ut_a(page_is_comp(next_page) == page_is_comp(page));
ut_a(btr_page_get_prev(next_page, mtr) ut_a(btr_page_get_prev(next_page, mtr)
......
...@@ -434,7 +434,6 @@ btr_pessimistic_scrub( ...@@ -434,7 +434,6 @@ btr_pessimistic_scrub(
const ulint page_no = mach_read_from_4(page + FIL_PAGE_OFFSET); const ulint page_no = mach_read_from_4(page + FIL_PAGE_OFFSET);
const ulint left_page_no = mach_read_from_4(page + FIL_PAGE_PREV); const ulint left_page_no = mach_read_from_4(page + FIL_PAGE_PREV);
const ulint right_page_no = mach_read_from_4(page + FIL_PAGE_NEXT); const ulint right_page_no = mach_read_from_4(page + FIL_PAGE_NEXT);
const ulint zip_size = index->table->space->zip_size();
/** /**
* When splitting page, we need X-latches on left/right brothers * When splitting page, we need X-latches on left/right brothers
...@@ -449,16 +448,12 @@ btr_pessimistic_scrub( ...@@ -449,16 +448,12 @@ btr_pessimistic_scrub(
*/ */
mtr->release_block_at_savepoint(scrub_data->savepoint, block); mtr->release_block_at_savepoint(scrub_data->savepoint, block);
btr_block_get( btr_block_get(*index, left_page_no, RW_X_LATCH, mtr);
page_id_t(index->table->space_id, left_page_no),
zip_size, RW_X_LATCH, *index, mtr);
/** /**
* Refetch block and re-initialize page * Refetch block and re-initialize page
*/ */
block = btr_block_get( block = btr_block_get(*index, page_no, RW_X_LATCH, mtr);
page_id_t(index->table->space_id, page_no),
zip_size, RW_X_LATCH, *index, mtr);
page = buf_block_get_frame(block); page = buf_block_get_frame(block);
...@@ -470,9 +465,7 @@ btr_pessimistic_scrub( ...@@ -470,9 +465,7 @@ btr_pessimistic_scrub(
} }
if (right_page_no != FIL_NULL) { if (right_page_no != FIL_NULL) {
btr_block_get( btr_block_get(*index, right_page_no, RW_X_LATCH, mtr);
page_id_t(index->table->space_id, right_page_no),
zip_size, RW_X_LATCH, *index, mtr);
} }
/* arguments to btr_page_split_and_insert */ /* arguments to btr_page_split_and_insert */
......
...@@ -648,7 +648,6 @@ rtr_adjust_upper_level( ...@@ -648,7 +648,6 @@ rtr_adjust_upper_level(
dtuple_t* node_ptr_upper; dtuple_t* node_ptr_upper;
ulint prev_page_no; ulint prev_page_no;
ulint next_page_no; ulint next_page_no;
ulint space;
page_cur_t* page_cursor; page_cur_t* page_cursor;
lock_prdt_t prdt; lock_prdt_t prdt;
lock_prdt_t new_prdt; lock_prdt_t new_prdt;
...@@ -752,16 +751,12 @@ rtr_adjust_upper_level( ...@@ -752,16 +751,12 @@ rtr_adjust_upper_level(
/* Get the previous and next pages of page */ /* Get the previous and next pages of page */
prev_page_no = btr_page_get_prev(page, mtr); prev_page_no = btr_page_get_prev(page, mtr);
next_page_no = btr_page_get_next(page, mtr); next_page_no = btr_page_get_next(page, mtr);
space = block->page.id.space();
ut_ad(block->zip_size() == index->table->space->zip_size()); ut_ad(block->zip_size() == index->table->space->zip_size());
/* Update page links of the level */ /* Update page links of the level */
if (prev_page_no != FIL_NULL) { if (prev_page_no != FIL_NULL) {
page_id_t prev_page_id(space, prev_page_no);
buf_block_t* prev_block = btr_block_get( buf_block_t* prev_block = btr_block_get(
prev_page_id, block->zip_size(), RW_X_LATCH, *index, prev_page_no, RW_X_LATCH, mtr);
*index, mtr);
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(prev_block->frame) == page_is_comp(page)); ut_a(page_is_comp(prev_block->frame) == page_is_comp(page));
ut_a(btr_page_get_next(prev_block->frame, mtr) ut_a(btr_page_get_next(prev_block->frame, mtr)
...@@ -774,11 +769,8 @@ rtr_adjust_upper_level( ...@@ -774,11 +769,8 @@ rtr_adjust_upper_level(
} }
if (next_page_no != FIL_NULL) { if (next_page_no != FIL_NULL) {
page_id_t next_page_id(space, next_page_no);
buf_block_t* next_block = btr_block_get( buf_block_t* next_block = btr_block_get(
next_page_id, block->zip_size(), RW_X_LATCH, *index, next_page_no, RW_X_LATCH, mtr);
*index, mtr);
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(next_block->frame) == page_is_comp(page)); 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, mtr)
...@@ -1879,16 +1871,17 @@ rtr_estimate_n_rows_in_range( ...@@ -1879,16 +1871,17 @@ rtr_estimate_n_rows_in_range(
index->set_modified(mtr); index->set_modified(mtr);
mtr_s_lock(&index->lock, &mtr); mtr_s_lock(&index->lock, &mtr);
buf_block_t* block = btr_block_get( buf_block_t* block = btr_root_block_get(index, RW_S_LATCH, &mtr);
page_id_t(index->table->space_id, index->page), if (!block) {
index->table->space->zip_size(), err_exit:
RW_S_LATCH, *index, &mtr); mtr.commit();
return HA_POS_ERROR;
}
const page_t* page = buf_block_get_frame(block); const page_t* page = buf_block_get_frame(block);
const unsigned n_recs = page_header_get_field(page, PAGE_N_RECS); const unsigned n_recs = page_header_get_field(page, PAGE_N_RECS);
if (n_recs == 0) { if (n_recs == 0) {
mtr.commit(); goto err_exit;
return(HA_POS_ERROR);
} }
/* Scan records in root page and calculate area. */ /* Scan records in root page and calculate area. */
......
...@@ -422,9 +422,7 @@ rtr_pcur_getnext_from_path( ...@@ -422,9 +422,7 @@ rtr_pcur_getnext_from_path(
btr_cur_latch_leaves( btr_cur_latch_leaves(
block, block,
page_id_t(index->table->space_id, BTR_MODIFY_TREE,
block->page.id.page_no()),
zip_size, BTR_MODIFY_TREE,
btr_cur, mtr); btr_cur, mtr);
} }
......
...@@ -217,36 +217,53 @@ btr_height_get( ...@@ -217,36 +217,53 @@ btr_height_get(
mtr_t* mtr) /*!< in/out: mini-transaction */ mtr_t* mtr) /*!< in/out: mini-transaction */
MY_ATTRIBUTE((warn_unused_result)); MY_ATTRIBUTE((warn_unused_result));
/** Gets a buffer page and declares its latching order level. /** Get an index page and declare its latching order level.
@param[in] page_id page id @param[in] index index tree
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 @param[in] page page number
@param[in] mode latch mode @param[in] mode latch mode
@param[in] file file name @param[in] file file name
@param[in] line line where called @param[in] line line where called
@param[in] index index tree
@param[in,out] mtr mini-transaction @param[in,out] mtr mini-transaction
@return block */ @return block */
UNIV_INLINE inline buf_block_t* btr_block_get_func(const dict_index_t& index, ulint page,
buf_block_t* ulint mode,
btr_block_get_func( const char* file, unsigned line,
const page_id_t page_id, mtr_t* mtr)
ulint zip_size, {
ulint mode, dberr_t err;
const char* file,
unsigned line, if (buf_block_t* block = buf_page_get_gen(
const dict_index_t& index, page_id_t(index.table->space->id, page),
mtr_t* mtr); index.table->space->zip_size(), mode, NULL, BUF_GET,
file, line, mtr, &err)) {
ut_ad(err == DB_SUCCESS);
if (mode != RW_NO_LATCH) {
buf_block_dbg_add_level(block, index.is_ibuf()
? SYNC_IBUF_TREE_NODE
: SYNC_TREE_NODE);
}
return block;
} else {
ut_ad(err != DB_SUCCESS);
if (err == DB_DECRYPTION_FAILED) {
if (index.table) {
index.table->file_unreadable = true;
}
}
return NULL;
}
}
/** Gets a buffer page and declares its latching order level. /** Gets a buffer page and declares its latching order level.
@param page_id tablespace/page identifier
@param zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param mode latch mode
@param index index tree @param index index tree
@param page page number
@param mode latch mode
@param mtr mini-transaction handle @param mtr mini-transaction handle
@return the block descriptor */ @return the block descriptor */
# define btr_block_get(page_id, zip_size, mode, index, mtr) \ # define btr_block_get(index, page, mode, mtr) \
btr_block_get_func(page_id, zip_size, mode, \ btr_block_get_func(index, page, mode, __FILE__, __LINE__, mtr)
__FILE__, __LINE__, index, mtr)
/**************************************************************//** /**************************************************************//**
Gets the index id field of a page. Gets the index id field of a page.
@return index id */ @return index id */
...@@ -689,7 +706,7 @@ buf_block_t* ...@@ -689,7 +706,7 @@ buf_block_t*
btr_root_block_get( btr_root_block_get(
/*===============*/ /*===============*/
const dict_index_t* index, /*!< in: index tree */ const dict_index_t* index, /*!< in: index tree */
ulint mode, /*!< in: either RW_S_LATCH rw_lock_type_t mode, /*!< in: either RW_S_LATCH
or RW_X_LATCH */ or RW_X_LATCH */
mtr_t* mtr); /*!< in: mtr */ mtr_t* mtr); /*!< in: mtr */
......
...@@ -29,48 +29,6 @@ Created 6/2/1994 Heikki Tuuri ...@@ -29,48 +29,6 @@ Created 6/2/1994 Heikki Tuuri
#include "mtr0log.h" #include "mtr0log.h"
#include "page0zip.h" #include "page0zip.h"
/** Gets a buffer page and declares its latching order level.
@param[in] page_id page id
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] mode latch mode
@param[in] file file name
@param[in] line line where called
@param[in] index index tree, may be NULL if it is not an insert buffer
tree
@param[in,out] mtr mini-transaction
@return block */
UNIV_INLINE
buf_block_t*
btr_block_get_func(
const page_id_t page_id,
ulint zip_size,
ulint mode,
const char* file,
unsigned line,
const dict_index_t& index,
mtr_t* mtr)
{
buf_block_t* block;
dberr_t err=DB_SUCCESS;
block = buf_page_get_gen(
page_id, zip_size, mode, NULL, BUF_GET, file, line, mtr, &err);
if (err == DB_DECRYPTION_FAILED) {
if (index.table) {
index.table->file_unreadable = true;
}
}
if (block && mode != RW_NO_LATCH) {
buf_block_dbg_add_level(block, index.is_ibuf()
? SYNC_IBUF_TREE_NODE
: SYNC_TREE_NODE);
}
return block;
}
/**************************************************************//** /**************************************************************//**
Sets the index id field of a page. */ Sets the index id field of a page. */
UNIV_INLINE UNIV_INLINE
......
...@@ -821,8 +821,6 @@ btr_rec_set_deleted_flag( ...@@ -821,8 +821,6 @@ btr_rec_set_deleted_flag(
/** Latches the leaf page or pages requested. /** Latches the leaf page or pages requested.
@param[in] block leaf page where the search converged @param[in] block leaf page where the search converged
@param[in] page_id page id of the leaf
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] latch_mode BTR_SEARCH_LEAF, ... @param[in] latch_mode BTR_SEARCH_LEAF, ...
@param[in] cursor cursor @param[in] cursor cursor
@param[in] mtr mini-transaction @param[in] mtr mini-transaction
...@@ -830,8 +828,6 @@ btr_rec_set_deleted_flag( ...@@ -830,8 +828,6 @@ btr_rec_set_deleted_flag(
btr_latch_leaves_t btr_latch_leaves_t
btr_cur_latch_leaves( btr_cur_latch_leaves(
buf_block_t* block, buf_block_t* block,
const page_id_t page_id,
ulint zip_size,
ulint latch_mode, ulint latch_mode,
btr_cur_t* cursor, btr_cur_t* cursor,
mtr_t* mtr); mtr_t* mtr);
......
...@@ -526,7 +526,8 @@ struct btr_pcur_t{ ...@@ -526,7 +526,8 @@ struct btr_pcur_t{
ulint buf_size; ulint buf_size;
btr_pcur_t() : btr_pcur_t() :
btr_cur(), latch_mode(0), old_stored(false), old_rec(NULL), btr_cur(), latch_mode(RW_NO_LATCH),
old_stored(false), old_rec(NULL),
old_n_fields(0), rel_pos(btr_pcur_pos_t(0)), old_n_fields(0), rel_pos(btr_pcur_pos_t(0)),
block_when_stored(NULL), block_when_stored(NULL),
modify_clock(0), withdraw_clock(0), modify_clock(0), withdraw_clock(0),
......
...@@ -2028,11 +2028,8 @@ row_merge_read_clustered_index( ...@@ -2028,11 +2028,8 @@ row_merge_read_clustered_index(
block = page_cur_get_block(cur); block = page_cur_get_block(cur);
block = btr_block_get( block = btr_block_get(
page_id_t(block->page.id.space(), *clust_index, next_page_no,
next_page_no), RW_S_LATCH, &mtr);
block->zip_size(),
BTR_SEARCH_LEAF,
*clust_index, &mtr);
btr_leaf_page_release(page_cur_get_block(cur), btr_leaf_page_release(page_cur_get_block(cur),
BTR_SEARCH_LEAF, &mtr); BTR_SEARCH_LEAF, &mtr);
......
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