mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +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:
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
|
||||
*
|
||||
* 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 */
|
||||
HASHCTL ctl;
|
||||
|
||||
if (!CacheMemoryContext)
|
||||
CreateCacheMemoryContext();
|
||||
|
||||
MemSet(&ctl, 0, sizeof(ctl));
|
||||
ctl.keysize = sizeof(Oid);
|
||||
ctl.entrysize = sizeof(TypeCacheEntry);
|
||||
ctl.hash = oid_hash;
|
||||
TypeCacheHash = hash_create("Type information cache", 64,
|
||||
&ctl, HASH_ELEM | HASH_FUNCTION);
|
||||
|
||||
/* Also make sure CacheMemoryContext exists */
|
||||
if (!CacheMemoryContext)
|
||||
CreateCacheMemoryContext();
|
||||
}
|
||||
|
||||
/* 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
|
||||
*
|
||||
* Note: we tell fmgr the finfo structures live in CacheMemoryContext,
|
||||
* which is not quite right (they're really in DynaHashContext) but this
|
||||
* will do for our purposes.
|
||||
* which is not quite right (they're really in the hash table's private
|
||||
* memory context) but this will do for our purposes.
|
||||
*/
|
||||
if ((flags & TYPECACHE_EQ_OPR_FINFO) &&
|
||||
typentry->eq_opr_finfo.fn_oid == InvalidOid &&
|
||||
@ -424,15 +425,16 @@ assign_record_type_typmod(TupleDesc tupDesc)
|
||||
/* First time through: initialize the hash table */
|
||||
HASHCTL ctl;
|
||||
|
||||
if (!CacheMemoryContext)
|
||||
CreateCacheMemoryContext();
|
||||
|
||||
MemSet(&ctl, 0, sizeof(ctl));
|
||||
ctl.keysize = REC_HASH_KEYS * sizeof(Oid);
|
||||
ctl.entrysize = sizeof(RecordCacheEntry);
|
||||
ctl.hash = tag_hash;
|
||||
RecordCacheHash = hash_create("Record information cache", 64,
|
||||
&ctl, HASH_ELEM | HASH_FUNCTION);
|
||||
|
||||
/* Also make sure CacheMemoryContext exists */
|
||||
if (!CacheMemoryContext)
|
||||
CreateCacheMemoryContext();
|
||||
}
|
||||
|
||||
/* Find or create a hashtable entry for this hash class */
|
||||
|
Reference in New Issue
Block a user