@@ -518,8 +518,10 @@ vacuum_set_xid_limits(Relation rel,
518
518
/*
519
519
* Compute the cutoff XID, being careful not to generate a "permanent" XID
520
520
*/
521
- limit = * oldestXmin - freezemin ;
522
- if (!TransactionIdIsNormal (limit ))
521
+ limit = * oldestXmin ;
522
+ if (limit > FirstNormalTransactionId + freezemin )
523
+ limit -= freezemin ;
524
+ else
523
525
limit = FirstNormalTransactionId ;
524
526
525
527
/*
@@ -607,8 +609,10 @@ vacuum_set_xid_limits(Relation rel,
607
609
* Compute XID limit causing a full-table vacuum, being careful not to
608
610
* generate a "permanent" XID.
609
611
*/
610
- limit = ReadNewTransactionId () - freezetable ;
611
- if (!TransactionIdIsNormal (limit ))
612
+ limit = ReadNewTransactionId ();
613
+ if (limit > FirstNormalTransactionId + freezetable )
614
+ limit -= freezetable ;
615
+ else
612
616
limit = FirstNormalTransactionId ;
613
617
614
618
* xidFullScanLimit = limit ;
@@ -632,8 +636,10 @@ vacuum_set_xid_limits(Relation rel,
632
636
* Compute MultiXact limit causing a full-table vacuum, being careful
633
637
* to generate a valid MultiXact value.
634
638
*/
635
- mxactLimit = ReadNextMultiXactId () - freezetable ;
636
- if (mxactLimit < FirstMultiXactId )
639
+ mxactLimit = ReadNextMultiXactId ();
640
+ if (mxactLimit > FirstMultiXactId + freezetable )
641
+ mxactLimit -= freezetable ;
642
+ else
637
643
mxactLimit = FirstMultiXactId ;
638
644
639
645
* mxactFullScanLimit = mxactLimit ;
0 commit comments