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

Add support for SHOW (DATABASES|VITESS_SHARDS|VITESS_TABLETS) LIKE #6750

Merged
merged 15 commits into from
Sep 28, 2020
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
3 changes: 2 additions & 1 deletion go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,8 @@ func (f *ForeignKeyDefinition) Format(buf *TrackedBuffer) {
// Format formats the node.
func (node *Show) Format(buf *TrackedBuffer) {
nodeType := strings.ToLower(node.Type)
if (nodeType == "tables" || nodeType == "columns" || nodeType == "fields" || nodeType == "index" || nodeType == "keys" || nodeType == "indexes") && node.ShowTablesOpt != nil {
if (nodeType == "tables" || nodeType == "columns" || nodeType == "fields" || nodeType == "index" || nodeType == "keys" || nodeType == "indexes" ||
nodeType == "databases" || nodeType == "keyspaces" || nodeType == "vitess_keyspaces" || nodeType == "vitess_shards" || nodeType == "vitess_tablets") && node.ShowTablesOpt != nil {
opt := node.ShowTablesOpt
if node.Extended != "" {
buf.astPrintf(node, "show %s%s", node.Extended, nodeType)
Expand Down
8 changes: 8 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1378,10 +1378,18 @@ var (
output: "show session variables",
}, {
input: "show vitess_keyspaces",
}, {
input: "show vitess_keyspaces like '%'",
}, {
input: "show vitess_shards",
}, {
input: "show vitess_shards like '%'",
}, {
input: "show vitess_tablets",
}, {
input: "show vitess_tablets like '%'",
}, {
input: "show vitess_tablets where hostname = 'some-tablet'",
}, {
input: "show vschema tables",
}, {
Expand Down
Loading