@@ -1269,7 +1269,8 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class,
12691269 * changes because we'd be updating the old data that we're about to throw
12701270 * away. Because the real work being done here for a mapped relation is
12711271 * just to change the relation map settings, it's all right to not update
1272- * the pg_class rows in this case.
1272+ * the pg_class rows in this case. The most important changes will instead
1273+ * performed later, in finish_heap_swap() itself.
12731274 */
12741275if (!target_is_pg_class )
12751276{
@@ -1504,6 +1505,40 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap,
15041505reindex_flags |=REINDEX_REL_CHECK_CONSTRAINTS ;
15051506reindex_relation (OIDOldHeap ,reindex_flags );
15061507
1508+ /*
1509+ * If the relation being rebuild is pg_class, swap_relation_files()
1510+ * couldn't update pg_class's own pg_class entry (check comments in
1511+ * swap_relation_files()), thus relfrozenxid was not updated. That's
1512+ * annoying because a potential reason for doing a VACUUM FULL is a
1513+ * imminent or actual anti-wraparound shutdown. So, now that we can
1514+ * access the new relation using it's indices, update
1515+ * relfrozenxid. pg_class doesn't have a toast relation, so we don't need
1516+ * to update the corresponding toast relation. Not that there's little
1517+ * point moving all relfrozenxid updates here since swap_relation_files()
1518+ * needs to write to pg_class for non-mapped relations anyway.
1519+ */
1520+ if (OIDOldHeap == RelationRelationId )
1521+ {
1522+ Relation relRelation ;
1523+ HeapTuple reltup ;
1524+ Form_pg_class relform ;
1525+
1526+ relRelation = heap_open (RelationRelationId ,RowExclusiveLock );
1527+
1528+ reltup = SearchSysCacheCopy1 (RELOID ,ObjectIdGetDatum (OIDOldHeap ));
1529+ if (!HeapTupleIsValid (reltup ))
1530+ elog (ERROR ,"cache lookup failed for relation %u" ,OIDOldHeap );
1531+ relform = (Form_pg_class )GETSTRUCT (reltup );
1532+
1533+ relform -> relfrozenxid = frozenXid ;
1534+ relform -> relminmxid = cutoffMulti ;
1535+
1536+ simple_heap_update (relRelation ,& reltup -> t_self ,reltup );
1537+ CatalogUpdateIndexes (relRelation ,reltup );
1538+
1539+ heap_close (relRelation ,RowExclusiveLock );
1540+ }
1541+
15071542/* Destroy new heap with old filenode */
15081543object .classId = RelationRelationId ;
15091544object .objectId = OIDNewHeap ;