mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
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.
This commit is contained in:
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/predtest.c,v 1.27 2009/06/11 14:48:59 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/optimizer/util/predtest.c,v 1.28 2009/12/27 18:55:52 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1532,9 +1532,6 @@ get_btree_test_op(Oid pred_op, Oid clause_op, bool refute_it)
|
|||||||
/* First time through: initialize the hash table */
|
/* First time through: initialize the hash table */
|
||||||
HASHCTL ctl;
|
HASHCTL ctl;
|
||||||
|
|
||||||
if (!CacheMemoryContext)
|
|
||||||
CreateCacheMemoryContext();
|
|
||||||
|
|
||||||
MemSet(&ctl, 0, sizeof(ctl));
|
MemSet(&ctl, 0, sizeof(ctl));
|
||||||
ctl.keysize = sizeof(OprProofCacheKey);
|
ctl.keysize = sizeof(OprProofCacheKey);
|
||||||
ctl.entrysize = sizeof(OprProofCacheEntry);
|
ctl.entrysize = sizeof(OprProofCacheEntry);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/parser/parse_oper.c,v 1.109 2009/06/13 15:42:09 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/parser/parse_oper.c,v 1.110 2009/12/27 18:55:52 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1098,9 +1098,6 @@ find_oper_cache_entry(OprCacheKey *key)
|
|||||||
/* First time through: initialize the hash table */
|
/* First time through: initialize the hash table */
|
||||||
HASHCTL ctl;
|
HASHCTL ctl;
|
||||||
|
|
||||||
if (!CacheMemoryContext)
|
|
||||||
CreateCacheMemoryContext();
|
|
||||||
|
|
||||||
MemSet(&ctl, 0, sizeof(ctl));
|
MemSet(&ctl, 0, sizeof(ctl));
|
||||||
ctl.keysize = sizeof(OprCacheKey);
|
ctl.keysize = sizeof(OprCacheKey);
|
||||||
ctl.entrysize = sizeof(OprCacheEntry);
|
ctl.entrysize = sizeof(OprCacheEntry);
|
||||||
|
16
src/backend/utils/cache/relcache.c
vendored
16
src/backend/utils/cache/relcache.c
vendored
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 */
|
/* First time through: initialize the opclass cache */
|
||||||
HASHCTL ctl;
|
HASHCTL ctl;
|
||||||
|
|
||||||
if (!CacheMemoryContext)
|
|
||||||
CreateCacheMemoryContext();
|
|
||||||
|
|
||||||
MemSet(&ctl, 0, sizeof(ctl));
|
MemSet(&ctl, 0, sizeof(ctl));
|
||||||
ctl.keysize = sizeof(Oid);
|
ctl.keysize = sizeof(Oid);
|
||||||
ctl.entrysize = sizeof(OpClassCacheEnt);
|
ctl.entrysize = sizeof(OpClassCacheEnt);
|
||||||
ctl.hash = oid_hash;
|
ctl.hash = oid_hash;
|
||||||
OpClassCache = hash_create("Operator class cache", 64,
|
OpClassCache = hash_create("Operator class cache", 64,
|
||||||
&ctl, HASH_ELEM | HASH_FUNCTION);
|
&ctl, HASH_ELEM | HASH_FUNCTION);
|
||||||
|
|
||||||
|
/* Also make sure CacheMemoryContext exists */
|
||||||
|
if (!CacheMemoryContext)
|
||||||
|
CreateCacheMemoryContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
opcentry = (OpClassCacheEnt *) hash_search(OpClassCache,
|
opcentry = (OpClassCacheEnt *) hash_search(OpClassCache,
|
||||||
@ -2513,17 +2514,14 @@ RelationBuildLocalRelation(const char *relname,
|
|||||||
void
|
void
|
||||||
RelationCacheInitialize(void)
|
RelationCacheInitialize(void)
|
||||||
{
|
{
|
||||||
MemoryContext oldcxt;
|
|
||||||
HASHCTL ctl;
|
HASHCTL ctl;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* switch to cache memory context
|
* make sure cache memory context exists
|
||||||
*/
|
*/
|
||||||
if (!CacheMemoryContext)
|
if (!CacheMemoryContext)
|
||||||
CreateCacheMemoryContext();
|
CreateCacheMemoryContext();
|
||||||
|
|
||||||
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create hashtable that indexes the relcache
|
* create hashtable that indexes the relcache
|
||||||
*/
|
*/
|
||||||
@ -2533,8 +2531,6 @@ RelationCacheInitialize(void)
|
|||||||
ctl.hash = oid_hash;
|
ctl.hash = oid_hash;
|
||||||
RelationIdCache = hash_create("Relcache by OID", INITRELCACHESIZE,
|
RelationIdCache = hash_create("Relcache by OID", INITRELCACHESIZE,
|
||||||
&ctl, HASH_ELEM | HASH_FUNCTION);
|
&ctl, HASH_ELEM | HASH_FUNCTION);
|
||||||
|
|
||||||
MemoryContextSwitchTo(oldcxt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
24
src/backend/utils/cache/ts_cache.c
vendored
24
src/backend/utils/cache/ts_cache.c
vendored
@ -20,7 +20,7 @@
|
|||||||
* Copyright (c) 2006-2009, PostgreSQL Global Development Group
|
* Copyright (c) 2006-2009, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/cache/ts_cache.c,v 1.9 2009/01/01 17:23:50 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/cache/ts_cache.c,v 1.10 2009/12/27 18:55:52 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -42,7 +42,6 @@
|
|||||||
#include "tsearch/ts_cache.h"
|
#include "tsearch/ts_cache.h"
|
||||||
#include "utils/array.h"
|
#include "utils/array.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
#include "utils/catcache.h"
|
|
||||||
#include "utils/fmgroids.h"
|
#include "utils/fmgroids.h"
|
||||||
#include "utils/inval.h"
|
#include "utils/inval.h"
|
||||||
#include "utils/lsyscache.h"
|
#include "utils/lsyscache.h"
|
||||||
@ -119,9 +118,6 @@ lookup_ts_parser_cache(Oid prsId)
|
|||||||
/* First time through: initialize the hash table */
|
/* First time through: initialize the hash table */
|
||||||
HASHCTL ctl;
|
HASHCTL ctl;
|
||||||
|
|
||||||
if (!CacheMemoryContext)
|
|
||||||
CreateCacheMemoryContext();
|
|
||||||
|
|
||||||
MemSet(&ctl, 0, sizeof(ctl));
|
MemSet(&ctl, 0, sizeof(ctl));
|
||||||
ctl.keysize = sizeof(Oid);
|
ctl.keysize = sizeof(Oid);
|
||||||
ctl.entrysize = sizeof(TSParserCacheEntry);
|
ctl.entrysize = sizeof(TSParserCacheEntry);
|
||||||
@ -131,6 +127,10 @@ lookup_ts_parser_cache(Oid prsId)
|
|||||||
/* Flush cache on pg_ts_parser changes */
|
/* Flush cache on pg_ts_parser changes */
|
||||||
CacheRegisterSyscacheCallback(TSPARSEROID, InvalidateTSCacheCallBack,
|
CacheRegisterSyscacheCallback(TSPARSEROID, InvalidateTSCacheCallBack,
|
||||||
PointerGetDatum(TSParserCacheHash));
|
PointerGetDatum(TSParserCacheHash));
|
||||||
|
|
||||||
|
/* Also make sure CacheMemoryContext exists */
|
||||||
|
if (!CacheMemoryContext)
|
||||||
|
CreateCacheMemoryContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check single-entry cache */
|
/* Check single-entry cache */
|
||||||
@ -219,9 +219,6 @@ lookup_ts_dictionary_cache(Oid dictId)
|
|||||||
/* First time through: initialize the hash table */
|
/* First time through: initialize the hash table */
|
||||||
HASHCTL ctl;
|
HASHCTL ctl;
|
||||||
|
|
||||||
if (!CacheMemoryContext)
|
|
||||||
CreateCacheMemoryContext();
|
|
||||||
|
|
||||||
MemSet(&ctl, 0, sizeof(ctl));
|
MemSet(&ctl, 0, sizeof(ctl));
|
||||||
ctl.keysize = sizeof(Oid);
|
ctl.keysize = sizeof(Oid);
|
||||||
ctl.entrysize = sizeof(TSDictionaryCacheEntry);
|
ctl.entrysize = sizeof(TSDictionaryCacheEntry);
|
||||||
@ -233,6 +230,10 @@ lookup_ts_dictionary_cache(Oid dictId)
|
|||||||
PointerGetDatum(TSDictionaryCacheHash));
|
PointerGetDatum(TSDictionaryCacheHash));
|
||||||
CacheRegisterSyscacheCallback(TSTEMPLATEOID, InvalidateTSCacheCallBack,
|
CacheRegisterSyscacheCallback(TSTEMPLATEOID, InvalidateTSCacheCallBack,
|
||||||
PointerGetDatum(TSDictionaryCacheHash));
|
PointerGetDatum(TSDictionaryCacheHash));
|
||||||
|
|
||||||
|
/* Also make sure CacheMemoryContext exists */
|
||||||
|
if (!CacheMemoryContext)
|
||||||
|
CreateCacheMemoryContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check single-entry cache */
|
/* Check single-entry cache */
|
||||||
@ -370,9 +371,6 @@ init_ts_config_cache(void)
|
|||||||
{
|
{
|
||||||
HASHCTL ctl;
|
HASHCTL ctl;
|
||||||
|
|
||||||
if (!CacheMemoryContext)
|
|
||||||
CreateCacheMemoryContext();
|
|
||||||
|
|
||||||
MemSet(&ctl, 0, sizeof(ctl));
|
MemSet(&ctl, 0, sizeof(ctl));
|
||||||
ctl.keysize = sizeof(Oid);
|
ctl.keysize = sizeof(Oid);
|
||||||
ctl.entrysize = sizeof(TSConfigCacheEntry);
|
ctl.entrysize = sizeof(TSConfigCacheEntry);
|
||||||
@ -384,6 +382,10 @@ init_ts_config_cache(void)
|
|||||||
PointerGetDatum(TSConfigCacheHash));
|
PointerGetDatum(TSConfigCacheHash));
|
||||||
CacheRegisterSyscacheCallback(TSCONFIGMAP, InvalidateTSCacheCallBack,
|
CacheRegisterSyscacheCallback(TSCONFIGMAP, InvalidateTSCacheCallBack,
|
||||||
PointerGetDatum(TSConfigCacheHash));
|
PointerGetDatum(TSConfigCacheHash));
|
||||||
|
|
||||||
|
/* Also make sure CacheMemoryContext exists */
|
||||||
|
if (!CacheMemoryContext)
|
||||||
|
CreateCacheMemoryContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
20
src/backend/utils/cache/typcache.c
vendored
20
src/backend/utils/cache/typcache.c
vendored
@ -36,7 +36,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.29 2009/01/01 17:23:50 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.30 2009/12/27 18:55:52 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -109,15 +109,16 @@ lookup_type_cache(Oid type_id, int flags)
|
|||||||
/* First time through: initialize the hash table */
|
/* First time through: initialize the hash table */
|
||||||
HASHCTL ctl;
|
HASHCTL ctl;
|
||||||
|
|
||||||
if (!CacheMemoryContext)
|
|
||||||
CreateCacheMemoryContext();
|
|
||||||
|
|
||||||
MemSet(&ctl, 0, sizeof(ctl));
|
MemSet(&ctl, 0, sizeof(ctl));
|
||||||
ctl.keysize = sizeof(Oid);
|
ctl.keysize = sizeof(Oid);
|
||||||
ctl.entrysize = sizeof(TypeCacheEntry);
|
ctl.entrysize = sizeof(TypeCacheEntry);
|
||||||
ctl.hash = oid_hash;
|
ctl.hash = oid_hash;
|
||||||
TypeCacheHash = hash_create("Type information cache", 64,
|
TypeCacheHash = hash_create("Type information cache", 64,
|
||||||
&ctl, HASH_ELEM | HASH_FUNCTION);
|
&ctl, HASH_ELEM | HASH_FUNCTION);
|
||||||
|
|
||||||
|
/* Also make sure CacheMemoryContext exists */
|
||||||
|
if (!CacheMemoryContext)
|
||||||
|
CreateCacheMemoryContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to look up an existing entry */
|
/* Try to look up an existing entry */
|
||||||
@ -249,8 +250,8 @@ lookup_type_cache(Oid type_id, int flags)
|
|||||||
* Set up fmgr lookup info as requested
|
* Set up fmgr lookup info as requested
|
||||||
*
|
*
|
||||||
* Note: we tell fmgr the finfo structures live in CacheMemoryContext,
|
* Note: we tell fmgr the finfo structures live in CacheMemoryContext,
|
||||||
* which is not quite right (they're really in DynaHashContext) but this
|
* which is not quite right (they're really in the hash table's private
|
||||||
* will do for our purposes.
|
* memory context) but this will do for our purposes.
|
||||||
*/
|
*/
|
||||||
if ((flags & TYPECACHE_EQ_OPR_FINFO) &&
|
if ((flags & TYPECACHE_EQ_OPR_FINFO) &&
|
||||||
typentry->eq_opr_finfo.fn_oid == InvalidOid &&
|
typentry->eq_opr_finfo.fn_oid == InvalidOid &&
|
||||||
@ -424,15 +425,16 @@ assign_record_type_typmod(TupleDesc tupDesc)
|
|||||||
/* First time through: initialize the hash table */
|
/* First time through: initialize the hash table */
|
||||||
HASHCTL ctl;
|
HASHCTL ctl;
|
||||||
|
|
||||||
if (!CacheMemoryContext)
|
|
||||||
CreateCacheMemoryContext();
|
|
||||||
|
|
||||||
MemSet(&ctl, 0, sizeof(ctl));
|
MemSet(&ctl, 0, sizeof(ctl));
|
||||||
ctl.keysize = REC_HASH_KEYS * sizeof(Oid);
|
ctl.keysize = REC_HASH_KEYS * sizeof(Oid);
|
||||||
ctl.entrysize = sizeof(RecordCacheEntry);
|
ctl.entrysize = sizeof(RecordCacheEntry);
|
||||||
ctl.hash = tag_hash;
|
ctl.hash = tag_hash;
|
||||||
RecordCacheHash = hash_create("Record information cache", 64,
|
RecordCacheHash = hash_create("Record information cache", 64,
|
||||||
&ctl, HASH_ELEM | HASH_FUNCTION);
|
&ctl, HASH_ELEM | HASH_FUNCTION);
|
||||||
|
|
||||||
|
/* Also make sure CacheMemoryContext exists */
|
||||||
|
if (!CacheMemoryContext)
|
||||||
|
CreateCacheMemoryContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find or create a hashtable entry for this hash class */
|
/* Find or create a hashtable entry for this hash class */
|
||||||
|
Reference in New Issue
Block a user