Skip to content

Commit 0fc733e

Browse files
committedFeb 16, 2025·
Respect other extensions' ExecutorStart hooks
When we override ExecutorStart hook that has been set by another extension we have to chain-call it not to disrupt other extension's integrity.
1 parent 9b499aa commit 0fc733e

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed
 

‎.unreleased/pr_7712

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixes: #7712 Respect other extensions' ExecutorStart hooks

‎tsl/src/hypercore/attr_capture.c

+20-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct CaptureAttributesContext
3232
};
3333

3434
static ExecutorStart_hook_type prev_ExecutorStart = NULL;
35+
static bool ExecutorStart_hook_initialized = false;
3536

3637
static void
3738
capture_var(Var *node, struct CaptureAttributesContext *context)
@@ -216,8 +217,15 @@ capture_ExecutorStart(QueryDesc *queryDesc, int eflags)
216217
ListCell *cell;
217218
#endif
218219

219-
/* Call the standard executor start function to set up plan states. */
220-
standard_ExecutorStart(queryDesc, eflags);
220+
if (prev_ExecutorStart)
221+
{
222+
prev_ExecutorStart(queryDesc, eflags);
223+
}
224+
else
225+
{
226+
/* Call the standard executor start function to set up plan states. */
227+
standard_ExecutorStart(queryDesc, eflags);
228+
}
221229

222230
struct CaptureAttributesContext context = {
223231
.rtable = queryDesc->plannedstmt->rtable,
@@ -245,6 +253,14 @@ capture_ExecutorStart(QueryDesc *queryDesc, int eflags)
245253
void
246254
_attr_capture_init(void)
247255
{
248-
prev_ExecutorStart = ExecutorStart_hook;
249-
ExecutorStart_hook = capture_ExecutorStart;
256+
/*
257+
* TSL init might be reexecuted so we need to make
258+
* sure to not initialize hook multiple times
259+
*/
260+
if (!ExecutorStart_hook_initialized)
261+
{
262+
ExecutorStart_hook_initialized = true;
263+
prev_ExecutorStart = ExecutorStart_hook;
264+
ExecutorStart_hook = capture_ExecutorStart;
265+
}
250266
}

0 commit comments

Comments
 (0)
Please sign in to comment.