@@ -64,12 +64,10 @@ typedef struct
6464} RelToCluster ;
6565
6666
67- static void rebuild_relation (Relation OldHeap , Oid indexOid ,
68- int freeze_min_age , int freeze_table_age , bool verbose );
67+ static void rebuild_relation (Relation OldHeap , Oid indexOid , bool verbose );
6968static void copy_heap_data (Oid OIDNewHeap , Oid OIDOldHeap , Oid OIDOldIndex ,
70- int freeze_min_age , int freeze_table_age , bool verbose ,
71- bool * pSwapToastByContent , TransactionId * pFreezeXid ,
72- MultiXactId * pCutoffMulti );
69+ bool verbose , bool * pSwapToastByContent ,
70+ TransactionId * pFreezeXid , MultiXactId * pCutoffMulti );
7371static List * get_tables_to_cluster (MemoryContext cluster_context );
7472static void reform_and_rewrite_tuple (HeapTuple tuple ,
7573 TupleDesc oldTupDesc , TupleDesc newTupDesc ,
@@ -176,11 +174,8 @@ cluster(ClusterStmt *stmt, bool isTopLevel)
176174 /* close relation, keep lock till commit */
177175 heap_close (rel , NoLock );
178176
179- /*
180- * Do the job. We use a -1 freeze_min_age to avoid having CLUSTER
181- * freeze tuples earlier than a plain VACUUM would.
182- */
183- cluster_rel (tableOid , indexOid , false, stmt -> verbose , -1 , -1 );
177+ /* Do the job. */
178+ cluster_rel (tableOid , indexOid , false, stmt -> verbose );
184179 }
185180 else
186181 {
@@ -229,9 +224,8 @@ cluster(ClusterStmt *stmt, bool isTopLevel)
229224 StartTransactionCommand ();
230225 /* functions in indexes may want a snapshot set */
231226 PushActiveSnapshot (GetTransactionSnapshot ());
232- /* Do the job. As above, use a -1 freeze_min_age. */
233- cluster_rel (rvtc -> tableOid , rvtc -> indexOid , true, stmt -> verbose ,
234- -1 , -1 );
227+ /* Do the job. */
228+ cluster_rel (rvtc -> tableOid , rvtc -> indexOid , true, stmt -> verbose );
235229 PopActiveSnapshot ();
236230 CommitTransactionCommand ();
237231 }
@@ -262,8 +256,7 @@ cluster(ClusterStmt *stmt, bool isTopLevel)
262256 * and error messages should refer to the operation as VACUUM not CLUSTER.
263257 */
264258void
265- cluster_rel (Oid tableOid , Oid indexOid , bool recheck , bool verbose ,
266- int freeze_min_age , int freeze_table_age )
259+ cluster_rel (Oid tableOid , Oid indexOid , bool recheck , bool verbose )
267260{
268261 Relation OldHeap ;
269262
@@ -407,8 +400,7 @@ cluster_rel(Oid tableOid, Oid indexOid, bool recheck, bool verbose,
407400 TransferPredicateLocksToHeapRelation (OldHeap );
408401
409402 /* rebuild_relation does all the dirty work */
410- rebuild_relation (OldHeap , indexOid , freeze_min_age , freeze_table_age ,
411- verbose );
403+ rebuild_relation (OldHeap , indexOid , verbose );
412404
413405 /* NB: rebuild_relation does heap_close() on OldHeap */
414406}
@@ -561,8 +553,7 @@ mark_index_clustered(Relation rel, Oid indexOid, bool is_internal)
561553 * NB: this routine closes OldHeap at the right time; caller should not.
562554 */
563555static void
564- rebuild_relation (Relation OldHeap , Oid indexOid ,
565- int freeze_min_age , int freeze_table_age , bool verbose )
556+ rebuild_relation (Relation OldHeap , Oid indexOid , bool verbose )
566557{
567558 Oid tableOid = RelationGetRelid (OldHeap );
568559 Oid tableSpace = OldHeap -> rd_rel -> reltablespace ;
@@ -587,8 +578,7 @@ rebuild_relation(Relation OldHeap, Oid indexOid,
587578 AccessExclusiveLock );
588579
589580 /* Copy the heap data into the new table in the desired order */
590- copy_heap_data (OIDNewHeap , tableOid , indexOid ,
591- freeze_min_age , freeze_table_age , verbose ,
581+ copy_heap_data (OIDNewHeap , tableOid , indexOid , verbose ,
592582 & swap_toast_by_content , & frozenXid , & cutoffMulti );
593583
594584 /*
@@ -743,8 +733,7 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace, bool forcetemp,
743733 * *pCutoffMulti receives the MultiXactId used as a cutoff point.
744734 */
745735static void
746- copy_heap_data (Oid OIDNewHeap , Oid OIDOldHeap , Oid OIDOldIndex ,
747- int freeze_min_age , int freeze_table_age , bool verbose ,
736+ copy_heap_data (Oid OIDNewHeap , Oid OIDOldHeap , Oid OIDOldIndex , bool verbose ,
748737 bool * pSwapToastByContent , TransactionId * pFreezeXid ,
749738 MultiXactId * pCutoffMulti )
750739{
@@ -857,10 +846,11 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex,
857846 * pSwapToastByContent = false;
858847
859848 /*
860- * compute xids used to freeze and weed out dead tuples.
849+ * Compute xids used to freeze and weed out dead tuples and multixacts.
850+ * Since we're going to rewrite the whole table anyway, there's no reason
851+ * not to be aggressive about this.
861852 */
862- vacuum_set_xid_limits (freeze_min_age , freeze_table_age ,
863- OldHeap -> rd_rel -> relisshared ,
853+ vacuum_set_xid_limits (0 , 0 , OldHeap -> rd_rel -> relisshared ,
864854 & OldestXmin , & FreezeXid , NULL , & MultiXactCutoff ,
865855 NULL );
866856
0 commit comments