Use ResourceOwner to track WaitEventSet in PG17

Relevant PG commit:
50c67c2019ab9ade8aa8768bfe604cd802fe8591
50c67c2019
pull/7699/head
naisila 2024-07-10 12:09:27 +02:00
parent 8513145ae5
commit 7ac47941bd
4 changed files with 8 additions and 3 deletions

View File

@ -866,7 +866,8 @@ WaitEventSetFromMultiConnectionStates(List *connections, int *waitCount)
*waitCount = 0; *waitCount = 0;
} }
WaitEventSet *waitEventSet = CreateWaitEventSet(CurrentMemoryContext, eventSetSize); WaitEventSet *waitEventSet = CreateWaitEventSet(WaitEventSetTracker_compat,
eventSetSize);
EnsureReleaseResource((MemoryContextCallbackFunction) (&FreeWaitEventSet), EnsureReleaseResource((MemoryContextCallbackFunction) (&FreeWaitEventSet),
waitEventSet); waitEventSet);

View File

@ -1130,7 +1130,7 @@ BuildWaitEventSet(MultiConnection **allConnections, int totalConnectionCount,
/* allocate pending connections + 2 for the signal latch and postmaster death */ /* allocate pending connections + 2 for the signal latch and postmaster death */
/* (CreateWaitEventSet makes room for pgwin32_signal_event automatically) */ /* (CreateWaitEventSet makes room for pgwin32_signal_event automatically) */
WaitEventSet *waitEventSet = CreateWaitEventSet(CurrentMemoryContext, WaitEventSet *waitEventSet = CreateWaitEventSet(WaitEventSetTracker_compat,
pendingConnectionCount + 2); pendingConnectionCount + 2);
for (int connectionIndex = 0; connectionIndex < pendingConnectionCount; for (int connectionIndex = 0; connectionIndex < pendingConnectionCount;

View File

@ -4740,7 +4740,7 @@ BuildWaitEventSet(List *sessionList)
int eventSetSize = GetEventSetSize(sessionList); int eventSetSize = GetEventSetSize(sessionList);
WaitEventSet *waitEventSet = WaitEventSet *waitEventSet =
CreateWaitEventSet(CurrentMemoryContext, eventSetSize); CreateWaitEventSet(WaitEventSetTracker_compat, eventSetSize);
WorkerSession *session = NULL; WorkerSession *session = NULL;
foreach_declared_ptr(session, sessionList) foreach_declared_ptr(session, sessionList)

View File

@ -98,6 +98,8 @@ getStxstattarget_compat(HeapTuple tup)
#define getAlterStatsStxstattarget_compat(a) ((Node *) makeInteger(a)) #define getAlterStatsStxstattarget_compat(a) ((Node *) makeInteger(a))
#define getIntStxstattarget_compat(a) (intVal(a)) #define getIntStxstattarget_compat(a) (intVal(a))
#define WaitEventSetTracker_compat CurrentResourceOwner
#else #else
#include "access/htup_details.h" #include "access/htup_details.h"
@ -119,6 +121,8 @@ getStxstattarget_compat(HeapTuple tup)
#define getAlterStatsStxstattarget_compat(a) (a) #define getAlterStatsStxstattarget_compat(a) (a)
#define getIntStxstattarget_compat(a) (a) #define getIntStxstattarget_compat(a) (a)
#define WaitEventSetTracker_compat CurrentMemoryContext
#endif #endif
#if PG_VERSION_NUM >= PG_VERSION_16 #if PG_VERSION_NUM >= PG_VERSION_16