Skip to content

Commit

Permalink
Fix: Vitess show character set where
Browse files Browse the repository at this point in the history
right now the show character set are hardcoded to be filtered with where statement.
since we don't really want to expand the results or forward the query to an underlying mysql because vitess only supports these 2 charsets.

closes #5584

* separate show charset vs show charset in parser
* changed the executor accordingly
* use where_expression_opt in parser, changed AST and executor accordingly

Signed-off-by: roni <[email protected]>
  • Loading branch information
Ronihe authored Feb 6, 2020
1 parent f64be2d commit a2dd7a0
Show file tree
Hide file tree
Showing 7 changed files with 1,971 additions and 1,760 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ require (
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
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/olekukonko/tablewriter v0.0.0-20160115111002-cca8bbc07984
github.com/opentracing-contrib/go-grpc v0.0.0-20180928155321-4b5a12d3ff02
github.com/opentracing/opentracing-go v1.1.0
Expand Down
3 changes: 3 additions & 0 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,9 @@ func (node *Show) Format(buf *TrackedBuffer) {
if node.Type == "collation" && node.ShowCollationFilterOpt != nil {
buf.Myprintf(" where %v", *node.ShowCollationFilterOpt)
}
if node.Type == "charset" && node.ShowTablesOpt != nil {
buf.Myprintf("%v", node.ShowTablesOpt.Filter)
}
if node.HasTable() {
buf.Myprintf(" %v", node.Table)
}
Expand Down
10 changes: 8 additions & 2 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1138,13 +1138,19 @@ var (
output: "show charset",
}, {
input: "show character set like '%foo'",
output: "show charset",
output: "show charset like '%foo'",
}, {
input: "show charset",
output: "show charset",
}, {
input: "show charset like '%foo'",
output: "show charset",
output: "show charset like '%foo'",
}, {
input: "show charset where 'charset' = 'utf8'",
output: "show charset where 'charset' = 'utf8'",
}, {
input: "show charset where 'charset' = '%foo'",
output: "show charset where 'charset' = '%foo'",
}, {
input: "show collation",
output: "show collation",
Expand Down
Loading

0 comments on commit a2dd7a0

Please sign in to comment.