Skip to content
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
10 changes: 10 additions & 0 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,7 @@ func (f *ForeignKeyDefinition) walkSubtree(visit Visit) error {
type Show struct {
Type string
OnTable TableName
Table TableName
ShowTablesOpt *ShowTablesOpt
Scope string
ShowCollationFilterOpt *Expr
Expand Down Expand Up @@ -1547,13 +1548,22 @@ func (node *Show) Format(buf *TrackedBuffer) {
if node.Type == "collation" && node.ShowCollationFilterOpt != nil {
buf.Myprintf(" where %v", *node.ShowCollationFilterOpt)
}
if node.HasTable() {
buf.Myprintf(" %v", node.Table)
}
}

// HasOnTable returns true if the show statement has an "on" clause
func (node *Show) HasOnTable() bool {
return node.OnTable.Name.v != ""
}

// HasTable returns true if the show statement has a parsed table name.
// Not all show statements parse table names.
func (node *Show) HasTable() bool {
return node.Table.Name.v != ""
}

func (node *Show) walkSubtree(visit Visit) error {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ var (
output: "show create procedure",
}, {
input: "show create table t",
output: "show create table",
output: "show create table t",
}, {
input: "show create trigger t",
output: "show create trigger",
Expand Down
Loading