diff --git a/go/vt/vtgate/executor_test.go b/go/vt/vtgate/executor_test.go index c14b2bc4256..9da78be84d7 100644 --- a/go/vt/vtgate/executor_test.go +++ b/go/vt/vtgate/executor_test.go @@ -437,7 +437,7 @@ func TestExecutorShowColumns(t *testing.T) { func TestExecutorShow(t *testing.T) { executor, _, _, sbclookup := createLegacyExecutorEnv() - session := NewSafeSession(&vtgatepb.Session{TargetString: "@master"}) + session := NewSafeSession(&vtgatepb.Session{TargetString: "TestExecutor"}) for _, query := range []string{"show vitess_keyspaces", "show keyspaces"} { qr, err := executor.Execute(ctx, "TestExecute", session, query, nil) @@ -459,6 +459,8 @@ func TestExecutorShow(t *testing.T) { _, err = executor.Execute(ctx, "TestExecute", session, "show collation where `Charset` = 'utf8' and `Collation` = 'utf8_bin'", nil) require.NoError(t, err) + _, err = executor.Execute(ctx, "TestExecute", session, "use @master", nil) + require.NoError(t, err) _, err = executor.Execute(ctx, "TestExecute", session, "show tables", nil) assert.EqualError(t, err, "keyspace not specified", "'show tables' should fail without a keyspace") assert.Empty(t, sbclookup.Queries, "sbclookup unexpectedly has queries already") diff --git a/go/vt/vtgate/planbuilder/show.go b/go/vt/vtgate/planbuilder/show.go index 2aacc6b47aa..31b36d7e588 100644 --- a/go/vt/vtgate/planbuilder/show.go +++ b/go/vt/vtgate/planbuilder/show.go @@ -85,7 +85,7 @@ func buildCharsetPlan(show *sqlparser.ShowBasic) (engine.Primitive, error) { } func buildSendAnywherePlan(show *sqlparser.ShowBasic, vschema ContextVSchema) (engine.Primitive, error) { - ks, err := vschema.FirstSortedKeyspace() + ks, err := vschema.AnyKeyspace() if err != nil { return nil, err } diff --git a/go/vt/vtgate/planbuilder/testdata/show_cases.txt b/go/vt/vtgate/planbuilder/testdata/show_cases.txt index 9776864ead2..8316f4c7560 100644 --- a/go/vt/vtgate/planbuilder/testdata/show_cases.txt +++ b/go/vt/vtgate/planbuilder/testdata/show_cases.txt @@ -214,7 +214,6 @@ } } - # show variables "show variables" { @@ -233,7 +232,6 @@ } } - # show databases "show databases" { diff --git a/go/vt/vtgate/planbuilder/testdata/show_cases_no_default_keyspace.txt b/go/vt/vtgate/planbuilder/testdata/show_cases_no_default_keyspace.txt index 7e5971147a5..737b6ed6bb2 100644 --- a/go/vt/vtgate/planbuilder/testdata/show_cases_no_default_keyspace.txt +++ b/go/vt/vtgate/planbuilder/testdata/show_cases_no_default_keyspace.txt @@ -33,3 +33,21 @@ "SingleShardOnly": true } } + +# show variables +"show variables" +{ + "QueryType": "SHOW", + "Original": "show variables", + "Instructions": { + "OperatorType": "Send", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "TargetDestination": "AnyShard()", + "IsDML": false, + "Query": "show variables", + "SingleShardOnly": true + } +}