Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e5af4d3

Browse files
committed
Fix for 68edd02: We need the hook anyway if we use long transactions
1 parent 68edd02 commit e5af4d3

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

pg_variables.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ 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+
8386
#define CHECK_ARGS_FOR_NULL() \
8487
do { \
8588
if (fcinfo->argnull[0]) \
@@ -110,6 +113,9 @@ static Oid LastTypeId = InvalidOid;
110113
*/
111114
static HASH_SEQ_STATUS *LastHSeqStatus = NULL;
112115

116+
/* Saved hook values for recall */
117+
static ExecutorEnd_hook_type prev_ExecutorEnd = NULL;
118+
113119
/* This stack contains lists of changed variables and packages per each subxact level */
114120
static dlist_head *changesStack = NULL;
115121
static MemoryContext changesStackContext = NULL;
@@ -2125,6 +2131,23 @@ pgvTransCallback(XactEvent event, void *arg)
21252131
}
21262132
}
21272133

2134+
/*
2135+
* ExecutorEnd hook: clean up hash table sequential scan status
2136+
*/
2137+
static void
2138+
variable_ExecutorEnd(QueryDesc *queryDesc)
2139+
{
2140+
if (LastHSeqStatus)
2141+
{
2142+
hash_seq_term(LastHSeqStatus);
2143+
LastHSeqStatus = NULL;
2144+
}
2145+
if (prev_ExecutorEnd)
2146+
prev_ExecutorEnd(queryDesc);
2147+
else
2148+
standard_ExecutorEnd(queryDesc);
2149+
}
2150+
21282151
/*
21292152
* Register callback function when module starts
21302153
*/
@@ -2133,6 +2156,10 @@ _PG_init(void)
21332156
{
21342157
RegisterXactCallback(pgvTransCallback, NULL);
21352158
RegisterSubXactCallback(pgvSubTransCallback, NULL);
2159+
2160+
/* Install hooks. */
2161+
prev_ExecutorEnd = ExecutorEnd_hook;
2162+
ExecutorEnd_hook = variable_ExecutorEnd;
21362163
}
21372164

21382165
/*
@@ -2143,4 +2170,5 @@ _PG_fini(void)
21432170
{
21442171
UnregisterXactCallback(pgvTransCallback, NULL);
21452172
UnregisterSubXactCallback(pgvSubTransCallback, NULL);
2173+
ExecutorEnd_hook = prev_ExecutorEnd;
21462174
}

0 commit comments

Comments
 (0)