Skip to content

Commit 68edd02

Browse files
committed
Fix for 8766f08: Use xact callback instead of the hook, it allowes to clean up after rollback
1 parent 61ea0bd commit 68edd02

File tree

1 file changed

+8
-27
lines changed

1 file changed

+8
-27
lines changed

pg_variables.c

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,6 @@ static void makePackHTAB(Package *package, bool is_trans);
8080
static inline ChangedObject *makeChangedObject(TransObject *object,
8181
MemoryContext ctx);
8282

83-
/* Hook functions */
84-
static void variable_ExecutorEnd(QueryDesc *queryDesc);
85-
8683
#define CHECK_ARGS_FOR_NULL() \
8784
do { \
8885
if (fcinfo->argnull[0]) \
@@ -113,9 +110,6 @@ static Oid LastTypeId = InvalidOid;
113110
*/
114111
static HASH_SEQ_STATUS *LastHSeqStatus = NULL;
115112

116-
/* Saved hook values for recall */
117-
static ExecutorEnd_hook_type prev_ExecutorEnd = NULL;
118-
119113
/* This stack contains lists of changed variables and packages per each subxact level */
120114
static dlist_head *changesStack = NULL;
121115
static MemoryContext changesStackContext = NULL;
@@ -2120,23 +2114,15 @@ pgvTransCallback(XactEvent event, void *arg)
21202114
break;
21212115
}
21222116
}
2123-
}
21242117

2125-
/*
2126-
* ExecutorEnd hook: clean up hash table sequential scan status
2127-
*/
2128-
static void
2129-
variable_ExecutorEnd(QueryDesc *queryDesc)
2130-
{
2131-
if (LastHSeqStatus)
2132-
{
2133-
hash_seq_term(LastHSeqStatus);
2134-
LastHSeqStatus = NULL;
2135-
}
2136-
if (prev_ExecutorEnd)
2137-
prev_ExecutorEnd(queryDesc);
2138-
else
2139-
standard_ExecutorEnd(queryDesc);
2118+
if (event == XACT_EVENT_PARALLEL_COMMIT || event == XACT_EVENT_COMMIT ||
2119+
event == XACT_EVENT_PREPARE ||
2120+
event == XACT_EVENT_PARALLEL_ABORT || event == XACT_EVENT_ABORT)
2121+
if (LastHSeqStatus)
2122+
{
2123+
hash_seq_term(LastHSeqStatus);
2124+
LastHSeqStatus = NULL;
2125+
}
21402126
}
21412127

21422128
/*
@@ -2147,10 +2133,6 @@ _PG_init(void)
21472133
{
21482134
RegisterXactCallback(pgvTransCallback, NULL);
21492135
RegisterSubXactCallback(pgvSubTransCallback, NULL);
2150-
2151-
/* Install hooks. */
2152-
prev_ExecutorEnd = ExecutorEnd_hook;
2153-
ExecutorEnd_hook = variable_ExecutorEnd;
21542136
}
21552137

21562138
/*
@@ -2161,5 +2143,4 @@ _PG_fini(void)
21612143
{
21622144
UnregisterXactCallback(pgvTransCallback, NULL);
21632145
UnregisterSubXactCallback(pgvSubTransCallback, NULL);
2164-
ExecutorEnd_hook = prev_ExecutorEnd;
21652146
}

0 commit comments

Comments
 (0)