From 5521b1eec9d8b6496a964862d6a47debd1a175b2 Mon Sep 17 00:00:00 2001 From: Saif Alharthi Date: Thu, 12 Dec 2019 12:26:05 -0800 Subject: [PATCH] Add fix for SHOW FULL COLUMNS Signed-off-by: Saif Alharthi Add test for query with qualifer Signed-off-by: Saif Alharthi --- go.mod | 4 ++-- go/vt/vtgate/executor.go | 8 ++++++++ go/vt/vtgate/executor_test.go | 7 +++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 44d8c461dd1..af52af73134 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 diff --git a/go/vt/vtgate/executor.go b/go/vt/vtgate/executor.go index b3c9e2c8980..5499160dab1 100644 --- a/go/vt/vtgate/executor.go +++ b/go/vt/vtgate/executor.go @@ -840,6 +840,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 == "" { diff --git a/go/vt/vtgate/executor_test.go b/go/vt/vtgate/executor_test.go index 8767cd0928c..8a42e884bc6 100644 --- a/go/vt/vtgate/executor_test.go +++ b/go/vt/vtgate/executor_test.go @@ -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{