summaryrefslogtreecommitdiff
path: root/src/backend/utils/cache/relcache.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-12-27 18:55:52 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-12-27 18:55:52 +0000
commitd4d1885e42ecc7d61c045f6d53b8fef4454083a9 (patch)
tree35574a51f8bdd4b0fc34eac62ef421d5f1779704 /src/backend/utils/cache/relcache.c
parentc4371cdb8b7615938c255ba584ea67f8b7d496b5 (diff)
Remove a couple of unnecessary calls of CreateCacheMemoryContext. These
probably got there via blind copy-and-paste from one of the legitimate callers, so rearrange and comment that code a bit to make it clearer that this isn't a necessary prerequisite to hash_create. Per observation from Robert Haas.
Diffstat (limited to 'src/backend/utils/cache/relcache.c')
-rw-r--r--src/backend/utils/cache/relcache.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 82c4bbc01a9..7fc6d1e919b 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.293 2009/12/07 05:22:22 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.294 2009/12/27 18:55:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1181,15 +1181,16 @@ LookupOpclassInfo(Oid operatorClassOid,
/* First time through: initialize the opclass cache */
HASHCTL ctl;
- if (!CacheMemoryContext)
- CreateCacheMemoryContext();
-
MemSet(&ctl, 0, sizeof(ctl));
ctl.keysize = sizeof(Oid);
ctl.entrysize = sizeof(OpClassCacheEnt);
ctl.hash = oid_hash;
OpClassCache = hash_create("Operator class cache", 64,
&ctl, HASH_ELEM | HASH_FUNCTION);
+
+ /* Also make sure CacheMemoryContext exists */
+ if (!CacheMemoryContext)
+ CreateCacheMemoryContext();
}
opcentry = (OpClassCacheEnt *) hash_search(OpClassCache,
@@ -2513,17 +2514,14 @@ RelationBuildLocalRelation(const char *relname,
void
RelationCacheInitialize(void)
{
- MemoryContext oldcxt;
HASHCTL ctl;
/*
- * switch to cache memory context
+ * make sure cache memory context exists
*/
if (!CacheMemoryContext)
CreateCacheMemoryContext();
- oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
-
/*
* create hashtable that indexes the relcache
*/
@@ -2533,8 +2531,6 @@ RelationCacheInitialize(void)
ctl.hash = oid_hash;
RelationIdCache = hash_create("Relcache by OID", INITRELCACHESIZE,
&ctl, HASH_ELEM | HASH_FUNCTION);
-
- MemoryContextSwitchTo(oldcxt);
}
/*