diff options
author | apostle <vladkakurin007@gmail.com> | 2022-05-28 16:19:15 +0000 |
---|---|---|
committer | apostle <vladkakurin007@gmail.com> | 2022-05-28 16:19:15 +0000 |
commit | d58425d40e9f9ab73484909e9b79c33bbd7b9d67 (patch) | |
tree | 582361639bab05c4db5c71b5a57ba5fe684fbe26 | |
parent | 0bbdd4071a761eaa6b88f0a97e00244cce111e0c (diff) | |
download | mariadb-git-d58425d40e9f9ab73484909e9b79c33bbd7b9d67.tar.gz |
fixs
-rw-r--r-- | storage/innobase/btr/btr0cur.cc | 16 | ||||
-rw-r--r-- | storage/innobase/dict/dict0stats.cc | 4 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 7 | ||||
-rw-r--r-- | storage/innobase/ibuf/ibuf0ibuf.cc | 6 | ||||
-rw-r--r-- | storage/innobase/include/btr0cur.h | 11 | ||||
-rw-r--r-- | storage/innobase/include/btr0pcur.h | 8 | ||||
-rw-r--r-- | storage/innobase/include/btr0pcur.inl | 14 |
7 files changed, 34 insertions, 32 deletions
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index dd2dd7c36bc..128afeb9ff7 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -2849,12 +2849,12 @@ btr_cur_open_at_index_side( /**********************************************************************//** Positions a cursor at a randomly chosen position within a B-tree. -@return true if the index is available and we have put the cursor, false -if the index is unavailable. Cursor->page_cur->rec can be null if -simulate_uniform=true, which means that no record is chosen in the +@return DB_SUCCESS if the index is available and we have put the cursor, +error code if the index is unavailable. If simulate_uniform=true, could be +DB_RECORD_NOT_FOUND returned, which means that no record is chosen in the generated tree path. The caller should retry a call, that will try a new tree path */ -bool +dberr_t btr_cur_open_at_rnd_pos( dict_index_t* index, /*!< in: index */ ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ... */ @@ -2926,7 +2926,7 @@ btr_cur_open_at_rnd_pos( } DBUG_EXECUTE_IF("test_index_is_unavailable", - return(false);); + return(DB_ERROR);); if (index->page == FIL_NULL) { /* Since we don't hold index lock until just now, the index @@ -2934,7 +2934,7 @@ btr_cur_open_at_rnd_pos( statistics updater for referenced table, it could be marked as unavailable by 'DROP TABLE' in the mean time, since we don't hold lock for statistics updater */ - return(false); + return(DB_ERROR); } const rw_lock_type_t root_leaf_rw_latch = btr_cur_latch_for_root_leaf( @@ -3157,9 +3157,9 @@ btr_cur_open_at_rnd_pos( // and exchange division by multiplication like // (b / c) < a <=> b < (a * c) if(sim_uniform_dist && (ut_rnd_gen() < (p * ~(uint32_t)0))) - page_cursor->rec = NULL; + err = DB_RECORD_NOT_FOUND; - return err == DB_SUCCESS; + return err; } /*==================== B-TREE INSERT =========================*/ diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc index 6869ad42332..b720d9a422b 100644 --- a/storage/innobase/dict/dict0stats.cc +++ b/storage/innobase/dict/dict0stats.cc @@ -1224,12 +1224,12 @@ btr_estimate_number_of_different_key_vals(dict_index_t* index, for (i = 0; i < n_sample_pages; i++) { mtr.start(); - bool available; + dberr_t available; available = btr_cur_open_at_rnd_pos(index, BTR_SEARCH_LEAF, &cursor, &mtr, false); - if (!available || index->table->bulk_trx_id != bulk_trx_id) { + if (available != DB_SUCCESS || index->table->bulk_trx_id != bulk_trx_id) { mtr.commit(); mem_heap_free(heap); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index de45166d501..aedb35dad75 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -9522,19 +9522,20 @@ ha_innobase::sample_next( btr_pcur_t* pcur= m_prebuilt->pcur; rec_t* rec; bool res; + dberr_t err; rec_offs offsets_[REC_OFFS_NORMAL_SIZE]; rec_offs* offsets= offsets_; rec_offs_init(offsets_); dict_index_t* index= innobase_get_index(MAX_KEY); mtr.start(); - res= btr_pcur_open_at_rnd_pos(index, BTR_SEARCH_LEAF, pcur, &mtr, true); + err= btr_pcur_open_at_rnd_pos(index, BTR_SEARCH_LEAF, pcur, &mtr, true); mtr.commit(); - if(!res || !(rec= btr_pcur_get_rec(pcur))) + if(err != DB_SUCCESS) { return HA_ERR_KEY_NOT_FOUND; } - + rec= btr_pcur_get_rec(pcur); mem_heap_t* heap= NULL; auto _ = make_scope_exit([heap]() { if(heap) mem_heap_free(heap); }); diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index aa35c0866f2..b08fc6a9893 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -2386,12 +2386,12 @@ ibuf_merge_pages( /* Open a cursor to a randomly chosen leaf of the tree, at a random position within the leaf */ - bool available; + dberr_t err; - available = btr_pcur_open_at_rnd_pos(ibuf.index, BTR_SEARCH_LEAF, + err = btr_pcur_open_at_rnd_pos(ibuf.index, BTR_SEARCH_LEAF, &pcur, &mtr, false); /* No one should make this index unavailable when server is running */ - ut_a(available); + ut_a(err == DB_SUCCESS); ut_ad(page_validate(btr_pcur_get_page(&pcur), ibuf.index)); diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h index 93a6756971f..45875f7a6e5 100644 --- a/storage/innobase/include/btr0cur.h +++ b/storage/innobase/include/btr0cur.h @@ -207,11 +207,12 @@ btr_cur_open_at_index_side( /**********************************************************************//** Positions a cursor at a randomly chosen position within a B-tree. -@return true if the index is available and we have put the cursor, false -if the index is unavailable. Cursor->page_cur->rec can be null if -simulate_uniform=true,which means that no record is chosen in the generated -tree path. The caller should retry a call, that will try a new tree path */ -bool +@return DB_SUCCESS if the index is available and we have put the cursor, +error code if the index is unavailable. If simulate_uniform=true, could be +DB_RECORD_NOT_FOUND returned, which means that no record is chosen in the +generated tree path. The caller should retry a call, that will +try a new tree path */ +dberr_t btr_cur_open_at_rnd_pos( dict_index_t* index, /*!< in: index */ ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ... */ diff --git a/storage/innobase/include/btr0pcur.h b/storage/innobase/include/btr0pcur.h index 3da840fe1a2..eed0cb86dec 100644 --- a/storage/innobase/include/btr0pcur.h +++ b/storage/innobase/include/btr0pcur.h @@ -200,13 +200,13 @@ btr_pcur_open_on_user_rec( mtr_t* mtr); /*!< in: mtr */ /**********************************************************************//** Positions a cursor at a randomly chosen position within a B-tree. -@return true if the index is available and we have put the cursor, false -if the index is unavailable. Cursor->btr_cur->page_cur->rec can be null if -simulate_uniform=true, which means that no record is chosen in the +@return DB_SUCCESS if the index is available and we have put the cursor, +error code if the index is unavailable. If simulate_uniform=true, could be +DB_RECORD_NOT_FOUND returned, which means that no record is chosen in the generated tree path. The caller should retry a call, that will try a new tree path */ UNIV_INLINE -bool +dberr_t btr_pcur_open_at_rnd_pos( dict_index_t* index, /*!< in: index */ ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ... */ diff --git a/storage/innobase/include/btr0pcur.inl b/storage/innobase/include/btr0pcur.inl index be77c7c87f0..9e8ac321137 100644 --- a/storage/innobase/include/btr0pcur.inl +++ b/storage/innobase/include/btr0pcur.inl @@ -479,13 +479,13 @@ btr_pcur_open_at_index_side( /**********************************************************************//** Positions a cursor at a randomly chosen position within a B-tree. -@return true if the index is available and we have put the cursor, false -if the index is unavailable. Cursor->btr_cur->page_cur->rec can be null if -simulate_uniform=true, which means that no record is chosen in the +@return DB_SUCCESS if the index is available and we have put the cursor, +error code if the index is unavailable. If simulate_uniform=true, could be +DB_RECORD_NOT_FOUND returned, which means that no record is chosen in the generated tree path. The caller should retry a call, that will try a new tree path */ UNIV_INLINE -bool +dberr_t btr_pcur_open_at_rnd_pos( dict_index_t* index, /*!< in: index */ ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ... */ @@ -500,9 +500,9 @@ btr_pcur_open_at_rnd_pos( btr_pcur_init(cursor); - bool available; + dberr_t err; - available = btr_cur_open_at_rnd_pos(index, latch_mode, + err = btr_cur_open_at_rnd_pos(index, latch_mode, btr_pcur_get_btr_cur(cursor), mtr, sim_uniform_dist); cursor->pos_state = BTR_PCUR_IS_POSITIONED; @@ -510,7 +510,7 @@ btr_pcur_open_at_rnd_pos( cursor->trx_if_known = NULL; - return(available); + return err; } /**************************************************************//** |