diff options
author | Peter Geoghegan <pg@bowt.ie> | 2020-06-25 10:55:28 -0700 |
---|---|---|
committer | Peter Geoghegan <pg@bowt.ie> | 2020-06-25 10:55:28 -0700 |
commit | 10f1ab2cb8bea3c6741a78f6dc19a5c91c0a34e1 (patch) | |
tree | 37a1a8de2bd0d98a2a76341fb5d8a6426d757f0f /src/backend/access/nbtree/nbtinsert.c | |
parent | 463b808e757928f053490dd397af77a80b4e7baa (diff) |
Fix misuse of table_index_fetch_tuple_check().
Commit 0d861bbb, which added deduplication to nbtree, had
_bt_check_unique() pass a TID to table_index_fetch_tuple_check() that
isn't safe to mutate. table_index_fetch_tuple_check()'s tid argument is
modified when the TID in question is not the latest visible tuple in a
hot chain, though this wasn't documented.
To fix, go back to using a local copy of the TID in _bt_check_unique(),
and update comments above table_index_fetch_tuple_check().
Backpatch: 13-, where B-Tree deduplication was introduced.
Diffstat (limited to 'src/backend/access/nbtree/nbtinsert.c')
-rw-r--r-- | src/backend/access/nbtree/nbtinsert.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index 55fe16bd4e1..b86c122763e 100644 --- a/src/backend/access/nbtree/nbtinsert.c +++ b/src/backend/access/nbtree/nbtinsert.c @@ -597,7 +597,8 @@ _bt_check_unique(Relation rel, BTInsertState insertstate, Relation heapRel, * not part of this chain because it had a different index * entry. */ - if (table_index_fetch_tuple_check(heapRel, &itup->t_tid, + htid = itup->t_tid; + if (table_index_fetch_tuple_check(heapRel, &htid, SnapshotSelf, NULL)) { /* Normal case --- it's still live */ |