Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport to 2.18.x: #7712: Respect other extensions' ExecutorStart hooks #7715

Merged
merged 1 commit into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .unreleased/pr_7712
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes: #7712 Respect other extensions' ExecutorStart hooks
24 changes: 20 additions & 4 deletions tsl/src/hypercore/attr_capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct CaptureAttributesContext
};

static ExecutorStart_hook_type prev_ExecutorStart = NULL;
static bool ExecutorStart_hook_initialized = false;

static void
capture_var(Var *node, struct CaptureAttributesContext *context)
Expand Down Expand Up @@ -216,8 +217,15 @@ capture_ExecutorStart(QueryDesc *queryDesc, int eflags)
ListCell *cell;
#endif

/* Call the standard executor start function to set up plan states. */
standard_ExecutorStart(queryDesc, eflags);
if (prev_ExecutorStart)
{
prev_ExecutorStart(queryDesc, eflags);
}
else
{
/* Call the standard executor start function to set up plan states. */
standard_ExecutorStart(queryDesc, eflags);
}

struct CaptureAttributesContext context = {
.rtable = queryDesc->plannedstmt->rtable,
Expand Down Expand Up @@ -245,6 +253,14 @@ capture_ExecutorStart(QueryDesc *queryDesc, int eflags)
void
_attr_capture_init(void)
{
prev_ExecutorStart = ExecutorStart_hook;
ExecutorStart_hook = capture_ExecutorStart;
/*
* TSL init might be reexecuted so we need to make
* sure to not initialize hook multiple times
*/
if (!ExecutorStart_hook_initialized)
{
ExecutorStart_hook_initialized = true;
prev_ExecutorStart = ExecutorStart_hook;
ExecutorStart_hook = capture_ExecutorStart;
}
}
Loading