Skip to content

Commit

Permalink
parser: add show create view grammar (pingcap#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewDi authored and leoppro committed Jan 20, 2019
1 parent d975e49 commit c31ea98
Show file tree
Hide file tree
Showing 4 changed files with 2,425 additions and 2,398 deletions.
12 changes: 9 additions & 3 deletions ast/dml.go
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,7 @@ const (
ShowStatus
ShowCollation
ShowCreateTable
ShowCreateView
ShowCreateUser
ShowGrants
ShowTriggers
Expand Down Expand Up @@ -1650,12 +1651,12 @@ func (n *ShowStmt) Restore(ctx *RestoreCtx) error {
if n.Pattern != nil && n.Pattern.Pattern != nil {
ctx.WriteKeyWord(" LIKE ")
if err := n.Pattern.Pattern.Restore(ctx); err != nil {
return errors.Annotate(err, "An error occurred while resotre ShowStmt.Pattern")
return errors.Annotate(err, "An error occurred while restore ShowStmt.Pattern")
}
} else if n.Where != nil {
ctx.WriteKeyWord(" WHERE ")
if err := n.Where.Restore(ctx); err != nil {
return errors.Annotate(err, "An error occurred while resotre ShowStmt.Where")
return errors.Annotate(err, "An error occurred while restore ShowStmt.Where")
}
}
return nil
Expand All @@ -1678,7 +1679,12 @@ func (n *ShowStmt) Restore(ctx *RestoreCtx) error {
case ShowCreateTable:
ctx.WriteKeyWord("CREATE TABLE ")
if err := n.Table.Restore(ctx); err != nil {
return errors.Annotate(err, "An error occurred while resotre ShowStmt.Table")
return errors.Annotate(err, "An error occurred while restore ShowStmt.Table")
}
case ShowCreateView:
ctx.WriteKeyWord("CREATE VIEW ")
if err := n.Table.Restore(ctx); err != nil {
return errors.Annotate(err, "An error occurred while restore ShowStmt.VIEW")
}
case ShowCreateDatabase:
ctx.WriteKeyWord("CREATE DATABASE ")
Expand Down
Loading

0 comments on commit c31ea98

Please sign in to comment.