Skip to content

Commit

Permalink
feat: refactor code to handle the case where newop is the same as op
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <manan@planetscale.com>
  • Loading branch information
GuptaManan100 committed Aug 7, 2024
1 parent 741a665 commit e2f137c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions go/vt/vtgate/planbuilder/operators/offset_planning.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,21 @@ func planOffsets(ctx *plancontext.PlanningContext, root Operator) Operator {
panic(vterrors.VT13001(fmt.Sprintf("should not see %T here", in)))
case offsettable:
newOp := op.planOffsets(ctx)
var anythingChanged *ApplyResult

if newOp == nil {
newOp = op
} else {
// We got a new operator from plan offsets. We should return that something has changed.
anythingChanged = Rewrote("planned offsets")
}

if DebugOperatorTree {
fmt.Println("Planned offsets for:")
fmt.Println(ToTree(newOp))
}
return newOp, anythingChanged

if newOp == op {
return newOp, nil
} else {
// We got a new operator from plan offsets. We should return that something has changed.
return newOp, Rewrote("planning offsets introduced a new operator")
}
}
return in, NoRewrite
}
Expand Down

0 comments on commit e2f137c

Please sign in to comment.