Skip to content

Commit

Permalink
Merge pull request #5558 from planetscale/sa-fix-show
Browse files Browse the repository at this point in the history
Add fix for SHOW FULL COLUMNS when query has a qualifier
  • Loading branch information
sougou authored Dec 13, 2019
2 parents e7f6f68 + 5521b1e commit 2352e94
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/dchest/safefile v0.0.0-20151022103144-855e8d98f185 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
github.com/evanphx/json-patch v4.5.0+incompatible
github.com/ghodss/yaml v0.0.0-20161207003320-04f313413ffd // indirect
github.com/go-ini/ini v1.12.0 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
Expand Down Expand Up @@ -45,7 +45,7 @@ require (
github.com/klauspost/crc32 v1.2.0 // indirect
github.com/klauspost/pgzip v1.2.0
github.com/kr/pretty v0.1.0 // indirect
github.com/krishicks/yaml-patch v0.0.10 // indirect
github.com/krishicks/yaml-patch v0.0.10
github.com/mattn/go-runewidth v0.0.1 // indirect
github.com/minio/minio-go v0.0.0-20190131015406-c8a261de75c1
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
Expand Down
8 changes: 8 additions & 0 deletions go/vt/vtgate/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,14 @@ func (e *Executor) handleShow(ctx context.Context, safeSession *SafeSession, sql
}
}
}
case sqlparser.KeywordString(sqlparser.COLUMNS):
if !show.OnTable.Qualifier.IsEmpty() {
destKeyspace = show.OnTable.Qualifier.String()
show.OnTable.Qualifier = sqlparser.NewTableIdent("")
} else {
break
}
sql = sqlparser.String(show)
case sqlparser.KeywordString(sqlparser.TABLES):
if show.ShowTablesOpt != nil && show.ShowTablesOpt.DbName != "" {
if destKeyspace == "" {
Expand Down
7 changes: 7 additions & 0 deletions go/vt/vtgate/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,13 @@ func TestExecutorShow(t *testing.T) {
if err != nil {
t.Error(err)
}

// Test SHOW FULL COLUMNS FROM where query has a qualifier
_, err = executor.Execute(context.Background(), "TestExecute", session, fmt.Sprintf("show full columns from %v.table1", KsTestUnsharded), nil)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}

// Just test for first & last.
qr.Rows = [][]sqltypes.Value{qr.Rows[0], qr.Rows[len(qr.Rows)-1]}
wantqr = &sqltypes.Result{
Expand Down

0 comments on commit 2352e94

Please sign in to comment.