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

go/vt/vtgate: fix nilness issues #14685

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the diff is silly but I figured it made more sense to hoist the error return that wrapped the error vs keeping the bare return.

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
Loading