aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/cluster.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-11-02 21:20:40 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-11-02 21:20:40 +0000
commite02d1abee6ada0658ddcbc73dc45925e6054781c (patch)
tree85567b5081f70c83db662488c56fa74bac8cc617 /src/backend/commands/cluster.c
parent5123139210a6767e99f3e420038d64926beb7d78 (diff)
downloadpostgresql-e02d1abee6ada0658ddcbc73dc45925e6054781c.tar.gz
postgresql-e02d1abee6ada0658ddcbc73dc45925e6054781c.zip
During swap_relfilenodes, swap relation size statistic fields along with
the relfilenode and toast fields. This ensures that the newly-computed statistics will be available on completion of CLUSTER.
Diffstat (limited to 'src/backend/commands/cluster.c')
-rw-r--r--src/backend/commands/cluster.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index 55cee5b4a76..fa414320a31 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.90 2002/09/04 20:31:14 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.91 2002/11/02 21:20:40 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -475,6 +475,20 @@ swap_relfilenodes(Oid r1, Oid r2)
/* we should not swap reltoastidxid */
+ /* swap size statistics too, since new rel has freshly-updated stats */
+ {
+ int4 swap_pages;
+ float4 swap_tuples;
+
+ swap_pages = relform1->relpages;
+ relform1->relpages = relform2->relpages;
+ relform2->relpages = swap_pages;
+
+ swap_tuples = relform1->reltuples;
+ relform1->reltuples = relform2->reltuples;
+ relform2->reltuples = swap_tuples;
+ }
+
/* Update the tuples in pg_class */
simple_heap_update(relRelation, &reltup1->t_self, reltup1);
simple_heap_update(relRelation, &reltup2->t_self, reltup2);