mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
Fix memory leaks in event trigger code.
Spotted by Jeff Davis.
This commit is contained in:
parent
ac78c4178b
commit
eea65943c6
7
src/backend/utils/cache/evtcache.c
vendored
7
src/backend/utils/cache/evtcache.c
vendored
@ -84,7 +84,7 @@ BuildEventTriggerCache(void)
|
||||
* the cache failed, then there might be some junk lying around
|
||||
* that we want to reclaim.
|
||||
*/
|
||||
MemoryContextReset(EventTriggerCacheContext);
|
||||
MemoryContextResetAndDeleteChildren(EventTriggerCacheContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -119,8 +119,9 @@ BuildEventTriggerCache(void)
|
||||
ctl.keysize = sizeof(EventTriggerEvent);
|
||||
ctl.entrysize = sizeof(EventTriggerCacheEntry);
|
||||
ctl.hash = tag_hash;
|
||||
ctl.hcxt = EventTriggerCacheContext;
|
||||
cache = hash_create("Event Trigger Cache", 32, &ctl,
|
||||
HASH_ELEM | HASH_FUNCTION);
|
||||
HASH_ELEM | HASH_FUNCTION | HASH_CONTEXT);
|
||||
|
||||
/*
|
||||
* Prepare to scan pg_event_trigger in name order. We use an MVCC
|
||||
@ -237,6 +238,6 @@ DecodeTextArrayToCString(Datum array, char ***cstringp)
|
||||
static void
|
||||
InvalidateEventCacheCallback(Datum arg, int cacheid, uint32 hashvalue)
|
||||
{
|
||||
MemoryContextReset(EventTriggerCacheContext);
|
||||
MemoryContextResetAndDeleteChildren(EventTriggerCacheContext);
|
||||
EventTriggerCache = NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user