Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show tables to use any keyspace on system schema #16521

Merged
merged 1 commit into from
Aug 1, 2024
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
9 changes: 6 additions & 3 deletions go/test/endtoend/vtgate/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,13 @@ func TestShowTables(t *testing.T) {
conn, closer := start(t)
defer closer()

query := "show tables;"
qr := utils.Exec(t, conn, query)

qr := utils.Exec(t, conn, "show tables")
assert.Equal(t, "Tables_in_ks", qr.Fields[0].Name)

// no error on executing `show tables` on system schema
utils.Exec(t, conn, `use mysql`)
utils.Exec(t, conn, "show tables")
utils.Exec(t, conn, "show tables from information_schema")
}

func TestCastConvert(t *testing.T) {
Expand Down
9 changes: 9 additions & 0 deletions go/vt/vtgate/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,15 @@ func TestExecutorShowTargeted(t *testing.T) {
}
}

func TestExecutorShowFromSystemSchema(t *testing.T) {
executor, _, _, _, ctx := createExecutorEnv(t)

session := NewSafeSession(&vtgatepb.Session{TargetString: "mysql"})

_, err := executor.Execute(ctx, nil, "TestExecutorShowFromSystemSchema", session, "show tables", nil)
require.NoError(t, err)
}

func TestExecutorUse(t *testing.T) {
executor, _, _, _, ctx := createExecutorEnv(t)

Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/vcursor_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ func commentedShardQueries(shardQueries []*querypb.BoundQuery, marginComments sq

// TargetDestination implements the ContextVSchema interface
func (vc *vcursorImpl) TargetDestination(qualifier string) (key.Destination, *vindexes.Keyspace, topodatapb.TabletType, error) {
keyspaceName := vc.keyspace
keyspaceName := vc.getActualKeyspace()
if vc.destination == nil && qualifier != "" {
keyspaceName = qualifier
}
Expand Down
Loading