Skip to content

Commit

Permalink
Merge pull request #7531 from planetscale/fp-7530
Browse files Browse the repository at this point in the history
Show anywhere plan fix to consider default keyspace
systay authored Feb 22, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 08c841d + 0b20eb9 commit ad933b5
Showing 4 changed files with 22 additions and 4 deletions.
4 changes: 3 additions & 1 deletion go/vt/vtgate/executor_test.go
Original file line number Diff line number Diff line change
@@ -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")
2 changes: 1 addition & 1 deletion go/vt/vtgate/planbuilder/show.go
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 0 additions & 2 deletions go/vt/vtgate/planbuilder/testdata/show_cases.txt
Original file line number Diff line number Diff line change
@@ -214,7 +214,6 @@
}
}


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


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

0 comments on commit ad933b5

Please sign in to comment.