amcheck: Fix ordering bug in update_cached_xid_range()

The initialization order in update_cached_xid_range() was wrong, calling
FullTransactionIdFromXidAndCtx() before setting
->next_xid. FullTransactionIdFromXidAndCtx() uses ->next_xid.

In most situations this will not cause visible issues, because the next call
to update_cached_xid_range() will use a less wrong ->next_xid. It's rare that
xids advance fast enough for this to be a problem.

Found while adding more asserts to the 64bit xid infrastructure.

Reviewed-by: Mark Dilger <[email protected]>
Discussion: 
https://postgr.es/m/[email protected]
Backpatch: 14-, where heapam verification was introduced

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6d9588108a5644800b0047ccb666f70373164f68

Modified Files
--------------
contrib/amcheck/verify_heapam.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

Reply via email to