Skip to content

Commit

Permalink
Merge pull request #7281 from planetscale/olap-remove-resolver
Browse files Browse the repository at this point in the history
removed resolver usage from StreamExecute
  • Loading branch information
systay authored Jan 11, 2021
2 parents a489616 + 4f329f2 commit bb3c7dd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
2 changes: 1 addition & 1 deletion go/test/endtoend/vtgate/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ func TestUseStmtInOLAP(t *testing.T) {
require.NoError(t, err)
defer conn.Close()

queries := []string{"set workload='olap'", "use `ks:80-`"}
queries := []string{"set workload='olap'", "use `ks:80-`", "use `ks:-80`"}
for i, q := range queries {
t.Run(fmt.Sprintf("%d-%s", i, q), func(t *testing.T) {
exec(t, conn, q)
Expand Down
25 changes: 2 additions & 23 deletions go/vt/vtgate/vtgate.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"vitess.io/vitess/go/stats"
"vitess.io/vitess/go/tb"
"vitess.io/vitess/go/vt/discovery"
"vitess.io/vitess/go/vt/key"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/schema"
Expand Down Expand Up @@ -311,34 +310,15 @@ func (vtg *VTGate) ExecuteBatch(ctx context.Context, session *vtgatepb.Session,
// by multiple go routines.
func (vtg *VTGate) StreamExecute(ctx context.Context, session *vtgatepb.Session, sql string, bindVariables map[string]*querypb.BindVariable, callback func(*sqltypes.Result) error) error {
// In this context, we don't care if we can't fully parse destination
destKeyspace, destTabletType, dest, _ := vtg.executor.ParseDestinationTarget(session.TargetString)
destKeyspace, destTabletType, _, _ := vtg.executor.ParseDestinationTarget(session.TargetString)
statsKey := []string{"StreamExecute", destKeyspace, topoproto.TabletTypeLString(destTabletType)}

defer vtg.timings.Record(statsKey, time.Now())

var err error
if bvErr := sqltypes.ValidateBindVariables(bindVariables); bvErr != nil {
err = vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "%v", bvErr)
goto handleError
}

// TODO: This could be simplified to have a StreamExecute that takes
// a destTarget without explicit destination.
switch dest.(type) {
case key.DestinationShard:
err = vtg.resolver.StreamExecute(
ctx,
sql,
bindVariables,
destKeyspace,
destTabletType,
dest,
session.Options,
func(reply *sqltypes.Result) error {
vtg.rowsReturned.Add(statsKey, int64(len(reply.Rows)))
return callback(reply)
})
default:
} else {
err = vtg.executor.StreamExecute(
ctx,
"StreamExecute",
Expand All @@ -354,7 +334,6 @@ func (vtg *VTGate) StreamExecute(ctx context.Context, session *vtgatepb.Session,
return callback(reply)
})
}
handleError:
if err != nil {
query := map[string]interface{}{
"Sql": sql,
Expand Down

0 comments on commit bb3c7dd

Please sign in to comment.