diff --git a/go/test/endtoend/vtgate/misc_test.go b/go/test/endtoend/vtgate/misc_test.go index e9ee18cead8..a6265191c4c 100644 --- a/go/test/endtoend/vtgate/misc_test.go +++ b/go/test/endtoend/vtgate/misc_test.go @@ -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) diff --git a/go/vt/vtgate/vtgate.go b/go/vt/vtgate/vtgate.go index 164179319f6..e67f7139523 100644 --- a/go/vt/vtgate/vtgate.go +++ b/go/vt/vtgate/vtgate.go @@ -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" @@ -311,7 +310,7 @@ 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()) @@ -319,26 +318,7 @@ func (vtg *VTGate) StreamExecute(ctx context.Context, session *vtgatepb.Session, 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", @@ -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,