From 2bf3aa120536ad85f20492c003d34846ecc99425 Mon Sep 17 00:00:00 2001 From: David Geier Date: Fri, 18 Sep 2026 12:52:47 +0200 Subject: [PATCH v2 1/8] Remove unnecessary CacheMemoryContext existence checks RelationCacheInitialize() is called from InitPostgres() before any catalog or relcache access can happen, and it creates CacheMemoryContext. Since that context is a child of TopMemoryContext and is never deleted or reset, it is guaranteed to exist by the time any of these code paths run. The remaining check in RelationCacheInitialize() itself is the one that actually creates it. --- src/backend/utils/cache/relcache.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index d8f04a05309..dc42f2c4c1f 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -1676,10 +1676,6 @@ LookupOpclassInfo(Oid operatorClassOid, /* First time through: initialize the opclass cache */ HASHCTL ctl; - /* Also make sure CacheMemoryContext exists */ - if (!CacheMemoryContext) - CreateCacheMemoryContext(); - ctl.keysize = sizeof(Oid); ctl.entrysize = sizeof(OpClassCacheEnt); OpClassCache = hash_create("Operator class cache", 64, @@ -3565,9 +3561,6 @@ RelationBuildLocalRelation(const char *relname, /* * switch to the cache context to create the relcache entry. */ - if (!CacheMemoryContext) - CreateCacheMemoryContext(); - oldcxt = MemoryContextSwitchTo(CacheMemoryContext); /* -- 2.55.0