postgresql/contrib/amcheck
Andres Freund e8a9750d03 amcheck: Fix FullTransactionIdFromXidAndCtx() for xids before epoch 0
64bit xids can't represent xids before epoch 0 (see also be504a3e97). When
FullTransactionIdFromXidAndCtx() was passed such an xid, it'd create a 64bit
xid far into the future. Noticed while adding assertions in the course of
investigating be504a3e97, as amcheck's test create such xids.

To fix the issue, just return FirstNormalFullTransactionId in this case. A
freshly initdb'd cluster already has a newer horizon. The most minimal version
of this would make the messages for some detected corruptions differently
inaccurate. To make those cases accurate, switch
FullTransactionIdFromXidAndCtx() to use the 32bit modulo difference between
xid and nextxid to compute the 64bit xid, yielding sensible "in the future" /
"in the past" answers.

Reviewed-by: Mark Dilger <mark.dilger@enterprisedb.com>
Discussion: https://postgr.es/m/20230108002923.cyoser3ttmt63bfn@awork3.anarazel.de
Backpatch: 14-, where heapam verification was introduced
2023-03-11 14:14:50 -08:00
..
expected Make relation-enumerating operations be security-restricted operations. 2022-05-09 08:35:08 -07:00
sql Make relation-enumerating operations be security-restricted operations. 2022-05-09 08:35:08 -07:00
t Harden TAP tests that intentionally corrupt page checksums. 2022-03-25 14:23:26 -04:00
.gitignore Add .gitignore to contrib/amcheck. 2017-03-09 22:45:24 -05:00
Makefile Extend amcheck to check heap pages. 2020-10-22 08:44:18 -04:00
amcheck--1.0--1.1.sql Add amcheck verification of heap relations belonging to btree indexes. 2018-03-31 19:52:01 -07:00
amcheck--1.0.sql Add amcheck extension to contrib. 2017-03-09 16:33:02 -08:00
amcheck--1.1--1.2.sql Allow amcheck to re-find tuples using new search. 2019-03-20 10:41:36 -07:00
amcheck--1.2--1.3.sql Extend amcheck to check heap pages. 2020-10-22 08:44:18 -04:00
amcheck.control Extend amcheck to check heap pages. 2020-10-22 08:44:18 -04:00
verify_heapam.c amcheck: Fix FullTransactionIdFromXidAndCtx() for xids before epoch 0 2023-03-11 14:14:50 -08:00
verify_nbtree.c Silence compiler warnings from some older compilers. 2022-06-01 17:21:45 -04:00