Skip to content

Commit

Permalink
go/vt/vtgate: fix nilness issues (#14685)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlayher authored Dec 6, 2023
1 parent f8a90ac commit f10fdbe
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 24 deletions.
4 changes: 0 additions & 4 deletions go/vt/vtgate/engine/vindex_lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,6 @@ func (vr *VindexLookup) executeBatch(ctx context.Context, vcursor VCursor, ids [
} else {
result, err = vcursor.ExecutePrimitive(ctx, vr.Lookup, bindVars, false)
}
if err != nil {
return nil, err
}

if err != nil {
return nil, vterrors.Wrapf(err, "failed while running the lookup query")
}
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/evalengine/api_coerce.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func CoerceTypes(v1, v2 Type) (out Type, err error) {
switch {
case sqltypes.IsTextOrBinary(v1.Type()) && sqltypes.IsTextOrBinary(v2.Type()):
mergedCollation, _, _, ferr := mergeCollations(typedCoercionCollation(v1.Type(), v1.Collation()), typedCoercionCollation(v2.Type(), v2.Collation()), v1.Type(), v2.Type())
if err != nil {
if ferr != nil {
return Type{}, ferr
}
out.collation = mergedCollation.Collation
Expand Down
6 changes: 0 additions & 6 deletions go/vt/vtgate/planbuilder/operator_transformers.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,6 @@ func transformAggregator(ctx *plancontext.PlanningContext, op *operators.Aggrega
})
}

if err != nil {
return nil, err
}
oa.truncateColumnCount = op.ResultColumns
return oa, nil
}
Expand Down Expand Up @@ -431,9 +428,6 @@ func routeToEngineRoute(ctx *plancontext.PlanningContext, op *operators.Route, h

rp := newRoutingParams(ctx, op.Routing.OpCode())
op.Routing.UpdateRoutingParams(ctx, rp)
if err != nil {
return nil, err
}

e := &engine.Route{
TableName: strings.Join(tableNames, ", "),
Expand Down
13 changes: 4 additions & 9 deletions go/vt/vtgate/planbuilder/operators/query_planning.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func planQuery(ctx *plancontext.PlanningContext, root Operator) (output Operator
// If we can push it under a route - done.
// If we can't, we will instead expand the Horizon into
// smaller operators and try to push these down as far as possible
func runPhases(ctx *plancontext.PlanningContext, root Operator) (op Operator, err error) {
op = root
func runPhases(ctx *plancontext.PlanningContext, root Operator) (Operator, error) {
op := root

p := phaser{}
for phase := p.next(ctx); phase != DONE; phase = p.next(ctx) {
Expand All @@ -66,19 +66,14 @@ func runPhases(ctx *plancontext.PlanningContext, root Operator) (op Operator, er
}

op = phase.act(ctx, op)
if err != nil {
return nil, err
}

var err error
op, err = runRewriters(ctx, op)
if err != nil {
return nil, err
}

op = compact(ctx, op)
if err != nil {
return nil, err
}
}

return addGroupByOnRHSOfJoin(op), nil
Expand Down Expand Up @@ -222,7 +217,7 @@ func pushProjectionToOuter(ctx *plancontext.PlanningContext, p *Projection, sq *
return p, NoRewrite
}

if !reachedPhase(ctx, subquerySettling) || err != nil {
if !reachedPhase(ctx, subquerySettling) {
return p, NoRewrite
}

Expand Down
5 changes: 1 addition & 4 deletions go/vt/vtgate/planbuilder/operators/vindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,12 @@ func (v *Vindex) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.E
}

// check RHS
var err error
if sqlparser.IsValue(comparison.Right) || sqlparser.IsSimpleTuple(comparison.Right) {
v.Value = comparison.Right
} else {
panic(vterrors.VT09018(wrongWhereCond + " (rhs is not a value)"))
}
if err != nil {
panic(vterrors.VT09018(wrongWhereCond+": %v", err))
}

v.OpCode = engine.VindexMap
v.Table.Predicates = append(v.Table.Predicates, e)
}
Expand Down

0 comments on commit f10fdbe

Please sign in to comment.