summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-07-23 17:41:44 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-07-23 17:41:44 +0300
commit1656ea28e8e49318b34e98ffa408d891a451c3f4 (patch)
tree9c322787f8b571d02c187b04eafe12c8c5ab6bf8 /storage
parentf7adc4a11d36d7a75ba82d658121cb263f5b78c7 (diff)
downloadmariadb-git-1656ea28e8e49318b34e98ffa408d891a451c3f4.tar.gz
MDEV-23244 ALTER TABLE…ADD PRIMARY KEY fails to flag duplicates
The fix of MDEV-13654 (commit ff81faf670e083e1da4f3e7bce33fe9104410b2c) wrongly caused ADD PRIMARY KEY to ignore duplicate PRIMARY KEY values caused by concurrent DML transactions that had been started before the ALTER TABLE operation (but did not access the table before the ALTER TABLE started). row_ins_duplicate_online(): Always report a duplicate key error if DB_TRX_ID had been reset (it belongs to a transaction that had started before the ALTER TABLE operation).
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/row/row0ins.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index d6596d586ab..13649777419 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -2241,8 +2241,14 @@ row_ins_duplicate_online(
return(DB_SUCCESS);
}
- if (fields == n_uniq + 2) {
- /* rec is an exact match of entry. */
+ ulint trx_id_len;
+
+ if (fields == n_uniq + 2
+ && memcmp(rec_get_nth_field(rec, offsets, n_uniq, &trx_id_len),
+ reset_trx_id, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN)) {
+ ut_ad(trx_id_len == DATA_TRX_ID_LEN);
+ /* rec is an exact match of entry, and DB_TRX_ID belongs
+ to a transaction that started after our ALTER TABLE. */
return(DB_SUCCESS_LOCKED_REC);
}