@@ -38,6 +38,7 @@ Created 6/2/1994 Heikki Tuuri
3838#include " lock0lock.h"
3939#include " trx0trx.h"
4040#include " srv0mon.h"
41+ #include " que0que.h"
4142#include " gis0geo.h"
4243#include " dict0boot.h"
4344#include " row0sel.h" /* row_search_max_autoinc() */
@@ -371,14 +372,13 @@ btr_root_fseg_adjust_on_import(
371372
372373/* *************************************************************/ /* *
373374Checks and adjusts the root node of a tree during IMPORT TABLESPACE.
374- @return error code, or DB_SUCCESS */
375- dberr_t
376- btr_root_adjust_on_import (
377- /* ======================*/
378- const dict_index_t * index) /* !< in: index tree */
375+ @param trx transaction
376+ @param index index tree
377+ @return error code */
378+ dberr_t btr_root_adjust_on_import (trx_t *trx, const dict_index_t *index)
379379{
380380 dberr_t err;
381- mtr_t mtr;
381+ mtr_t mtr{trx} ;
382382 page_t * page;
383383 page_zip_des_t * page_zip;
384384 dict_table_t * table = index->table ;
@@ -1006,25 +1006,25 @@ btr_create(
10061006/* * Free a B-tree except the root page. The root page MUST be freed after
10071007this by calling btr_free_root.
10081008@param[in,out] block root page
1009- @param[in] log_mode mtr logging mode */
1009+ @param[in] outer_mtr surrounding mini-transaction */
10101010static
10111011void
10121012btr_free_but_not_root (
10131013 buf_block_t * block,
1014- mtr_log_t log_mode
1014+ const mtr_t & outer_mtr
10151015#ifdef BTR_CUR_HASH_ADAPT
10161016 ,bool ahi=false
10171017#endif
10181018 )
10191019{
1020- mtr_t mtr;
1020+ mtr_t mtr{outer_mtr. trx } ;
10211021
10221022 ut_ad (fil_page_index_page_check (block->page .frame ));
10231023 ut_ad (!page_has_siblings (block->page .frame ));
10241024leaf_loop:
10251025 mtr_start (&mtr);
10261026 ut_d (mtr.freeing_tree ());
1027- mtr_set_log_mode (&mtr, log_mode );
1027+ mtr_set_log_mode (&mtr, outer_mtr. get_log_mode () );
10281028 fil_space_t *space = mtr.set_named_space_id (block->page .id ().space ());
10291029
10301030 if (!btr_root_fseg_validate (FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF,
@@ -1052,7 +1052,7 @@ btr_free_but_not_root(
10521052 }
10531053top_loop:
10541054 mtr_start (&mtr);
1055- mtr_set_log_mode (&mtr, log_mode );
1055+ mtr_set_log_mode (&mtr, outer_mtr. get_log_mode () );
10561056 space = mtr.set_named_space_id (block->page .id ().space ());
10571057
10581058 finished = !btr_root_fseg_validate (FIL_PAGE_DATA + PAGE_BTR_SEG_TOP,
@@ -1071,16 +1071,13 @@ btr_free_but_not_root(
10711071 }
10721072}
10731073
1074- #ifdef BTR_CUR_HASH_ADAPT
1075- TRANSACTIONAL_TARGET
1076- #endif
10771074/* * Clear the index tree and reinitialize the root page, in the
10781075rollback of TRX_UNDO_EMPTY. The BTR_SEG_LEAF is freed and reinitialized.
10791076@param thr query thread
10801077@return error code */
10811078dberr_t dict_index_t::clear (que_thr_t *thr)
10821079{
1083- mtr_t mtr;
1080+ mtr_t mtr{ thr_get_trx (thr)} ;
10841081 mtr.start ();
10851082 if (table->is_temporary ())
10861083 mtr.set_log_mode (MTR_LOG_NO_REDO);
@@ -1101,7 +1098,7 @@ dberr_t dict_index_t::clear(que_thr_t *thr)
11011098 RW_X_LATCH, guess, BUF_GET, &mtr, &err);
11021099 if (root_block)
11031100 {
1104- btr_free_but_not_root (root_block, mtr. get_log_mode ()
1101+ btr_free_but_not_root (root_block, mtr
11051102#ifdef BTR_CUR_HASH_ADAPT
11061103 ,any_ahi_pages ()
11071104#endif
@@ -1133,19 +1130,20 @@ void btr_free_if_exists(fil_space_t *space, uint32_t page,
11331130 space->zip_size (),
11341131 index_id, mtr))
11351132 {
1136- btr_free_but_not_root (root, mtr-> get_log_mode () );
1133+ btr_free_but_not_root (root, * mtr);
11371134 mtr->set_named_space (space);
11381135 btr_free_root (root, *space, mtr);
11391136 }
11401137}
11411138
11421139/* * Drop a temporary table
1140+ @param trx transaction
11431141@param table temporary table */
1144- void btr_drop_temporary_table (const dict_table_t &table)
1142+ void btr_drop_temporary_table (trx_t *trx, const dict_table_t &table)
11451143{
11461144 ut_ad (table.is_temporary ());
11471145 ut_ad (table.space == fil_system.temp_space );
1148- mtr_t mtr;
1146+ mtr_t mtr{trx} ;
11491147 mtr.start ();
11501148 for (const dict_index_t *index= table.indexes .start ; index;
11511149 index= dict_table_get_next_index (index))
@@ -1159,8 +1157,8 @@ void btr_drop_temporary_table(const dict_table_t &table)
11591157 0 , RW_X_LATCH, guess, BUF_GET,
11601158 &mtr, nullptr ))
11611159 {
1162- btr_free_but_not_root (block, MTR_LOG_NO_REDO);
11631160 mtr.set_log_mode (MTR_LOG_NO_REDO);
1161+ btr_free_but_not_root (block, mtr);
11641162 btr_free_root (block, *fil_system.temp_space , &mtr);
11651163 mtr.commit ();
11661164 mtr.start ();
@@ -1179,7 +1177,7 @@ btr_read_autoinc(dict_index_t* index)
11791177 ut_ad (index->is_primary ());
11801178 ut_ad (index->table ->persistent_autoinc );
11811179 ut_ad (!index->table ->is_temporary ());
1182- mtr_t mtr;
1180+ mtr_t mtr{ nullptr } ;
11831181 mtr.start ();
11841182 dberr_t err;
11851183 uint64_t autoinc;
@@ -1217,7 +1215,7 @@ uint64_t btr_read_autoinc_with_fallback(const dict_table_t *table,
12171215 ut_ad (!table->is_temporary ());
12181216
12191217 uint64_t autoinc= 0 ;
1220- mtr_t mtr;
1218+ mtr_t mtr{ nullptr } ;
12211219 mtr.start ();
12221220 const dict_index_t *const first_index= dict_table_get_first_index (table);
12231221
@@ -1260,19 +1258,20 @@ uint64_t btr_read_autoinc_with_fallback(const dict_table_t *table,
12601258}
12611259
12621260/* * Write the next available AUTO_INCREMENT value to PAGE_ROOT_AUTO_INC.
1261+ @param[in,out] trx transaction
12631262@param[in,out] index clustered index
12641263@param[in] autoinc the AUTO_INCREMENT value
12651264@param[in] reset whether to reset the AUTO_INCREMENT
12661265 to a possibly smaller value than currently
12671266 exists in the page */
1268- void
1269- btr_write_autoinc ( dict_index_t * index, ib_uint64_t autoinc, bool reset)
1267+ void btr_write_autoinc ( trx_t *trx, dict_index_t *index, uint64_t autoinc,
1268+ bool reset)
12701269{
12711270 ut_ad (index->is_primary ());
12721271 ut_ad (index->table ->persistent_autoinc );
12731272 ut_ad (!index->table ->is_temporary ());
12741273
1275- mtr_t mtr;
1274+ mtr_t mtr{trx} ;
12761275 mtr.start ();
12771276 fil_space_t *space= index->table ->space ;
12781277 if (buf_block_t *root= buf_page_get (page_id_t (space->id , index->page ),
@@ -4360,8 +4359,6 @@ btr_print_index(
43604359 }
43614360
43624361 mtr_commit (&mtr);
4363-
4364- ut_ad (btr_validate_index (index, 0 ));
43654362}
43664363#endif /* UNIV_BTR_PRINT */
43674364
@@ -4706,7 +4703,7 @@ dberr_t
47064703btr_validate_level (
47074704/* ===============*/
47084705 dict_index_t * index, /* !< in: index tree */
4709- const trx_t * trx, /* !< in: transaction or NULL */
4706+ trx_t * trx, /* !< in: transaction */
47104707 ulint level) /* !< in: level number */
47114708{
47124709 buf_block_t * block;
@@ -4719,7 +4716,7 @@ btr_validate_level(
47194716 rec_t * rec;
47204717 page_cur_t cursor;
47214718 dtuple_t * node_ptr_tuple;
4722- mtr_t mtr;
4719+ mtr_t mtr{trx} ;
47234720 mem_heap_t * heap = mem_heap_create (256 );
47244721 rec_offs* offsets = NULL ;
47254722 rec_offs* offsets2= NULL ;
@@ -4744,7 +4741,7 @@ btr_validate_level(
47444741 while (level != btr_page_get_level (page)) {
47454742 const rec_t * node_ptr;
47464743 switch (dberr_t e =
4747- fseg_page_is_allocated (space,
4744+ fseg_page_is_allocated (&mtr, space,
47484745 block->page .id ().page_no ())) {
47494746 case DB_SUCCESS_LOCKED_REC:
47504747 break ;
@@ -4834,7 +4831,8 @@ btr_validate_level(
48344831#endif /* UNIV_ZIP_DEBUG */
48354832
48364833 if (DB_SUCCESS_LOCKED_REC
4837- != fseg_page_is_allocated (space, block->page .id ().page_no ())) {
4834+ != fseg_page_is_allocated (&mtr, space,
4835+ block->page .id ().page_no ())) {
48384836 btr_validate_report1 (index, level, block);
48394837
48404838 ib::warn () << " Page is marked as free" ;
@@ -5137,9 +5135,9 @@ dberr_t
51375135btr_validate_index (
51385136/* ===============*/
51395137 dict_index_t * index, /* !< in: index */
5140- const trx_t * trx) /* !< in: transaction or NULL */
5138+ trx_t * trx) /* !< in: transaction */
51415139{
5142- mtr_t mtr;
5140+ mtr_t mtr{trx} ;
51435141 mtr.start ();
51445142
51455143 mtr_x_lock_index (index, &mtr);
0 commit comments