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

Cleanup: Remove some page_get_page_no() calls

Refer to buf_page_t::id instead of parsing the tablespace identifier
or page number from the buffer pool page.
parent 56f6dab1
......@@ -1906,7 +1906,7 @@ btr_root_raise_and_insert(
+ root->frame, space));
}
ut_a(dict_index_get_page(index) == page_get_page_no(root->frame));
ut_a(dict_index_get_page(index) == root->page.id.page_no());
#endif /* UNIV_BTR_DEBUG */
ut_ad(mtr_memo_contains_flagged(mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK
......
......@@ -5613,17 +5613,15 @@ btr_cur_compress_if_useful(
ut_ad(mtr_memo_contains(mtr, btr_cur_get_block(cursor),
MTR_MEMO_PAGE_X_FIX));
if (dict_index_is_spatial(cursor->index)) {
const page_t* page = btr_cur_get_page(cursor);
const trx_t* trx = NULL;
if (cursor->rtr_info->thr != NULL) {
trx = thr_get_trx(cursor->rtr_info->thr);
}
if (cursor->index->is_spatial()) {
const trx_t* trx = cursor->rtr_info->thr
? thr_get_trx(cursor->rtr_info->thr)
: NULL;
const buf_block_t* block = btr_cur_get_block(cursor);
/* Check whether page lock prevents the compression */
if (!lock_test_prdt_page_lock(trx, page_get_space_id(page),
page_get_page_no(page))) {
if (!lock_test_prdt_page_lock(trx, block->page.id.space(),
block->page.id.page_no())) {
return(false);
}
}
......@@ -6127,8 +6125,6 @@ btr_cur_add_path_info(
ulint root_height) /*!< in: root node height in tree */
{
btr_path_t* slot;
const rec_t* rec;
const page_t* page;
ut_a(cursor->path_arr);
......@@ -6147,16 +6143,14 @@ btr_cur_add_path_info(
slot->nth_rec = ULINT_UNDEFINED;
}
rec = btr_cur_get_rec(cursor);
slot = cursor->path_arr + (root_height - height);
page = page_align(rec);
const buf_block_t* block = btr_cur_get_block(cursor);
slot->nth_rec = page_rec_get_n_recs_before(rec);
slot->n_recs = page_get_n_recs(page);
slot->page_no = page_get_page_no(page);
slot->page_level = btr_page_get_level(page);
slot->nth_rec = page_rec_get_n_recs_before(btr_cur_get_rec(cursor));
slot->n_recs = page_get_n_recs(block->frame);
slot->page_no = block->page.id.page_no();
slot->page_level = btr_page_get_level(block->frame);
}
/*******************************************************************//**
......@@ -7428,9 +7422,7 @@ struct btr_blob_log_check_t {
if (UNIV_UNLIKELY(m_op == BTR_STORE_INSERT_BULK)) {
offs = page_offset(*m_rec);
page_no = page_get_page_no(
buf_block_get_frame(*m_block));
page_no = (*m_block)->page.id.page_no();
buf_block_buf_fix_inc(*m_block, __FILE__, __LINE__);
} else {
btr_pcur_store_position(m_pcur, m_mtr);
......@@ -7950,40 +7942,30 @@ btr_store_big_rec_extern_fields(
return(error);
}
/*******************************************************************//**
Check the FIL_PAGE_TYPE on an uncompressed BLOB page. */
static
void
btr_check_blob_fil_page_type(
/*=========================*/
ulint space_id, /*!< in: space id */
ulint page_no, /*!< in: page number */
const page_t* page, /*!< in: page */
ibool read) /*!< in: TRUE=read, FALSE=purge */
/** Check the FIL_PAGE_TYPE on an uncompressed BLOB page.
@param[in] block uncompressed BLOB page
@param[in] read true=read, false=purge */
static void btr_check_blob_fil_page_type(const buf_block_t& block, bool read)
{
ulint type = fil_page_get_type(page);
ut_a(space_id == page_get_space_id(page));
ut_a(page_no == page_get_page_no(page));
if (UNIV_UNLIKELY(type != FIL_PAGE_TYPE_BLOB)) {
ulint flags = fil_space_get_flags(space_id);
#ifndef UNIV_DEBUG /* Improve debug test coverage */
if (!DICT_TF_HAS_ATOMIC_BLOBS(flags)) {
/* Old versions of InnoDB did not initialize
FIL_PAGE_TYPE on BLOB pages. Do not print
anything about the type mismatch when reading
a BLOB page that may be from old versions. */
return;
}
#endif /* !UNIV_DEBUG */
ib::fatal() << "FIL_PAGE_TYPE=" << type
<< " on BLOB " << (read ? "read" : "purge")
<< " space " << space_id << " page " << page_no
<< " flags " << flags;
}
uint16_t type= fil_page_get_type(block.frame);
if (UNIV_LIKELY(type == FIL_PAGE_TYPE_BLOB))
return;
/* FIXME: take the tablespace as a parameter */
if (fil_space_t *space= fil_space_acquire_silent(block.page.id.space()))
{
/* Old versions of InnoDB did not initialize FIL_PAGE_TYPE on BLOB
pages. Do not print anything about the type mismatch when reading
a BLOB page that may be from old versions. */
if (space->full_crc32() || DICT_TF_HAS_ATOMIC_BLOBS(space->flags))
{
ib::fatal() << "FIL_PAGE_TYPE=" << type
<< (read ? " on BLOB read file " : " on BLOB purge file ")
<< space->chain.start->name
<< " page " << block.page.id.page_no();
}
space->release();
}
}
/*******************************************************************//**
......@@ -8139,8 +8121,7 @@ btr_free_externally_stored_field(
}
} else {
ut_ad(!block->page.zip.data);
btr_check_blob_fil_page_type(space_id, page_no, page,
FALSE);
btr_check_blob_fil_page_type(*ext_block, false);
next_page_no = mach_read_from_4(
page + FIL_PAGE_DATA
......@@ -8277,7 +8258,7 @@ btr_copy_blob_prefix(
buf_block_dbg_add_level(block, SYNC_EXTERN_STORAGE);
page = buf_block_get_frame(block);
btr_check_blob_fil_page_type(space_id, page_no, page, TRUE);
btr_check_blob_fil_page_type(*block, true);
blob_header = page + offset;
part_len = btr_blob_get_part_len(blob_header);
......
......@@ -2094,8 +2094,7 @@ btr_search_hash_table_validate(ulint hash_table_id)
ib::error() << "Error in an adaptive hash"
<< " index pointer to page "
<< page_id_t(page_get_space_id(page),
page_get_page_no(page))
<< block->page.id
<< ", ptr mem address "
<< reinterpret_cast<const void*>(
node->data)
......
......@@ -1852,7 +1852,7 @@ fseg_create(
+ block->frame, page_offset(inode));
mtr->write<4>(*block, byte_offset + FSEG_HDR_PAGE_NO
+ block->frame, page_get_page_no(page_align(inode)));
+ block->frame, iblock->page.id.page_no());
mtr->write<4,mtr_t::OPT>(*block, byte_offset + FSEG_HDR_SPACE
+ block->frame, space->id);
......
......@@ -2434,10 +2434,8 @@ ibuf_merge_pages(
and the whole B-tree must be empty. InnoDB does not
allow empty B-tree pages other than the root. */
ut_ad(ibuf.empty);
ut_ad(page_get_space_id(btr_pcur_get_page(&pcur))
== IBUF_SPACE_ID);
ut_ad(page_get_page_no(btr_pcur_get_page(&pcur))
== FSP_IBUF_TREE_ROOT_PAGE_NO);
ut_ad(btr_pcur_get_block(&pcur)->page.id
== page_id_t(IBUF_SPACE_ID, FSP_IBUF_TREE_ROOT_PAGE_NO));
ibuf_mtr_commit(&mtr);
btr_pcur_close(&pcur);
......@@ -2495,11 +2493,8 @@ ibuf_merge_space(
and the whole B-tree must be empty. InnoDB does not
allow empty B-tree pages other than the root. */
ut_ad(ibuf.empty);
ut_ad(page_get_space_id(btr_pcur_get_page(&pcur))
== IBUF_SPACE_ID);
ut_ad(page_get_page_no(btr_pcur_get_page(&pcur))
== FSP_IBUF_TREE_ROOT_PAGE_NO);
ut_ad(btr_pcur_get_block(&pcur)->page.id
== page_id_t(IBUF_SPACE_ID, FSP_IBUF_TREE_ROOT_PAGE_NO));
} else {
sum_sizes = ibuf_get_merge_pages(
......
......@@ -137,17 +137,17 @@ btr_cur_compress_recommendation(
LIMIT_OPTIMISTIC_INSERT_DEBUG(page_get_n_recs(page) * 2U,
return(FALSE));
if (page_get_data_size(page)
< BTR_CUR_PAGE_COMPRESS_LIMIT(cursor->index)
|| !page_has_siblings(page)) {
if (!page_has_siblings(page)
|| page_get_data_size(page)
< BTR_CUR_PAGE_COMPRESS_LIMIT(cursor->index)) {
/* The page fillfactor has dropped below a predefined
minimum value OR the level in the B-tree contains just
one page: we recommend compression if this is not the
root page. */
return(dict_index_get_page(cursor->index)
!= page_get_page_no(page));
return cursor->index->page
!= btr_cur_get_block(cursor)->page.id.page_no();
}
return(FALSE);
......@@ -172,17 +172,17 @@ btr_cur_can_delete_without_compress(
page = btr_cur_get_page(cursor);
if (page_get_data_size(page) - rec_size
< BTR_CUR_PAGE_COMPRESS_LIMIT(cursor->index)
|| !page_has_siblings(page) || page_get_n_recs(page) < 2) {
if (!page_has_siblings(page) || page_get_n_recs(page) < 2
|| page_get_data_size(page) - rec_size
< BTR_CUR_PAGE_COMPRESS_LIMIT(cursor->index)) {
/* The page fillfactor will drop below a predefined
minimum value, OR the level in the B-tree contains just
one page, OR the page will become empty: we recommend
compression if this is not the root page. */
return(dict_index_get_page(cursor->index)
== page_get_page_no(page));
return cursor->index->page
== btr_cur_get_block(cursor)->page.id.page_no();
}
return(TRUE);
......
......@@ -2575,19 +2575,17 @@ page_delete_rec(
ut_ad(page_is_leaf(page));
if (!rec_offs_any_extern(offsets)
&& ((page_get_data_size(page) - rec_offs_size(offsets)
< BTR_CUR_PAGE_COMPRESS_LIMIT(index))
|| !page_has_siblings(page)
|| (page_get_n_recs(page) < 2))) {
ulint root_page_no = dict_index_get_page(index);
&& (!page_has_siblings(page)
|| (page_get_n_recs(page) < 2)
|| page_get_data_size(page) - rec_offs_size(offsets)
< BTR_CUR_PAGE_COMPRESS_LIMIT(index))) {
/* The page fillfactor will drop below a predefined
minimum value, OR the level in the B-tree contains just
one page, OR the page will become empty: we recommend
compression if this is not the root page. */
no_compress_needed = page_get_page_no(page) == root_page_no;
no_compress_needed = block->page.id.page_no() == index->page;
} else {
no_compress_needed = true;
}
......
......@@ -1363,7 +1363,7 @@ page_zip_compress(
<< " index "
<< index->name()
<< " page "
<< page_get_page_no(page)
<< block->page.id.page_no()
<< "("
<< (page_is_leaf(page) ? "leaf" : "non-leaf")
<< ")";
......
......@@ -604,26 +604,21 @@ row_purge_remove_sec_if_poss_leaf(
goto func_exit_no_pcur;
}
if (dict_index_is_spatial(index)) {
const page_t* page;
const trx_t* trx = NULL;
if (btr_cur->rtr_info != NULL
&& btr_cur->rtr_info->thr != NULL) {
trx = thr_get_trx(
btr_cur->rtr_info->thr);
}
page = btr_cur_get_page(btr_cur);
if (!lock_test_prdt_page_lock(
trx,
page_get_space_id(page),
page_get_page_no(page))
&& page_get_n_recs(page) < 2
&& btr_cur_get_block(btr_cur)
->page.id.page_no() !=
dict_index_get_page(index)) {
if (index->is_spatial()) {
const buf_block_t* block = btr_cur_get_block(
btr_cur);
if (block->page.id.page_no()
!= index->page
&& page_get_n_recs(block->frame) < 2
&& !lock_test_prdt_page_lock(
btr_cur->rtr_info
&& btr_cur->rtr_info->thr
? thr_get_trx(
btr_cur->rtr_info->thr)
: NULL,
block->page.id.space(),
block->page.id.page_no())) {
/* this is the last record on page,
and it has a "page" lock on it,
which mean search is still depending
......@@ -631,8 +626,7 @@ row_purge_remove_sec_if_poss_leaf(
DBUG_LOG("purge",
"skip purging last"
" record on page "
<< btr_cur_get_block(btr_cur)
->page.id);
<< block->page.id);
btr_pcur_close(&pcur);
mtr.commit();
......
......@@ -4762,14 +4762,13 @@ row_search_mvcc(
ib::error() << "Rec address "
<< static_cast<const void*>(rec)
<< ", buf block fix count "
<< btr_cur_get_block(
btr_pcur_get_btr_cur(pcur))->page
<< btr_pcur_get_block(pcur)->page
.buf_fix_count;
ib::error() << "Index corruption: rec offs "
<< page_offset(rec) << " next offs "
<< next_offs << ", page no "
<< page_get_page_no(page_align(rec))
<< btr_pcur_get_block(pcur)->page.id.page_no()
<< ", index " << index->name
<< " of table " << index->table->name
<< ". Run CHECK TABLE. You may need to"
......@@ -4786,7 +4785,7 @@ row_search_mvcc(
ib::info() << "Index corruption: rec offs "
<< page_offset(rec) << " next offs "
<< next_offs << ", page no "
<< page_get_page_no(page_align(rec))
<< btr_pcur_get_block(pcur)->page.id.page_no()
<< ", index " << index->name
<< " of table " << index->table->name
<< ". We try to skip the rest of the page.";
......@@ -4814,7 +4813,7 @@ row_search_mvcc(
ib::error() << "Index corruption: rec offs "
<< page_offset(rec) << " next offs "
<< next_offs << ", page no "
<< page_get_page_no(page_align(rec))
<< btr_pcur_get_block(pcur)->page.id.page_no()
<< ", index " << index->name
<< " of table " << index->table->name
<< ". We try to skip the record.";
......
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