Commit 1a4a7ddd authored by Marko Mäkelä's avatar Marko Mäkelä

Cleanup: Make btr_root_block_get() more robust

btr_root_block_get(): Check for index->page == FIL_NULL.

btr_root_get(): Declare static. Other callers can invoke
btr_root_block_get() directly.

btr_get_size(): Remove conditions that are checked in
btr_root_block_get().
parent 48bbc447
......@@ -219,7 +219,7 @@ btr_root_block_get(
or RW_X_LATCH */
mtr_t* mtr) /*!< in: mtr */
{
if (!index->table || !index->table->space) {
if (!index->table || !index->table->space || index->page == FIL_NULL) {
return NULL;
}
......@@ -259,6 +259,7 @@ btr_root_block_get(
/**************************************************************//**
Gets the root node of a tree and sx-latches it for segment access.
@return root page, sx-latched */
static
page_t*
btr_root_get(
/*=========*/
......@@ -578,10 +579,8 @@ btr_get_size(
|| mtr->memo_contains(index->lock, MTR_MEMO_S_LOCK));
ut_ad(flag == BTR_N_LEAF_PAGES || flag == BTR_TOTAL_SIZE);
if (index->page == FIL_NULL
|| dict_index_is_online_ddl(index)
|| !index->is_committed()
|| !index->table->space) {
if (dict_index_is_online_ddl(index)
|| !index->is_committed()) {
return(ULINT_UNDEFINED);
}
......
......@@ -411,15 +411,15 @@ static dberr_t btr_cur_instant_init_low(dict_index_t* index, mtr_t* mtr)
return DB_CORRUPTION;
}
page_t* root = btr_root_get(index, mtr);
buf_block_t* root = btr_root_block_get(index, RW_SX_LATCH, mtr);
if (!root || btr_cur_instant_root_init(index, root)) {
if (!root || btr_cur_instant_root_init(index, root->frame)) {
goto unreadable;
}
ut_ad(index->n_core_null_bytes != dict_index_t::NO_CORE_NULL_BYTES);
if (fil_page_get_type(root) == FIL_PAGE_INDEX) {
if (fil_page_get_type(root->frame) == FIL_PAGE_INDEX) {
ut_ad(!index->is_instant());
return DB_SUCCESS;
}
......
......@@ -187,16 +187,6 @@ void btr_corruption_report(const buf_block_t* block,const dict_index_t* index);
!= index->table->not_redundant()) \
btr_corruption_report(block, index)
/**************************************************************//**
Gets the root node of a tree and sx-latches it for segment access.
@return root page, sx-latched */
page_t*
btr_root_get(
/*=========*/
const dict_index_t* index, /*!< in: index tree */
mtr_t* mtr) /*!< in: mtr */
MY_ATTRIBUTE((nonnull));
/**************************************************************//**
Checks and adjusts the root node of a tree during IMPORT TABLESPACE.
@return error code, or DB_SUCCESS */
......
......@@ -914,7 +914,7 @@ row_purge_upd_exist_or_extern_func(
index->set_modified(mtr);
/* NOTE: we must also acquire an X-latch to the
/* NOTE: we must also acquire a U latch to the
root page of the tree. We will need it when we
free pages from the tree. If the tree is of height 1,
the tree X-latch does NOT protect the root page,
......@@ -923,7 +923,7 @@ row_purge_upd_exist_or_extern_func(
latching order if we would only later latch the
root page of such a tree! */
btr_root_get(index, &mtr);
btr_root_block_get(index, RW_SX_LATCH, &mtr);
block = buf_page_get(
page_id_t(rseg.space->id, page_no),
......
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