summaryrefslogtreecommitdiff
path: root/storage/innobase/dict
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2022-11-16 09:43:48 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2022-11-16 09:43:48 +0200
commit89ec4b53ac4c7568b9c9765fff50d9bec7cf3534 (patch)
treef1d62effdb84f1407a465b82799dff3e2bd69484 /storage/innobase/dict
parent6b2d6a81d463f64472715126e69d90aa54811873 (diff)
downloadmariadb-git-89ec4b53ac4c7568b9c9765fff50d9bec7cf3534.tar.gz
MDEV-29603: Implement btr_cur_t::open_leaf()
btr_cur_t::open_leaf(): Replaces btr_cur_open_at_index_side() for most calls, except dict_stats_analyze_index(), which is the only place where we need to open a page at the non-leaf level. Use btr_block_get() for better error handling. Also, use the enumeration type btr_latch_mode wherever possible. Reviewed by: Vladislav Lesin
Diffstat (limited to 'storage/innobase/dict')
-rw-r--r--storage/innobase/dict/dict0load.cc5
-rw-r--r--storage/innobase/dict/dict0stats.cc27
2 files changed, 24 insertions, 8 deletions
diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc
index ce31721bd72..b7f245a3787 100644
--- a/storage/innobase/dict/dict0load.cc
+++ b/storage/innobase/dict/dict0load.cc
@@ -215,8 +215,9 @@ dict_startscan_system(
mtr_t* mtr, /*!< in: the mini-transaction */
dict_table_t* table) /*!< in: system table */
{
- if (btr_pcur_open_at_index_side(true, table->indexes.start, BTR_SEARCH_LEAF,
- pcur, true, 0, mtr) != DB_SUCCESS)
+ btr_pcur_init(pcur);
+ if (pcur->open_leaf(true, table->indexes.start, BTR_SEARCH_LEAF, mtr) !=
+ DB_SUCCESS)
return nullptr;
const rec_t *rec;
do
diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc
index 6e70cbf7547..a5806de7b6a 100644
--- a/storage/innobase/dict/dict0stats.cc
+++ b/storage/innobase/dict/dict0stats.cc
@@ -1560,6 +1560,25 @@ empty_table:
return err;
}
+/** Open persistent cursor at the first page in a tree level.
+@param index B-tree index
+@param pcur persistent cursor
+@param level level to search for (0=leaf)
+@param mtr mini-transaction */
+static dberr_t btr_pcur_open_level(dict_index_t *index, btr_pcur_t *pcur,
+ ulint level, mtr_t *mtr)
+{
+ btr_pcur_init(pcur);
+ pcur->trx_if_known= nullptr;
+ pcur->latch_mode= BTR_SEARCH_TREE;
+ pcur->search_mode= PAGE_CUR_G;
+ pcur->pos_state= BTR_PCUR_IS_POSITIONED;
+
+ return btr_cur_open_at_index_side(true, index,
+ BTR_SEARCH_TREE_ALREADY_S_LATCHED,
+ btr_pcur_get_btr_cur(pcur), level, mtr);
+}
+
/* @{ Pseudo code about the relation between the following functions
let N = N_SAMPLE_PAGES(index)
@@ -1649,9 +1668,7 @@ dict_stats_analyze_index_level(
/* Position pcur on the leftmost record on the leftmost page
on the desired level. */
- if (btr_pcur_open_at_index_side(
- true, index, BTR_SEARCH_TREE_ALREADY_S_LATCHED,
- &pcur, true, level, mtr) != DB_SUCCESS
+ if (btr_pcur_open_level(index, &pcur, level, mtr) != DB_SUCCESS
|| !btr_pcur_move_to_next_on_page(&pcur)) {
goto func_exit;
}
@@ -2289,9 +2306,7 @@ dict_stats_analyze_index_for_n_prefix(
n_diff_data->n_diff_all_analyzed_pages = 0;
n_diff_data->n_external_pages_sum = 0;
- if (btr_pcur_open_at_index_side(true, index,
- BTR_SEARCH_TREE_ALREADY_S_LATCHED,
- &pcur, true, n_diff_data->level, mtr)
+ if (btr_pcur_open_level(index, &pcur, n_diff_data->level, mtr)
!= DB_SUCCESS
|| !btr_pcur_move_to_next_on_page(&pcur)) {
return;