summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-09-16 12:50:55 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-09-17 14:40:41 +0300
commit1a4a7dddb6505352a7c3b4a2e1583ed92cad1dcf (patch)
treecc1fc2e13420ed52ba1021ecfb57fe2374eca449
parent48bbc447335a0b3ec698e975d48ad49145780624 (diff)
downloadmariadb-git-1a4a7dddb6505352a7c3b4a2e1583ed92cad1dcf.tar.gz
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().
-rw-r--r--storage/innobase/btr/btr0btr.cc9
-rw-r--r--storage/innobase/btr/btr0cur.cc6
-rw-r--r--storage/innobase/include/btr0btr.h10
-rw-r--r--storage/innobase/row/row0purge.cc4
4 files changed, 9 insertions, 20 deletions
diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc
index f786da84b17..56e84e47fda 100644
--- a/storage/innobase/btr/btr0btr.cc
+++ b/storage/innobase/btr/btr0btr.cc
@@ -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);
}
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index e533f93b199..adba676808c 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -411,15 +411,15 @@ unreadable:
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;
}
diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h
index 65608552986..4543fc21e8a 100644
--- a/storage/innobase/include/btr0btr.h
+++ b/storage/innobase/include/btr0btr.h
@@ -188,16 +188,6 @@ void btr_corruption_report(const buf_block_t* block,const dict_index_t* 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.
@return error code, or DB_SUCCESS */
dberr_t
diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc
index daaba10bc5a..010ec224460 100644
--- a/storage/innobase/row/row0purge.cc
+++ b/storage/innobase/row/row0purge.cc
@@ -914,7 +914,7 @@ skip_secondaries:
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 @@ skip_secondaries:
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),