aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/gist/gist.c
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2005-05-11 06:24:55 +0000
committerNeil Conway <neilc@samurai.com>2005-05-11 06:24:55 +0000
commit314043749573f8638bd779298860828c44484ca4 (patch)
tree022cf49a537345221bb512067269c26688d0e4cd /src/backend/access/gist/gist.c
parentff868d8161b9b07bc7e311a295119fa843899a7f (diff)
downloadpostgresql-314043749573f8638bd779298860828c44484ca4.tar.gz
postgresql-314043749573f8638bd779298860828c44484ca4.zip
This patch refactors away some duplicated code in the index AM build
methods: they all invoke UpdateStats() since they have computed the number of heap tuples, so I created a function in catalog/index.c that each AM now calls.
Diffstat (limited to 'src/backend/access/gist/gist.c')
-rw-r--r--src/backend/access/gist/gist.c25
1 files changed, 3 insertions, 22 deletions
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
index c1e3dfae367..e02f0a37624 100644
--- a/src/backend/access/gist/gist.c
+++ b/src/backend/access/gist/gist.c
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.113 2005/03/21 01:23:56 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.114 2005/05/11 06:24:50 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -184,27 +184,8 @@ gistbuild(PG_FUNCTION_ARGS)
/* okay, all heap tuples are indexed */
- /*
- * Since we just counted the tuples in the heap, we update its stats
- * in pg_class to guarantee that the planner takes advantage of the
- * index we just created. But, only update statistics during normal
- * index definitions, not for indices on system catalogs created
- * during bootstrap processing. We must close the relations before
- * updating statistics to guarantee that the relcache entries are
- * flushed when we increment the command counter in UpdateStats(). But
- * we do not release any locks on the relations; those will be held
- * until end of transaction.
- */
- if (IsNormalProcessingMode())
- {
- Oid hrelid = RelationGetRelid(heap);
- Oid irelid = RelationGetRelid(index);
-
- heap_close(heap, NoLock);
- index_close(index);
- UpdateStats(hrelid, reltuples);
- UpdateStats(irelid, buildstate.indtuples);
- }
+ /* since we just counted the # of tuples, may as well update stats */
+ IndexCloseAndUpdateStats(heap, reltuples, index, buildstate.indtuples);
freeGISTstate(&buildstate.giststate);
#ifdef GISTDEBUG