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