Skip to content

Commit

Permalink
Merge pull request #4732 from dweitzman/show_create
Browse files Browse the repository at this point in the history
vtgate executor: route "show create table" to the user-provided or vs…
  • Loading branch information
sougou authored Mar 19, 2019
2 parents 8ec6f2e + 5ff205f commit 20bd2bb
Show file tree
Hide file tree
Showing 6 changed files with 962 additions and 913 deletions.
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

0 comments on commit 20bd2bb

Please sign in to comment.