diff --git a/src/backend/partitioning/partdesc.c b/src/backend/partitioning/partdesc.c index b207b765f2..7f15774266 100644 --- a/src/backend/partitioning/partdesc.c +++ b/src/backend/partitioning/partdesc.c @@ -72,6 +72,15 @@ RelationBuildPartitionDesc(Relation rel) MemoryContext oldcxt; int *mapping; + MemoryContext tmp; + MemoryContext old; + + tmp = AllocSetContextCreate(CurrentMemoryContext, + "tmp context", + ALLOCSET_SMALL_SIZES); + + old = MemoryContextSwitchTo(tmp); + /* * Get partition oids from pg_inherits. This uses a single snapshot to * fetch the list of children, so while more children may be getting added @@ -231,6 +240,9 @@ RelationBuildPartitionDesc(Relation rel) } } + MemoryContextSwitchTo(old); + MemoryContextDelete(tmp); + rel->rd_partdesc = partdesc; }