mirror of
https://github.com/postgres/postgres.git
synced 2025-07-12 21:01:52 +03:00
Avoid repeating loads of frozen ID values.
Repeating loads of inplace-updated fields tends to cause bugs like the one from the previous commit. While there's no bug to fix in these code sites, adopt the load-once style. This improves the chance of future copy/paste finding the safe style. Discussion: https://postgr.es/m/20240423003956.e7.nmisch@google.com
This commit is contained in:
@ -919,18 +919,24 @@ copy_table_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
|
||||
* FreezeXid will become the table's new relfrozenxid, and that mustn't go
|
||||
* backwards, so take the max.
|
||||
*/
|
||||
if (TransactionIdIsValid(OldHeap->rd_rel->relfrozenxid) &&
|
||||
TransactionIdPrecedes(cutoffs.FreezeLimit,
|
||||
OldHeap->rd_rel->relfrozenxid))
|
||||
cutoffs.FreezeLimit = OldHeap->rd_rel->relfrozenxid;
|
||||
{
|
||||
TransactionId relfrozenxid = OldHeap->rd_rel->relfrozenxid;
|
||||
|
||||
if (TransactionIdIsValid(relfrozenxid) &&
|
||||
TransactionIdPrecedes(cutoffs.FreezeLimit, relfrozenxid))
|
||||
cutoffs.FreezeLimit = relfrozenxid;
|
||||
}
|
||||
|
||||
/*
|
||||
* MultiXactCutoff, similarly, shouldn't go backwards either.
|
||||
*/
|
||||
if (MultiXactIdIsValid(OldHeap->rd_rel->relminmxid) &&
|
||||
MultiXactIdPrecedes(cutoffs.MultiXactCutoff,
|
||||
OldHeap->rd_rel->relminmxid))
|
||||
cutoffs.MultiXactCutoff = OldHeap->rd_rel->relminmxid;
|
||||
{
|
||||
MultiXactId relminmxid = OldHeap->rd_rel->relminmxid;
|
||||
|
||||
if (MultiXactIdIsValid(relminmxid) &&
|
||||
MultiXactIdPrecedes(cutoffs.MultiXactCutoff, relminmxid))
|
||||
cutoffs.MultiXactCutoff = relminmxid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decide whether to use an indexscan or seqscan-and-optional-sort to scan
|
||||
|
Reference in New Issue
Block a user