Skip to content

Commit

Permalink
parser: support ALTER TABLE ALTER CHECK, ALTER TABLE DROP CHECK s…
Browse files Browse the repository at this point in the history
…yntax (pingcap#505)
  • Loading branch information
spongedu authored and Tanner committed Aug 20, 2019
1 parent 17f828c commit 21816a4
Show file tree
Hide file tree
Showing 3 changed files with 4,234 additions and 4,161 deletions.
12 changes: 12 additions & 0 deletions ast/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,8 @@ const (
AlterTableRepairPartition
AlterTableImportPartitionTablespace
AlterTableDiscardPartitionTablespace
AlterTableAlterCheck
AlterTableDropCheck

// TODO: Add more actions
)
Expand Down Expand Up @@ -2293,6 +2295,16 @@ func (n *AlterTableSpec) Restore(ctx *RestoreCtx) error {
if !n.WithValidation {
ctx.WriteKeyWord(" WITHOUT VALIDATION")
}
case AlterTableAlterCheck:
ctx.WriteKeyWord("ALTER CHECK ")
ctx.WriteName(n.Constraint.Name)
if n.Constraint.Enforced == false {
ctx.WriteKeyWord(" NOT")
}
ctx.WriteKeyWord(" ENFORCED")
case AlterTableDropCheck:
ctx.WriteKeyWord("DROP CHECK ")
ctx.WriteName(n.Constraint.Name)
default:
// TODO: not support
ctx.WritePlainf(" /* AlterTableType(%d) is not supported */ ", n.Tp)
Expand Down
Loading

0 comments on commit 21816a4

Please sign in to comment.