mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 14:54:20 +01:00
branches/zip: Merge revisions 4400:4481 from branches/5.1:
------------------------------------------------------------------------ r4481 | marko | 2009-03-19 15:01:48 +0200 (Thu, 19 Mar 2009) | 6 lines branches/5.1: row_unlock_for_mysql(): Do not unlock records that were modified by the current transaction. This bug was introduced or unmasked in r4400. rb://97 approved by Heikki Tuuri ------------------------------------------------------------------------
This commit is contained in:
parent
bbd50cdb96
commit
113101682f
1 changed files with 56 additions and 17 deletions
|
@ -1452,8 +1452,6 @@ row_unlock_for_mysql(
|
|||
btr_pcur_t* pcur = prebuilt->pcur;
|
||||
btr_pcur_t* clust_pcur = prebuilt->clust_pcur;
|
||||
trx_t* trx = prebuilt->trx;
|
||||
rec_t* rec;
|
||||
mtr_t mtr;
|
||||
|
||||
ut_ad(prebuilt && trx);
|
||||
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
|
||||
|
@ -1475,6 +1473,11 @@ row_unlock_for_mysql(
|
|||
|
||||
if (prebuilt->new_rec_locks >= 1) {
|
||||
|
||||
rec_t* rec;
|
||||
dict_index_t* index;
|
||||
dulint rec_trx_id;
|
||||
mtr_t mtr;
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
/* Restore the cursor position and find the record */
|
||||
|
@ -1484,27 +1487,63 @@ row_unlock_for_mysql(
|
|||
}
|
||||
|
||||
rec = btr_pcur_get_rec(pcur);
|
||||
index = btr_pcur_get_btr_cur(pcur)->index;
|
||||
|
||||
lock_rec_unlock(trx, btr_pcur_get_block(pcur),
|
||||
rec, prebuilt->select_lock_type);
|
||||
if (prebuilt->new_rec_locks >= 2) {
|
||||
/* Restore the cursor position and find the record
|
||||
in the clustered index. */
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
if (!has_latches_on_recs) {
|
||||
btr_pcur_restore_position(BTR_SEARCH_LEAF,
|
||||
clust_pcur, &mtr);
|
||||
}
|
||||
|
||||
if (prebuilt->new_rec_locks >= 2) {
|
||||
mtr_start(&mtr);
|
||||
|
||||
/* Restore the cursor position and find the record */
|
||||
|
||||
if (!has_latches_on_recs) {
|
||||
btr_pcur_restore_position(BTR_SEARCH_LEAF, clust_pcur,
|
||||
&mtr);
|
||||
rec = btr_pcur_get_rec(clust_pcur);
|
||||
index = btr_pcur_get_btr_cur(clust_pcur)->index;
|
||||
}
|
||||
|
||||
rec = btr_pcur_get_rec(clust_pcur);
|
||||
/* If the record has been modified by this
|
||||
transaction, do not unlock it. */
|
||||
ut_a(index->type & DICT_CLUSTERED);
|
||||
|
||||
lock_rec_unlock(trx, btr_pcur_get_block(clust_pcur),
|
||||
rec, prebuilt->select_lock_type);
|
||||
if (index->trx_id_offset) {
|
||||
rec_trx_id = trx_read_trx_id(rec
|
||||
+ index->trx_id_offset);
|
||||
} else {
|
||||
mem_heap_t* heap = NULL;
|
||||
ulint offsets_[REC_OFFS_NORMAL_SIZE];
|
||||
ulint* offsets = offsets_;
|
||||
|
||||
rec_offs_init(offsets_);
|
||||
offsets = rec_get_offsets(rec, index, offsets,
|
||||
ULINT_UNDEFINED, &heap);
|
||||
|
||||
rec_trx_id = row_get_rec_trx_id(rec, index, offsets);
|
||||
|
||||
if (UNIV_LIKELY_NULL(heap)) {
|
||||
mem_heap_free(heap);
|
||||
}
|
||||
}
|
||||
|
||||
if (ut_dulint_cmp(rec_trx_id, trx->id) != 0) {
|
||||
/* We did not update the record: unlock it */
|
||||
|
||||
rec = btr_pcur_get_rec(pcur);
|
||||
index = btr_pcur_get_btr_cur(pcur)->index;
|
||||
|
||||
lock_rec_unlock(trx, btr_pcur_get_block(pcur),
|
||||
rec, prebuilt->select_lock_type);
|
||||
|
||||
if (prebuilt->new_rec_locks >= 2) {
|
||||
rec = btr_pcur_get_rec(clust_pcur);
|
||||
index = btr_pcur_get_btr_cur(clust_pcur)->index;
|
||||
|
||||
lock_rec_unlock(trx,
|
||||
btr_pcur_get_block(clust_pcur),
|
||||
rec,
|
||||
prebuilt->select_lock_type);
|
||||
}
|
||||
}
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue