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

Update Planning for Limits in the presence of foreign keys #15372

Merged
merged 7 commits into from
Mar 6, 2024
Next Next commit
refactor: move the check earlier
Signed-off-by: Manan Gupta <manan@planetscale.com>
  • Loading branch information
GuptaManan100 committed Feb 27, 2024
commit 0f41eda9c5018a3f2603e8a8c1431e2a7b73db44
12 changes: 6 additions & 6 deletions go/vt/vtgate/planbuilder/operators/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,6 @@ func createOperatorFromUpdate(ctx *plancontext.PlanningContext, updStmt *sqlpars
panic(vterrors.VT12001("update with limit with foreign key constraints"))
}

// Now we check if any of the foreign key columns that are being udpated have dependencies on other updated columns.
// This is unsafe, and we currently don't support this in Vitess.
if err := ctx.SemTable.ErrIfFkDependentColumnUpdated(updStmt.Exprs); err != nil {
panic(err)
}

return buildFkOperator(ctx, op, updClone, parentFks, childFks, vTbl)
}

Expand All @@ -167,6 +161,12 @@ func errIfUpdateNotSupported(ctx *plancontext.PlanningContext, stmt *sqlparser.U
panic(vterrors.VT12001("multi-table UPDATE statement with multi-target column update"))
}
}

// Now we check if any of the foreign key columns that are being udpated have dependencies on other updated columns.
// This is unsafe, and we currently don't support this in Vitess.
if err := ctx.SemTable.ErrIfFkDependentColumnUpdated(stmt.Exprs); err != nil {
panic(err)
}
}

func createUpdateOperator(ctx *plancontext.PlanningContext, updStmt *sqlparser.Update) (Operator, *vindexes.Table, *sqlparser.Update) {
Expand Down