From b40776d22185423f57e32b9c9fcac2326fdb4fde Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Fri, 18 May 2007 23:19:42 +0000 Subject: Have CLUSTER advance the table's relfrozenxid. The new frozen point is the FreezeXid introduced in a recent commit, so there isn't any data loss in this approach. Doing it causes ALTER TABLE (or rather, the forms of it that cause a full table rewrite) to be affected as well. In this case, the frozen point is RecentXmin, because after the rewrite all the tuples are relabeled with the rewriting transaction's Xid. TOAST tables are fixed automatically as well, as fallout of the way they were already being handled in the respective code paths. With this patch, there is no longer need to VACUUM tables for Xid wraparound purposes that have been cleaned up via TRUNCATE or CLUSTER. --- src/backend/commands/tablecmds.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/backend/commands/tablecmds.c') diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index cdfbc6f0829..aafc4d1b2ee 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.224 2007/05/16 17:28:20 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.225 2007/05/18 23:19:41 alvherre Exp $ * *------------------------------------------------------------------------- */ @@ -2285,8 +2285,13 @@ ATRewriteTables(List **wqueue) */ ATRewriteTable(tab, OIDNewHeap); - /* Swap the physical files of the old and new heaps. */ - swap_relation_files(tab->relid, OIDNewHeap); + /* + * Swap the physical files of the old and new heaps. Since we are + * generating a new heap, we can use RecentXmin for the table's new + * relfrozenxid because we rewrote all the tuples on + * ATRewriteTable, so no older Xid remains on the table. + */ + swap_relation_files(tab->relid, OIDNewHeap, RecentXmin); CommandCounterIncrement(); -- cgit v1.2.3