Skip to content

Commit

Permalink
fix: build on delete operator (#14833)
Browse files Browse the repository at this point in the history
Signed-off-by: Harshit Gangal <[email protected]>
  • Loading branch information
harshit-gangal authored Dec 20, 2023
1 parent c4b275c commit 6d43493
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions go/vt/vtgate/planbuilder/operators/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,32 +88,33 @@ func (d *Delete) ShortDescription() string {
return fmt.Sprintf("%s.%s%s%s", d.Target.VTable.Keyspace.Name, d.Target.VTable.Name.String(), orderBy, limit)
}

func createOperatorFromDelete(ctx *plancontext.PlanningContext, deleteStmt *sqlparser.Delete) Operator {
func createOperatorFromDelete(ctx *plancontext.PlanningContext, deleteStmt *sqlparser.Delete) (op Operator) {
delClone := sqlparser.CloneRefOfDelete(deleteStmt)

delOp := createDeleteOperator(ctx, deleteStmt)
op = delOp

if deleteStmt.Comments != nil {
delOp = &LockAndComment{
Source: delOp,
op = &LockAndComment{
Source: op,
Comments: deleteStmt.Comments,
}
}

childFks := ctx.SemTable.GetChildForeignKeysList()
// If there are no foreign key constraints, then we don't need to do anything.
if len(childFks) == 0 {
return delOp
return
}
// If the delete statement has a limit, we don't support it yet.
if delClone.Limit != nil {
panic(vterrors.VT12001("foreign keys management at vitess with limit"))
}

return createFkCascadeOpForDelete(ctx, delOp, delClone, childFks, vindexTable)
return createFkCascadeOpForDelete(ctx, op, delClone, childFks, delOp.Target.VTable)
}

func createDeleteOperator(ctx *plancontext.PlanningContext, del *sqlparser.Delete) Operator {
func createDeleteOperator(ctx *plancontext.PlanningContext, del *sqlparser.Delete) *Delete {
op := crossJoin(ctx, del.TableExprs)

if del.Where != nil {
Expand Down

0 comments on commit 6d43493

Please sign in to comment.