Skip to content
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: 3 additions & 1 deletion go/vt/vtgate/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,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 databases", "show vitess_keyspaces", "show keyspaces", "show DATABASES", "show schemas", "show SCHEMAS"} {
qr, err := executor.Execute(ctx, "TestExecute", session, query, nil)
Expand All @@ -449,6 +449,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, errNoKeyspace.Error(), "'show tables' should fail without a keyspace")
assert.Empty(t, sbclookup.Queries, "sbclookup unexpectedly has queries already")
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/planbuilder/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func buildShowBasicPlan(show *sqlparser.ShowBasic, vschema ContextVSchema) (engi
}

func showSendAnywhere(show *sqlparser.ShowBasic, vschema ContextVSchema) (engine.Primitive, error) {
ks, err := vschema.FirstSortedKeyspace()
ks, err := vschema.AnyKeyspace()
if err != nil {
return nil, err
}
Expand Down
2 changes: 0 additions & 2 deletions go/vt/vtgate/planbuilder/testdata/show_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@
}
}


# show variables
"show variables"
{
Expand All @@ -233,7 +232,6 @@
}
}


# show databases
"show databases"
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}