Commit 5d0bab47 authored by Marko Mäkelä's avatar Marko Mäkelä

btr_block_get(), btr_block_get_func(): Change the parameter to

const dict_index_t&

btr_level_list_remove(): Clean up the parameters. Renamed from
btr_level_list_remove_func().
parent fba9883b
......@@ -226,7 +226,7 @@ btr_root_block_get(
buf_block_t* block = btr_block_get(
page_id_t(index->table->space_id, index->page),
index->table->space->zip_size(), mode,
index, mtr);
*index, mtr);
if (!block) {
index->table->file_unreadable = true;
......@@ -367,7 +367,7 @@ btr_root_adjust_on_import(
mtr_set_log_mode(&mtr, MTR_LOG_NO_REDO);
block = btr_block_get(page_id, zip_size, RW_X_LATCH, index, &mtr);
block = btr_block_get(page_id, zip_size, RW_X_LATCH, *index, &mtr);
page = buf_block_get_frame(block);
page_zip = buf_block_get_page_zip(block);
......@@ -830,7 +830,7 @@ btr_node_ptr_get_child(
page_id_t(index->table->space_id,
btr_node_ptr_get_child_page_no(node_ptr, offsets)),
index->table->space->zip_size(),
RW_SX_LATCH, index, mtr);
RW_SX_LATCH, *index, mtr);
}
/************************************************************//**
......@@ -2570,12 +2570,12 @@ btr_attach_half_pages(
if (prev_page_no != FIL_NULL && direction == FSP_DOWN) {
prev_block = btr_block_get(
page_id_t(space, prev_page_no), block->zip_size(),
RW_X_LATCH, index, mtr);
RW_X_LATCH, *index, mtr);
}
if (next_page_no != FIL_NULL && direction != FSP_DOWN) {
next_block = btr_block_get(
page_id_t(space, next_page_no), block->zip_size(),
RW_X_LATCH, index, mtr);
RW_X_LATCH, *index, mtr);
}
/* Get the level of the split pages */
......@@ -2725,7 +2725,7 @@ btr_insert_into_right_sibling(
next_block = btr_block_get(
page_id_t(space, next_page_no), block->zip_size(),
RW_X_LATCH, cursor->index, mtr);
RW_X_LATCH, *cursor->index, mtr);
next_page = buf_block_get_frame(next_block);
bool is_leaf = page_is_leaf(next_page);
......@@ -3244,25 +3244,18 @@ btr_page_split_and_insert(
}
/** Remove a page from the level list of pages.
@param[in] space space where removed
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in,out] page page to remove
@param[in] block page to remove
@param[in] index index tree
@param[in,out] mtr mini-transaction */
void
btr_level_list_remove_func(
ulint space,
ulint zip_size,
page_t* page,
dict_index_t* index,
mtr_t* mtr)
void btr_level_list_remove(const buf_block_t& block, const dict_index_t& index,
mtr_t* mtr)
{
ut_ad(page != NULL);
ut_ad(mtr != NULL);
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX));
ut_ad(space == page_get_space_id(page));
ut_ad(mtr_memo_contains(mtr, &block, MTR_MEMO_PAGE_X_FIX));
ut_ad(block.zip_size() == index.table->space->zip_size());
ut_ad(index.table->space->id == block.page.id.space());
/* Get the previous and next page numbers of page */
const page_t* page = block.frame;
const ulint prev_page_no = btr_page_get_prev(page, mtr);
const ulint next_page_no = btr_page_get_next(page, mtr);
......@@ -3270,8 +3263,10 @@ btr_level_list_remove_func(
if (prev_page_no != FIL_NULL) {
buf_block_t* prev_block
= btr_block_get(page_id_t(space, prev_page_no),
zip_size, RW_X_LATCH, index, mtr);
= btr_block_get(page_id_t(index.table->space->id,
prev_page_no),
block.zip_size(), RW_X_LATCH,
index, mtr);
page_t* prev_page
= buf_block_get_frame(prev_block);
......@@ -3287,10 +3282,9 @@ btr_level_list_remove_func(
}
if (next_page_no != FIL_NULL) {
buf_block_t* next_block
= btr_block_get(
page_id_t(space, next_page_no), zip_size,
RW_X_LATCH, index, mtr);
buf_block_t* next_block = btr_block_get(
page_id_t(index.table->space->id, next_page_no),
block.zip_size(), RW_X_LATCH, index, mtr);
page_t* next_page
= buf_block_get_frame(next_block);
......@@ -3631,8 +3625,6 @@ btr_compress(
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
const ulint zip_size = index->table->space->zip_size();
MONITOR_INC(MONITOR_INDEX_MERGE_ATTEMPTS);
left_page_no = btr_page_get_prev(page, mtr);
......@@ -3788,8 +3780,7 @@ btr_compress(
btr_search_drop_page_hash_index(block);
/* Remove the page from the level list */
btr_level_list_remove(index->table->space_id,
zip_size, page, index, mtr);
btr_level_list_remove(*block, *index, mtr);
if (dict_index_is_spatial(index)) {
rec_t* my_rec = father_cursor.page_cur.rec;
......@@ -3918,8 +3909,7 @@ btr_compress(
#endif /* UNIV_BTR_DEBUG */
/* Remove the page from the level list */
btr_level_list_remove(index->table->space_id,
zip_size, page, index, mtr);
btr_level_list_remove(*block, *index, mtr);
ut_ad(btr_node_ptr_get_child_page_no(
btr_cur_get_rec(&father_cursor), offsets)
......@@ -4027,7 +4017,7 @@ btr_compress(
committed mini-transaction, because in crash recovery,
the free bits could momentarily be set too high. */
if (zip_size) {
if (merge_block->zip_size()) {
/* Because the free bits may be incremented
and we cannot update the insert buffer bitmap
in the same mini-transaction, the only safe
......@@ -4087,9 +4077,8 @@ btr_compress(
err_exit:
/* We play it safe and reset the free bits. */
if (zip_size
&& merge_page
&& page_is_leaf(merge_page)
if (merge_block && merge_block->zip_size()
&& page_is_leaf(merge_block->frame)
&& !dict_index_is_clust(index)) {
ibuf_reset_free_bits(merge_block);
......@@ -4266,7 +4255,7 @@ btr_discard_page(
if (left_page_no != FIL_NULL) {
merge_block = btr_block_get(
page_id_t(index->table->space_id, left_page_no),
zip_size, RW_X_LATCH, index, mtr);
zip_size, RW_X_LATCH, *index, mtr);
merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG
......@@ -4282,7 +4271,7 @@ btr_discard_page(
} else if (right_page_no != FIL_NULL) {
merge_block = btr_block_get(
page_id_t(index->table->space_id, right_page_no),
zip_size, RW_X_LATCH, index, mtr);
zip_size, RW_X_LATCH, *index, mtr);
merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG
......@@ -4324,8 +4313,7 @@ btr_discard_page(
}
/* Remove the page from the level list */
btr_level_list_remove(index->table->space_id, zip_size,
page, index, mtr);
btr_level_list_remove(*block, *index, mtr);
#ifdef UNIV_ZIP_DEBUG
{
......@@ -4941,7 +4929,7 @@ btr_validate_level(
page_id_t(index->table->space_id,
left_page_no),
zip_size,
RW_SX_LATCH, index, &mtr);
RW_SX_LATCH, *index, &mtr);
page = buf_block_get_frame(block);
left_page_no = btr_page_get_prev(page, &mtr);
}
......@@ -5012,7 +5000,7 @@ btr_validate_level(
right_block = btr_block_get(
page_id_t(index->table->space_id, right_page_no),
zip_size,
RW_SX_LATCH, index, &mtr);
RW_SX_LATCH, *index, &mtr);
right_page = buf_block_get_frame(right_block);
......@@ -5190,13 +5178,13 @@ btr_validate_level(
page_id_t(index->table->space_id,
parent_right_page_no),
zip_size,
RW_SX_LATCH, index, &mtr);
RW_SX_LATCH, *index, &mtr);
right_block = btr_block_get(
page_id_t(index->table->space_id,
right_page_no),
zip_size,
RW_SX_LATCH, index, &mtr);
RW_SX_LATCH, *index, &mtr);
}
btr_cur_position(
......@@ -5274,21 +5262,21 @@ btr_validate_level(
index->table->space_id,
parent_right_page_no),
zip_size,
RW_SX_LATCH, index, &mtr);
RW_SX_LATCH, *index, &mtr);
}
} else if (parent_page_no != FIL_NULL) {
btr_block_get(
page_id_t(index->table->space_id,
parent_page_no),
zip_size,
RW_SX_LATCH, index, &mtr);
RW_SX_LATCH, *index, &mtr);
}
}
block = btr_block_get(
page_id_t(index->table->space_id, right_page_no),
zip_size,
RW_SX_LATCH, index, &mtr);
RW_SX_LATCH, *index, &mtr);
page = buf_block_get_frame(block);
......@@ -5395,7 +5383,7 @@ btr_can_merge_with_page(
const page_id_t page_id(index->table->space_id, page_no);
const ulint zip_size = index->table->space->zip_size();
mblock = btr_block_get(page_id, zip_size, RW_X_LATCH, index, mtr);
mblock = btr_block_get(page_id, zip_size, RW_X_LATCH, *index, mtr);
mpage = buf_block_get_frame(mblock);
n_recs = page_get_n_recs(page);
......
......@@ -122,7 +122,7 @@ PageBulk::init()
new_block = btr_block_get(
page_id_t(m_index->table->space_id, m_page_no),
m_index->table->space->zip_size(),
RW_X_LATCH, m_index, &m_mtr);
RW_X_LATCH, *m_index, &m_mtr);
new_page = buf_block_get_frame(new_block);
new_page_zip = buf_block_get_page_zip(new_block);
......@@ -1018,7 +1018,7 @@ BtrBulk::finish(dberr_t err)
last_block = btr_block_get(
page_id_t(m_index->table->space_id, last_page_no),
m_index->table->space->zip_size(),
RW_X_LATCH, m_index, &mtr);
RW_X_LATCH, *m_index, &mtr);
first_rec = page_rec_get_next(
page_get_infimum_rec(last_block->frame));
ut_ad(page_rec_is_user_rec(first_rec));
......
......@@ -251,7 +251,7 @@ btr_cur_latch_leaves(
mode = latch_mode == BTR_MODIFY_LEAF ? RW_X_LATCH : RW_S_LATCH;
latch_leaves.savepoints[1] = mtr_set_savepoint(mtr);
get_block = btr_block_get(page_id, zip_size, mode,
cursor->index, mtr);
*cursor->index, mtr);
latch_leaves.blocks[1] = get_block;
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(get_block->frame) == page_is_comp(page));
......@@ -283,7 +283,7 @@ btr_cur_latch_leaves(
latch_leaves.savepoints[0] = mtr_set_savepoint(mtr);
get_block = btr_block_get(
page_id_t(page_id.space(), left_page_no),
zip_size, RW_X_LATCH, cursor->index, mtr);
zip_size, RW_X_LATCH, *cursor->index, mtr);
latch_leaves.blocks[0] = get_block;
if (spatial) {
......@@ -299,7 +299,7 @@ btr_cur_latch_leaves(
latch_leaves.savepoints[1] = mtr_set_savepoint(mtr);
get_block = btr_block_get(
page_id, zip_size, RW_X_LATCH, cursor->index, mtr);
page_id, zip_size, RW_X_LATCH, *cursor->index, mtr);
latch_leaves.blocks[1] = get_block;
#ifdef UNIV_BTR_DEBUG
......@@ -330,7 +330,7 @@ btr_cur_latch_leaves(
latch_leaves.savepoints[2] = mtr_set_savepoint(mtr);
get_block = btr_block_get(
page_id_t(page_id.space(), right_page_no),
zip_size, RW_X_LATCH, cursor->index, mtr);
zip_size, RW_X_LATCH, *cursor->index, mtr);
latch_leaves.blocks[2] = get_block;
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(get_block->frame)
......@@ -358,7 +358,7 @@ btr_cur_latch_leaves(
latch_leaves.savepoints[0] = mtr_set_savepoint(mtr);
get_block = btr_block_get(
page_id_t(page_id.space(), left_page_no),
zip_size, mode, cursor->index, mtr);
zip_size, mode, *cursor->index, mtr);
latch_leaves.blocks[0] = get_block;
cursor->left_block = get_block;
#ifdef UNIV_BTR_DEBUG
......@@ -371,7 +371,7 @@ btr_cur_latch_leaves(
latch_leaves.savepoints[1] = mtr_set_savepoint(mtr);
get_block = btr_block_get(page_id, zip_size, mode,
cursor->index, mtr);
*cursor->index, mtr);
latch_leaves.blocks[1] = get_block;
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(get_block->frame) == page_is_comp(page));
......@@ -766,7 +766,7 @@ btr_cur_optimistic_latch_leaves(
page_id_t(cursor->index->table->space_id,
left_page_no),
cursor->index->table->space->zip_size(),
mode, cursor->index, mtr);
mode, *cursor->index, mtr);
} else {
cursor->left_block = NULL;
}
......@@ -2352,12 +2352,12 @@ btr_cur_search_to_nth_level_func(
if (latch_mode == BTR_CONT_MODIFY_TREE) {
child_block = btr_block_get(
page_id, zip_size, RW_X_LATCH,
index, 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);
*index, mtr);
}
btr_assert_not_corrupted(child_block, index);
......@@ -7476,7 +7476,7 @@ struct btr_blob_log_check_t {
m_pcur->btr_cur.page_cur.block = btr_block_get(
page_id_t(index->table->space_id, page_no),
index->table->space->zip_size(),
RW_X_LATCH, index, m_mtr);
RW_X_LATCH, *index, m_mtr);
m_pcur->btr_cur.page_cur.rec
= m_pcur->btr_cur.page_cur.block->frame
+ offs;
......
......@@ -166,7 +166,7 @@ btr_defragment_add_index(
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);
RW_NO_LATCH, *index, &mtr);
page_t* page = NULL;
if (block) {
......@@ -487,9 +487,7 @@ btr_defragment_merge_pages(
lock_update_merge_left(to_block, orig_pred,
from_block);
btr_search_drop_page_hash_index(from_block);
btr_level_list_remove(
index->table->space_id,
zip_size, from_page, index, mtr);
btr_level_list_remove(*from_block, *index, mtr);
btr_page_get_father(index, from_block, mtr, &parent);
btr_cur_node_ptr_delete(&parent, mtr);
/* btr_blob_dbg_remove(from_page, index,
......@@ -593,7 +591,7 @@ btr_defragment_n_pages(
blocks[i] = btr_block_get(page_id_t(index->table->space_id,
page_no), zip_size,
RW_X_LATCH, index, mtr);
RW_X_LATCH, *index, mtr);
}
if (n_pages == 1) {
......
......@@ -475,7 +475,7 @@ btr_pcur_move_to_next_page(
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);
*btr_pcur_get_btr_cur(cursor)->index, mtr);
if (UNIV_UNLIKELY(!next_block)) {
return;
......
......@@ -451,14 +451,14 @@ btr_pessimistic_scrub(
btr_block_get(
page_id_t(index->table->space_id, left_page_no),
zip_size, RW_X_LATCH, index, mtr);
zip_size, RW_X_LATCH, *index, mtr);
/**
* Refetch block and re-initialize page
*/
block = btr_block_get(
page_id_t(index->table->space_id, page_no),
zip_size, RW_X_LATCH, index, mtr);
zip_size, RW_X_LATCH, *index, mtr);
page = buf_block_get_frame(block);
......@@ -472,7 +472,7 @@ btr_pessimistic_scrub(
if (right_page_no != FIL_NULL) {
btr_block_get(
page_id_t(index->table->space_id, right_page_no),
zip_size, RW_X_LATCH, index, mtr);
zip_size, RW_X_LATCH, *index, mtr);
}
/* arguments to btr_page_split_and_insert */
......
......@@ -761,7 +761,7 @@ rtr_adjust_upper_level(
buf_block_t* prev_block = btr_block_get(
prev_page_id, block->zip_size(), RW_X_LATCH,
index, mtr);
*index, mtr);
#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)
......@@ -778,7 +778,7 @@ rtr_adjust_upper_level(
buf_block_t* next_block = btr_block_get(
next_page_id, block->zip_size(), RW_X_LATCH,
index, mtr);
*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)
......@@ -1882,7 +1882,7 @@ rtr_estimate_n_rows_in_range(
buf_block_t* block = btr_block_get(
page_id_t(index->table->space_id, index->page),
index->table->space->zip_size(),
RW_S_LATCH, index, &mtr);
RW_S_LATCH, *index, &mtr);
const page_t* page = buf_block_get_frame(block);
const unsigned n_recs = page_header_get_field(page, PAGE_N_RECS);
......
......@@ -223,8 +223,7 @@ btr_height_get(
@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] index index tree
@param[in,out] mtr mini-transaction
@return block */
UNIV_INLINE
......@@ -235,19 +234,19 @@ btr_block_get_func(
ulint mode,
const char* file,
unsigned line,
dict_index_t* index,
const dict_index_t& index,
mtr_t* mtr);
/** 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, may be NULL if not the insert buffer tree
@param index index tree
@param mtr mini-transaction handle
@return the block descriptor */
# define btr_block_get(page_id, zip_size, mode, index, mtr) \
btr_block_get_func(page_id, zip_size, mode, \
__FILE__, __LINE__, (dict_index_t*)index, mtr)
__FILE__, __LINE__, index, mtr)
/**************************************************************//**
Gets the index id field of a page.
@return index id */
......@@ -763,28 +762,11 @@ btr_validate_index(
MY_ATTRIBUTE((warn_unused_result));
/** Remove a page from the level list of pages.
@param[in] space space where removed
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in,out] page page to remove
@param[in] block page to remove
@param[in] index index tree
@param[in,out] mtr mini-transaction */
void
btr_level_list_remove_func(
ulint space,
ulint zip_size,
page_t* page,
dict_index_t* index,
mtr_t* mtr);
/*************************************************************//**
Removes a page from the level list of pages.
@param space in: space where removed
@param zip_size in: compressed page size in bytes, or 0 for uncompressed
@param page in/out: page to remove
@param index in: index tree
@param mtr in/out: mini-transaction */
# define btr_level_list_remove(space,zip_size,page,index,mtr) \
btr_level_list_remove_func(space,zip_size,page,index,mtr)
void btr_level_list_remove(const buf_block_t& block, const dict_index_t& index,
mtr_t* mtr);
/*************************************************************//**
If page is the only on its level, this function moves its records to the
......
......@@ -47,7 +47,7 @@ btr_block_get_func(
ulint mode,
const char* file,
unsigned line,
dict_index_t* index,
const dict_index_t& index,
mtr_t* mtr)
{
buf_block_t* block;
......@@ -57,21 +57,18 @@ btr_block_get_func(
page_id, zip_size, mode, NULL, BUF_GET, file, line, mtr, &err);
if (err == DB_DECRYPTION_FAILED) {
if (index && index->table) {
index->table->file_unreadable = true;
if (index.table) {
index.table->file_unreadable = true;
}
}
if (block) {
if (mode != RW_NO_LATCH) {
buf_block_dbg_add_level(
block, index != NULL && dict_index_is_ibuf(index)
? SYNC_IBUF_TREE_NODE : SYNC_TREE_NODE);
}
if (block && mode != RW_NO_LATCH) {
buf_block_dbg_add_level(block, index.is_ibuf()
? SYNC_IBUF_TREE_NODE
: SYNC_TREE_NODE);
}
return(block);
return block;
}
/**************************************************************//**
......
......@@ -437,9 +437,9 @@ buf_page_t* buf_page_get_zip(const page_id_t page_id, ulint zip_size);
@param[in] guess guessed block or NULL
@param[in] mode BUF_GET, BUF_GET_IF_IN_POOL,
BUF_PEEK_IF_IN_POOL, BUF_GET_NO_LATCH, or BUF_GET_IF_IN_POOL_OR_WATCH
@param[in] file file name
@param[in] line line where called
@param[in] mtr mini-transaction
@param[in] file file name of caller
@param[in] line line number of caller
@param[in,out] mtr mini-transaction
@param[out] err DB_SUCCESS or error code
@return pointer to the block or NULL */
buf_block_t*
......
......@@ -2032,7 +2032,7 @@ row_merge_read_clustered_index(
next_page_no),
block->zip_size(),
BTR_SEARCH_LEAF,
clust_index, &mtr);
*clust_index, &mtr);
btr_leaf_page_release(page_cur_get_block(cur),
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