Skip to content

Commit eea6594

Browse files
committed
Fix memory leaks in event trigger code.
Spotted by Jeff Davis.
1 parent ac78c41 commit eea6594

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/backend/utils/cache/evtcache.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ BuildEventTriggerCache(void)
8484
* the cache failed, then there might be some junk lying around
8585
* that we want to reclaim.
8686
*/
87-
MemoryContextReset(EventTriggerCacheContext);
87+
MemoryContextResetAndDeleteChildren(EventTriggerCacheContext);
8888
}
8989
else
9090
{
@@ -119,8 +119,9 @@ BuildEventTriggerCache(void)
119119
ctl.keysize = sizeof(EventTriggerEvent);
120120
ctl.entrysize = sizeof(EventTriggerCacheEntry);
121121
ctl.hash = tag_hash;
122+
ctl.hcxt = EventTriggerCacheContext;
122123
cache = hash_create("Event Trigger Cache", 32, &ctl,
123-
HASH_ELEM | HASH_FUNCTION);
124+
HASH_ELEM | HASH_FUNCTION | HASH_CONTEXT);
124125

125126
/*
126127
* Prepare to scan pg_event_trigger in name order. We use an MVCC
@@ -237,6 +238,6 @@ DecodeTextArrayToCString(Datum array, char ***cstringp)
237238
static void
238239
InvalidateEventCacheCallback(Datum arg, int cacheid, uint32 hashvalue)
239240
{
240-
MemoryContextReset(EventTriggerCacheContext);
241+
MemoryContextResetAndDeleteChildren(EventTriggerCacheContext);
241242
EventTriggerCache = NULL;
242243
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy