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