@@ -3588,14 +3588,12 @@ record with the same ordering prefix in in the B-tree index
3588
3588
@param[in] latch_mode latch mode wished in restoration
3589
3589
@param[in] pcur cursor whose position has been stored
3590
3590
@param[in] moves_up true if the cursor moves up in the index
3591
- @param[in] mtr mtr; CAUTION: may commit mtr temporarily!
3592
- @param[in] select_lock_type select lock type
3591
+ @param[in,out] mtr mtr; CAUTION: may commit mtr temporarily!
3593
3592
@return true if we may need to process the record the cursor is now
3594
3593
positioned on (i.e. we should not go to the next record yet) */
3595
3594
static bool sel_restore_position_for_mysql (bool *same_user_rec,
3596
3595
ulint latch_mode, btr_pcur_t *pcur,
3597
- bool moves_up, mtr_t *mtr,
3598
- lock_mode select_lock_type)
3596
+ bool moves_up, mtr_t *mtr)
3599
3597
{
3600
3598
auto status = btr_pcur_restore_position (latch_mode, pcur, mtr);
3601
3599
@@ -3618,8 +3616,7 @@ static bool sel_restore_position_for_mysql(bool *same_user_rec,
3618
3616
switch (pcur->rel_pos ) {
3619
3617
case BTR_PCUR_ON:
3620
3618
if (!*same_user_rec && moves_up) {
3621
- if (status == btr_pcur_t ::SAME_UNIQ
3622
- && select_lock_type != LOCK_NONE)
3619
+ if (status == btr_pcur_t ::SAME_UNIQ)
3623
3620
return true ;
3624
3621
next:
3625
3622
if (btr_pcur_move_to_next (pcur, mtr)
@@ -4303,7 +4300,7 @@ row_search_mvcc(
4303
4300
const rec_t * clust_rec;
4304
4301
Row_sel_get_clust_rec_for_mysql row_sel_get_clust_rec_for_mysql;
4305
4302
ibool unique_search = FALSE ;
4306
- ibool mtr_has_extra_clust_latch = FALSE ;
4303
+ ulint mtr_extra_clust_savepoint = 0 ;
4307
4304
bool moves_up = false ;
4308
4305
/* if the returned record was locked and we did a semi-consistent
4309
4306
read (fetch the newest committed version), then this is set to
@@ -4673,7 +4670,7 @@ row_search_mvcc(
4673
4670
4674
4671
bool need_to_process = sel_restore_position_for_mysql (
4675
4672
&same_user_rec, BTR_SEARCH_LEAF,
4676
- pcur, moves_up, &mtr, prebuilt-> select_lock_type );
4673
+ pcur, moves_up, &mtr);
4677
4674
4678
4675
if (UNIV_UNLIKELY (need_to_process)) {
4679
4676
if (UNIV_UNLIKELY (prebuilt->row_read_type
@@ -5355,7 +5352,7 @@ row_search_mvcc(
5355
5352
/* It was a non-clustered index and we must fetch also the
5356
5353
clustered index record */
5357
5354
5358
- mtr_has_extra_clust_latch = TRUE ;
5355
+ mtr_extra_clust_savepoint = mtr. get_savepoint () ;
5359
5356
5360
5357
ut_ad (!vrow);
5361
5358
/* The following call returns 'offsets' associated with
@@ -5643,27 +5640,15 @@ row_search_mvcc(
5643
5640
/* No need to do store restore for R-tree */
5644
5641
mtr.commit ();
5645
5642
mtr.start ();
5646
- mtr_has_extra_clust_latch = FALSE ;
5647
- } else if (mtr_has_extra_clust_latch ) {
5648
- /* If we have extra cluster latch, we must commit
5649
- mtr if we are moving to the next non-clustered
5643
+ mtr_extra_clust_savepoint = 0 ;
5644
+ } else if (mtr_extra_clust_savepoint ) {
5645
+ /* We must release any clustered index latches
5646
+ if we are moving to the next non-clustered
5650
5647
index record, because we could break the latching
5651
5648
order if we would access a different clustered
5652
5649
index page right away without releasing the previous. */
5653
-
5654
- btr_pcur_store_position (pcur, &mtr);
5655
- mtr.commit ();
5656
- mtr_has_extra_clust_latch = FALSE ;
5657
-
5658
- mtr.start ();
5659
-
5660
- if (sel_restore_position_for_mysql (&same_user_rec,
5661
- BTR_SEARCH_LEAF,
5662
- pcur, moves_up, &mtr,
5663
- prebuilt->select_lock_type )
5664
- ) {
5665
- goto rec_loop;
5666
- }
5650
+ mtr.rollback_to_savepoint (mtr_extra_clust_savepoint);
5651
+ mtr_extra_clust_savepoint = 0 ;
5667
5652
}
5668
5653
5669
5654
if (moves_up) {
@@ -5723,7 +5708,7 @@ row_search_mvcc(
5723
5708
5724
5709
lock_table_wait:
5725
5710
mtr.commit ();
5726
- mtr_has_extra_clust_latch = FALSE ;
5711
+ mtr_extra_clust_savepoint = 0 ;
5727
5712
5728
5713
trx->error_state = err;
5729
5714
@@ -5752,7 +5737,7 @@ row_search_mvcc(
5752
5737
if (!dict_index_is_spatial (index)) {
5753
5738
sel_restore_position_for_mysql (
5754
5739
&same_user_rec, BTR_SEARCH_LEAF, pcur,
5755
- moves_up, &mtr, prebuilt-> select_lock_type );
5740
+ moves_up, &mtr);
5756
5741
}
5757
5742
5758
5743
if (trx->isolation_level <= TRX_ISO_READ_COMMITTED
0 commit comments