1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-21 02:52:47 +03:00

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.
This commit is contained in:
Peter Geoghegan
2020-06-25 10:55:28 -07:00
parent 463b808e75
commit 10f1ab2cb8
3 changed files with 9 additions and 2 deletions

View File

@@ -989,7 +989,9 @@ table_index_fetch_end(struct IndexFetchTableData *scan)
/*
* Fetches, as part of an index scan, tuple at `tid` into `slot`, after doing
* a visibility test according to `snapshot`. If a tuple was found and passed
* the visibility test, returns true, false otherwise.
* the visibility test, returns true, false otherwise. Note that *tid may be
* modified when we return true (see later remarks on multiple row versions
* reachable via a single index entry).
*
* *call_again needs to be false on the first call to table_index_fetch_tuple() for
* a tid. If there potentially is another tuple matching the tid, *call_again