Skip to content

Commit

Permalink
Fix DISCARD/IMPORT TABLESPACE syntax (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
fzhedu authored and leoppro committed Aug 26, 2019
1 parent c23214d commit 091e94e
Show file tree
Hide file tree
Showing 4 changed files with 3,001 additions and 2,950 deletions.
9 changes: 7 additions & 2 deletions ast/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1865,7 +1865,8 @@ const (
AlterTableDiscardPartitionTablespace
AlterTableAlterCheck
AlterTableDropCheck

AlterTableImportTablespace
AlterTableDiscardTablespace
// TODO: Add more actions
)

Expand Down Expand Up @@ -2322,6 +2323,10 @@ func (n *AlterTableSpec) Restore(ctx *RestoreCtx) error {
case AlterTableDropCheck:
ctx.WriteKeyWord("DROP CHECK ")
ctx.WriteName(n.Constraint.Name)
case AlterTableImportTablespace:
ctx.WriteKeyWord("IMPORT TABLESPACE")
case AlterTableDiscardTablespace:
ctx.WriteKeyWord("DISCARD TABLESPACE")
default:
// TODO: not support
ctx.WritePlainf(" /* AlterTableType(%d) is not supported */ ", n.Tp)
Expand Down Expand Up @@ -2390,7 +2395,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 || spec.Tp == AlterTableRemovePartitioning {
if i == 0 || spec.Tp == AlterTablePartition || spec.Tp == AlterTableRemovePartitioning || spec.Tp == AlterTableImportTablespace || spec.Tp == AlterTableDiscardTablespace {
ctx.WritePlain(" ")
} else {
ctx.WritePlain(", ")
Expand Down
Loading

0 comments on commit 091e94e

Please sign in to comment.