Index: src/backend/commands/cluster.c =================================================================== RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/commands/cluster.c,v retrieving revision 1.159 diff -c -p -r1.159 cluster.c *** src/backend/commands/cluster.c 8 Apr 2007 01:26:28 -0000 1.159 --- src/backend/commands/cluster.c 15 May 2007 22:55:22 -0000 *************** typedef struct *** 54,60 **** static void cluster_rel(RelToCluster *rv, bool recheck); static void rebuild_relation(Relation OldHeap, Oid indexOid); ! static void copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex); static List *get_tables_to_cluster(MemoryContext cluster_context); --- 54,60 ---- static void cluster_rel(RelToCluster *rv, bool recheck); static void rebuild_relation(Relation OldHeap, Oid indexOid); ! static TransactionId copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex); static List *get_tables_to_cluster(MemoryContext cluster_context); *************** rebuild_relation(Relation OldHeap, Oid i *** 512,517 **** --- 512,518 ---- Oid tableSpace = OldHeap->rd_rel->reltablespace; Oid OIDNewHeap; char NewHeapName[NAMEDATALEN]; + TransactionId frozenXid; ObjectAddress object; /* Mark the correct index as clustered */ *************** rebuild_relation(Relation OldHeap, Oid i *** 538,548 **** /* * Copy the heap data into the new table in the desired order. */ ! copy_heap_data(OIDNewHeap, tableOid, indexOid); /* To make the new heap's data visible (probably not needed?). */ CommandCounterIncrement(); /* Swap the physical files of the old and new heaps. */ swap_relation_files(tableOid, OIDNewHeap); --- 539,556 ---- /* * Copy the heap data into the new table in the desired order. */ ! frozenXid = copy_heap_data(OIDNewHeap, tableOid, indexOid); /* To make the new heap's data visible (probably not needed?). */ CommandCounterIncrement(); + /* + * update the relation's freeze Xid. We don't need to change the + * actual tuple on disk, because swap_relation_files will do it for + * us. + */ + OldHeap->rd_rel->relfrozenxid = frozenXid; + /* Swap the physical files of the old and new heaps. */ swap_relation_files(tableOid, OIDNewHeap); *************** make_new_heap(Oid OIDOldHeap, const char *** 640,648 **** } /* ! * Do the physical copying of heap data. */ ! static void copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex) { Relation NewHeap, --- 648,657 ---- } /* ! * Do the physical copying of heap data. Returns the transaction ID used as ! * cutoff point. */ ! static TransactionId copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex) { Relation NewHeap, *************** copy_heap_data(Oid OIDNewHeap, Oid OIDOl *** 809,814 **** --- 818,825 ---- index_close(OldIndex, NoLock); heap_close(OldHeap, NoLock); heap_close(NewHeap, NoLock); + + return OldestXmin; } /*