From e02d1abee6ada0658ddcbc73dc45925e6054781c Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 2 Nov 2002 21:20:40 +0000 Subject: [PATCH] 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. --- src/backend/commands/cluster.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 55cee5b4a7..fa414320a3 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);