diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2007-05-17 15:28:29 +0000 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2007-05-17 15:28:29 +0000 |
commit | 3b0347b36e1f59e5db95e8994948d850bfc90472 (patch) | |
tree | 437bc425e994ac31daf0775e476b7315b939070c /src/backend/commands/cluster.c | |
parent | 90cbc63fd10adaeb01c3180156e0e48eee08b5ed (diff) | |
download | postgresql-3b0347b36e1f59e5db95e8994948d850bfc90472.tar.gz postgresql-3b0347b36e1f59e5db95e8994948d850bfc90472.zip |
Move the tuple freezing point in CLUSTER to a point further back in the past,
to avoid losing useful Xid information in not-so-old tuples. This makes
CLUSTER behave the same as VACUUM as far a tuple-freezing behavior goes
(though CLUSTER does not yet advance the table's relfrozenxid).
While at it, move the actual freezing operation in rewriteheap.c to a more
appropriate place, and document it thoroughly. This part of the patch from
Tom Lane.
Diffstat (limited to 'src/backend/commands/cluster.c')
-rw-r--r-- | src/backend/commands/cluster.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 656d7d710f0..3eee46fbd0a 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.159 2007/04/08 01:26:28 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.160 2007/05/17 15:28:29 alvherre Exp $ * *------------------------------------------------------------------------- */ @@ -29,6 +29,7 @@ #include "catalog/namespace.h" #include "catalog/toasting.h" #include "commands/cluster.h" +#include "commands/vacuum.h" #include "miscadmin.h" #include "storage/procarray.h" #include "utils/acl.h" @@ -657,6 +658,7 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex) HeapTuple tuple; bool use_wal; TransactionId OldestXmin; + TransactionId FreezeXid; RewriteState rwstate; /* @@ -688,11 +690,16 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex) /* use_wal off requires rd_targblock be initially invalid */ Assert(NewHeap->rd_targblock == InvalidBlockNumber); - /* Get the cutoff xmin we'll use to weed out dead tuples */ - OldestXmin = GetOldestXmin(OldHeap->rd_rel->relisshared, true); + /* + * compute xids used to freeze and weed out dead tuples. We use -1 + * freeze_min_age to avoid having CLUSTER freeze tuples earlier than + * a plain VACUUM would. + */ + vacuum_set_xid_limits(-1, OldHeap->rd_rel->relisshared, + &OldestXmin, &FreezeXid); /* Initialize the rewrite operation */ - rwstate = begin_heap_rewrite(NewHeap, OldestXmin, use_wal); + rwstate = begin_heap_rewrite(NewHeap, OldestXmin, FreezeXid, use_wal); /* * Scan through the OldHeap in OldIndex order and copy each tuple into the |