diff options
Diffstat (limited to 'src/backend/utils/cache')
-rw-r--r-- | src/backend/utils/cache/plancache.c | 3 | ||||
-rw-r--r-- | src/backend/utils/cache/relcache.c | 37 | ||||
-rw-r--r-- | src/backend/utils/cache/ts_cache.c | 13 |
3 files changed, 31 insertions, 22 deletions
diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c index 8d7d8e04c9f..85bb7b914a0 100644 --- a/src/backend/utils/cache/plancache.c +++ b/src/backend/utils/cache/plancache.c @@ -180,6 +180,7 @@ CreateCachedPlan(RawStmt *raw_parse_tree, plansource->magic = CACHEDPLANSOURCE_MAGIC; plansource->raw_parse_tree = copyObject(raw_parse_tree); plansource->query_string = pstrdup(query_string); + MemoryContextSetIdentifier(source_context, plansource->query_string); plansource->commandTag = commandTag; plansource->param_types = NULL; plansource->num_params = 0; @@ -951,6 +952,7 @@ BuildCachedPlan(CachedPlanSource *plansource, List *qlist, plan_context = AllocSetContextCreate(CurrentMemoryContext, "CachedPlan", ALLOCSET_START_SMALL_SIZES); + MemoryContextCopySetIdentifier(plan_context, plansource->query_string); /* * Copy plan into the new context. @@ -1346,6 +1348,7 @@ CopyCachedPlan(CachedPlanSource *plansource) newsource->magic = CACHEDPLANSOURCE_MAGIC; newsource->raw_parse_tree = copyObject(plansource->raw_parse_tree); newsource->query_string = pstrdup(plansource->query_string); + MemoryContextSetIdentifier(source_context, newsource->query_string); newsource->commandTag = plansource->commandTag; if (plansource->num_params > 0) { diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 46513024405..de502f9bc9e 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -675,11 +675,12 @@ RelationBuildRuleLock(Relation relation) /* * Make the private context. Assume it'll not contain much data. */ - rulescxt = AllocSetContextCreateExtended(CacheMemoryContext, - RelationGetRelationName(relation), - MEMCONTEXT_COPY_NAME, - ALLOCSET_SMALL_SIZES); + rulescxt = AllocSetContextCreate(CacheMemoryContext, + "relation rules", + ALLOCSET_SMALL_SIZES); relation->rd_rulescxt = rulescxt; + MemoryContextCopySetIdentifier(rulescxt, + RelationGetRelationName(relation)); /* * allocate an array to hold the rewrite rules (the array is extended if @@ -852,10 +853,11 @@ RelationBuildPartitionKey(Relation relation) if (!HeapTupleIsValid(tuple)) return; - partkeycxt = AllocSetContextCreateExtended(CurTransactionContext, - RelationGetRelationName(relation), - MEMCONTEXT_COPY_NAME, - ALLOCSET_SMALL_SIZES); + partkeycxt = AllocSetContextCreate(CurTransactionContext, + "partition key", + ALLOCSET_SMALL_SIZES); + MemoryContextCopySetIdentifier(partkeycxt, + RelationGetRelationName(relation)); key = (PartitionKey) MemoryContextAllocZero(partkeycxt, sizeof(PartitionKeyData)); @@ -1533,11 +1535,12 @@ RelationInitIndexAccessInfo(Relation relation) * a context, and not just a couple of pallocs, is so that we won't leak * any subsidiary info attached to fmgr lookup records. */ - indexcxt = AllocSetContextCreateExtended(CacheMemoryContext, - RelationGetRelationName(relation), - MEMCONTEXT_COPY_NAME, - ALLOCSET_SMALL_SIZES); + indexcxt = AllocSetContextCreate(CacheMemoryContext, + "index info", + ALLOCSET_SMALL_SIZES); relation->rd_indexcxt = indexcxt; + MemoryContextCopySetIdentifier(indexcxt, + RelationGetRelationName(relation)); /* * Now we can fetch the index AM's API struct @@ -5603,12 +5606,12 @@ load_relcache_init_file(bool shared) * prepare index info context --- parameters should match * RelationInitIndexAccessInfo */ - indexcxt = - AllocSetContextCreateExtended(CacheMemoryContext, - RelationGetRelationName(rel), - MEMCONTEXT_COPY_NAME, - ALLOCSET_SMALL_SIZES); + indexcxt = AllocSetContextCreate(CacheMemoryContext, + "index info", + ALLOCSET_SMALL_SIZES); rel->rd_indexcxt = indexcxt; + MemoryContextCopySetIdentifier(indexcxt, + RelationGetRelationName(rel)); /* * Now we can fetch the index AM's API struct. (We can't store diff --git a/src/backend/utils/cache/ts_cache.c b/src/backend/utils/cache/ts_cache.c index 3d5c1941488..97347780d3b 100644 --- a/src/backend/utils/cache/ts_cache.c +++ b/src/backend/utils/cache/ts_cache.c @@ -294,16 +294,19 @@ lookup_ts_dictionary_cache(Oid dictId) Assert(!found); /* it wasn't there a moment ago */ /* Create private memory context the first time through */ - saveCtx = AllocSetContextCreateExtended(CacheMemoryContext, - NameStr(dict->dictname), - MEMCONTEXT_COPY_NAME, - ALLOCSET_SMALL_SIZES); + saveCtx = AllocSetContextCreate(CacheMemoryContext, + "TS dictionary", + ALLOCSET_SMALL_SIZES); + MemoryContextCopySetIdentifier(saveCtx, NameStr(dict->dictname)); } else { /* Clear the existing entry's private context */ saveCtx = entry->dictCtx; - MemoryContextResetAndDeleteChildren(saveCtx); + /* Don't let context's ident pointer dangle while we reset it */ + MemoryContextSetIdentifier(saveCtx, NULL); + MemoryContextReset(saveCtx); + MemoryContextCopySetIdentifier(saveCtx, NameStr(dict->dictname)); } MemSet(entry, 0, sizeof(TSDictionaryCacheEntry)); |