Skip to content

Commit

Permalink
parser: fix remove partitioning syntax (pingcap#396)
Browse files Browse the repository at this point in the history
* add support for REMOVE PARTITIONING syntax

* remove unused value

* add type for AlterTableSpec

* indent with tab

* indent with tab
  • Loading branch information
tangenta authored and kennytm committed Jul 26, 2019
1 parent 595f527 commit b2776f8
Show file tree
Hide file tree
Showing 5 changed files with 6,919 additions and 6,852 deletions.
5 changes: 4 additions & 1 deletion ast/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,7 @@ const (
AlterTablePartition
AlterTableEnableKeys
AlterTableDisableKeys
AlterTableRemovePartitioning

// TODO: Add more actions
)
Expand Down Expand Up @@ -1998,6 +1999,8 @@ func (n *AlterTableSpec) Restore(ctx *RestoreCtx) error {
ctx.WriteKeyWord("ENABLE KEYS")
case AlterTableDisableKeys:
ctx.WriteKeyWord("DISABLE KEYS")
case AlterTableRemovePartitioning:
ctx.WriteKeyWord("REMOVE PARTITIONING")
default:
// TODO: not support
ctx.WritePlainf(" /* AlterTableType(%d) is not supported */ ", n.Tp)
Expand Down Expand Up @@ -2066,7 +2069,7 @@ func (n *AlterTableStmt) Restore(ctx *RestoreCtx) error {
return errors.Annotate(err, "An error occurred while restore AlterTableStmt.Table")
}
for i, spec := range n.Specs {
if i == 0 || spec.Tp == AlterTablePartition {
if i == 0 || spec.Tp == AlterTablePartition || spec.Tp == AlterTableRemovePartitioning {
ctx.WritePlain(" ")
} else {
ctx.WritePlain(", ")
Expand Down
2 changes: 2 additions & 0 deletions misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ var tokenMap = map[string]int{
"PAGE": pageSym,
"PARTIAL": partial,
"PARTITION": partition,
"PARTITIONING": partitioning,
"PARTITIONS": partitions,
"PASSWORD": password,
"PESSIMISTIC": pessimistic,
Expand Down Expand Up @@ -440,6 +441,7 @@ var tokenMap = map[string]int{
"REGEXP": regexpKwd,
"REGIONS": regions,
"RELOAD": reload,
"REMOVE": remove,
"RENAME": rename,
"REPEAT": repeat,
"REPEATABLE": repeatable,
Expand Down
Loading

0 comments on commit b2776f8

Please sign in to comment.