v03_fix_memory_leak_in_hashed_subplan_node.patch

text/x-diff

Filename: v03_fix_memory_leak_in_hashed_subplan_node.patch
Type: text/x-diff
Part: 0
Message: Re: 回复:BUG #19040: Memory leak in hashed subplan node due to missing hashtempcxt reset

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
Series: patch v3
File+
src/backend/executor/execGrouping.c 5 0
diff --git a/src/backend/executor/execGrouping.c b/src/backend/executor/execGrouping.c
index b5400749353..600d1ae5a96 100644
--- a/src/backend/executor/execGrouping.c
+++ b/src/backend/executor/execGrouping.c
@@ -316,6 +316,7 @@ LookupTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot,
 	Assert(entry == NULL || entry->hash == local_hash);
 
 	MemoryContextSwitchTo(oldContext);
+	MemoryContextReset(hashtable->tempcxt);
 
 	return entry;
 }
@@ -338,6 +339,7 @@ TupleHashTableHash(TupleHashTable hashtable, TupleTableSlot *slot)
 	hash = TupleHashTableHash_internal(hashtable->hashtab, NULL);
 
 	MemoryContextSwitchTo(oldContext);
+	MemoryContextReset(hashtable->tempcxt);
 
 	return hash;
 }
@@ -365,6 +367,7 @@ LookupTupleHashEntryHash(TupleHashTable hashtable, TupleTableSlot *slot,
 	Assert(entry == NULL || entry->hash == hash);
 
 	MemoryContextSwitchTo(oldContext);
+	MemoryContextReset(hashtable->tempcxt);
 
 	return entry;
 }
@@ -398,7 +401,9 @@ FindTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot,
 	/* Search the hash table */
 	key = NULL;					/* flag to reference inputslot */
 	entry = tuplehash_lookup(hashtable->hashtab, key);
+
 	MemoryContextSwitchTo(oldContext);
+	MemoryContextReset(hashtable->tempcxt);
 
 	return entry;
 }