Skip to content

Commit f10fdbe

Browse files
authored
go/vt/vtgate: fix nilness issues (#14685)
1 parent f8a90ac commit f10fdbe

File tree

5 files changed

+6
-24
lines changed

5 files changed

+6
-24
lines changed

go/vt/vtgate/engine/vindex_lookup.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,6 @@ func (vr *VindexLookup) executeBatch(ctx context.Context, vcursor VCursor, ids [
227227
} else {
228228
result, err = vcursor.ExecutePrimitive(ctx, vr.Lookup, bindVars, false)
229229
}
230-
if err != nil {
231-
return nil, err
232-
}
233-
234230
if err != nil {
235231
return nil, vterrors.Wrapf(err, "failed while running the lookup query")
236232
}

go/vt/vtgate/evalengine/api_coerce.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func CoerceTypes(v1, v2 Type) (out Type, err error) {
4848
switch {
4949
case sqltypes.IsTextOrBinary(v1.Type()) && sqltypes.IsTextOrBinary(v2.Type()):
5050
mergedCollation, _, _, ferr := mergeCollations(typedCoercionCollation(v1.Type(), v1.Collation()), typedCoercionCollation(v2.Type(), v2.Collation()), v1.Type(), v2.Type())
51-
if err != nil {
51+
if ferr != nil {
5252
return Type{}, ferr
5353
}
5454
out.collation = mergedCollation.Collation

go/vt/vtgate/planbuilder/operator_transformers.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,6 @@ func transformAggregator(ctx *plancontext.PlanningContext, op *operators.Aggrega
251251
})
252252
}
253253

254-
if err != nil {
255-
return nil, err
256-
}
257254
oa.truncateColumnCount = op.ResultColumns
258255
return oa, nil
259256
}
@@ -431,9 +428,6 @@ func routeToEngineRoute(ctx *plancontext.PlanningContext, op *operators.Route, h
431428

432429
rp := newRoutingParams(ctx, op.Routing.OpCode())
433430
op.Routing.UpdateRoutingParams(ctx, rp)
434-
if err != nil {
435-
return nil, err
436-
}
437431

438432
e := &engine.Route{
439433
TableName: strings.Join(tableNames, ", "),

go/vt/vtgate/planbuilder/operators/query_planning.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ func planQuery(ctx *plancontext.PlanningContext, root Operator) (output Operator
5555
// If we can push it under a route - done.
5656
// If we can't, we will instead expand the Horizon into
5757
// smaller operators and try to push these down as far as possible
58-
func runPhases(ctx *plancontext.PlanningContext, root Operator) (op Operator, err error) {
59-
op = root
58+
func runPhases(ctx *plancontext.PlanningContext, root Operator) (Operator, error) {
59+
op := root
6060

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

6868
op = phase.act(ctx, op)
69-
if err != nil {
70-
return nil, err
71-
}
7269

70+
var err error
7371
op, err = runRewriters(ctx, op)
7472
if err != nil {
7573
return nil, err
7674
}
7775

7876
op = compact(ctx, op)
79-
if err != nil {
80-
return nil, err
81-
}
8277
}
8378

8479
return addGroupByOnRHSOfJoin(op), nil
@@ -222,7 +217,7 @@ func pushProjectionToOuter(ctx *plancontext.PlanningContext, p *Projection, sq *
222217
return p, NoRewrite
223218
}
224219

225-
if !reachedPhase(ctx, subquerySettling) || err != nil {
220+
if !reachedPhase(ctx, subquerySettling) {
226221
return p, NoRewrite
227222
}
228223

go/vt/vtgate/planbuilder/operators/vindex.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,12 @@ func (v *Vindex) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.E
148148
}
149149

150150
// check RHS
151-
var err error
152151
if sqlparser.IsValue(comparison.Right) || sqlparser.IsSimpleTuple(comparison.Right) {
153152
v.Value = comparison.Right
154153
} else {
155154
panic(vterrors.VT09018(wrongWhereCond + " (rhs is not a value)"))
156155
}
157-
if err != nil {
158-
panic(vterrors.VT09018(wrongWhereCond+": %v", err))
159-
}
156+
160157
v.OpCode = engine.VindexMap
161158
v.Table.Predicates = append(v.Table.Predicates, e)
162159
}

0 commit comments

Comments
 (0)