File tree 4 files changed +14
-20
lines changed
4 files changed +14
-20
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,8 @@ lock_rec_set_nth_bit(
96
96
bit_index = i % 8 ;
97
97
98
98
((byte * ) & lock [1 ])[byte_index ] |= 1 << bit_index ;
99
+
100
+ ++ lock -> trx -> lock .n_rec_locks ;
99
101
}
100
102
101
103
/*********************************************************************/ /**
Original file line number Diff line number Diff line change @@ -774,6 +774,7 @@ struct trx_lock_t {
774
774
mutex to prevent recursive deadlocks.
775
775
Protected by both the lock sys mutex
776
776
and the trx_t::mutex. */
777
+ ulint n_rec_locks; /* !< number of rec locks in this trx */
777
778
};
778
779
779
780
#define TRX_MAGIC_N 91118598
Original file line number Diff line number Diff line change @@ -963,6 +963,12 @@ lock_rec_reset_nth_bit(
963
963
byte mask = 1 << (i & 7 );
964
964
byte bit = *b & mask;
965
965
*b &= ~mask;
966
+
967
+ if (bit != 0 ) {
968
+ ut_ad (lock->trx ->lock .n_rec_locks > 0 );
969
+ --lock->trx ->lock .n_rec_locks ;
970
+ }
971
+
966
972
return (bit);
967
973
}
968
974
@@ -1339,28 +1345,9 @@ lock_number_of_rows_locked(
1339
1345
/* =======================*/
1340
1346
const trx_lock_t * trx_lock) /* !< in: transaction locks */
1341
1347
{
1342
- const lock_t * lock;
1343
- ulint n_records = 0 ;
1344
-
1345
1348
ut_ad (lock_mutex_own ());
1346
1349
1347
- for (lock = UT_LIST_GET_FIRST (trx_lock->trx_locks );
1348
- lock != NULL ;
1349
- lock = UT_LIST_GET_NEXT (trx_locks, lock)) {
1350
-
1351
- if (lock_get_type_low (lock) == LOCK_REC) {
1352
- ulint n_bit;
1353
- ulint n_bits = lock_rec_get_n_bits (lock);
1354
-
1355
- for (n_bit = 0 ; n_bit < n_bits; n_bit++) {
1356
- if (lock_rec_get_nth_bit (lock, n_bit)) {
1357
- n_records++;
1358
- }
1359
- }
1360
- }
1361
- }
1362
-
1363
- return (n_records);
1350
+ return (trx_lock->n_rec_locks );
1364
1351
}
1365
1352
1366
1353
/* ********************************************************************/ /* *
@@ -6386,6 +6373,8 @@ lock_trx_release_locks(
6386
6373
6387
6374
lock_release (trx);
6388
6375
6376
+ trx->lock .n_rec_locks = 0 ;
6377
+
6389
6378
lock_mutex_exit ();
6390
6379
6391
6380
/* We don't remove the locks one by one from the vector for
Original file line number Diff line number Diff line change @@ -118,6 +118,8 @@ trx_init(
118
118
119
119
trx->support_xa = true ;
120
120
121
+ trx->lock .n_rec_locks = 0 ;
122
+
121
123
trx->search_latch_timeout = BTR_SEA_TIMEOUT;
122
124
123
125
trx->dict_operation = TRX_DICT_OP_NONE;
You can’t perform that action at this time.
0 commit comments