diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-12-27 18:55:52 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-12-27 18:55:52 +0000 |
commit | d4d1885e42ecc7d61c045f6d53b8fef4454083a9 (patch) | |
tree | 35574a51f8bdd4b0fc34eac62ef421d5f1779704 /src/backend/utils/cache/typcache.c | |
parent | c4371cdb8b7615938c255ba584ea67f8b7d496b5 (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/typcache.c')
-rw-r--r-- | src/backend/utils/cache/typcache.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c index 87927b815ba..397914971d5 100644 --- a/src/backend/utils/cache/typcache.c +++ b/src/backend/utils/cache/typcache.c @@ -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 */ |