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

sql: add support for foreign key cascades in udfs #110396

Merged
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
12 changes: 11 additions & 1 deletion pkg/sql/apply_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ func runPlanInsidePlan(

plannerCopy := *params.p
plannerCopy.curPlan.planComponents = *plan

// "Pausable portal" execution model is only applicable to the outer
// statement since we actually need to execute all inner plans to completion
// before we can produce any "outer" rows to be returned to the client, so
Expand Down Expand Up @@ -333,6 +334,12 @@ func runPlanInsidePlan(
// We don't have "inner" subqueries, so the apply join can only refer to
// the "outer" ones.
plannerCopy.curPlan.subqueryPlans = params.p.curPlan.subqueryPlans
// During cleanup, nil out the inner subquery plans before closing the plan
// components. Otherwise, we may inadvertently close nodes that are needed
// when executing the outer query.
defer func() {
plan.subqueryPlans = nil
}()
}

distributePlan := getPlanDistribution(
Expand Down Expand Up @@ -365,10 +372,13 @@ func runPlanInsidePlan(
evalCtxFactory2 := func(usedConcurrently bool) *extendedEvalContext {
return evalCtxFactory()
}

plannerCopy.autoCommit = false
execCfg.DistSQLPlanner.PlanAndRunCascadesAndChecks(
ctx, &plannerCopy, evalCtxFactory2, &plannerCopy.curPlan.planComponents, recv,
)
// We might have appended some cascades or checks to the plannerCopy, so we
// need to update the plan for cleanup purposes before proceeding.
*plan = plannerCopy.curPlan.planComponents
if recv.commErr != nil {
return recv.commErr
}
Expand Down
Loading