Skip to content

Commit

Permalink
[parser] parser: support drop placement policy (pingcap#1295)
Browse files Browse the repository at this point in the history
  • Loading branch information
AilinKid authored and ti-chi-bot committed Oct 9, 2021
1 parent eb90a16 commit 55074f2
Show file tree
Hide file tree
Showing 4 changed files with 6,632 additions and 6,561 deletions.
28 changes: 28 additions & 0 deletions parser/ast/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var (
_ DDLNode = &DropIndexStmt{}
_ DDLNode = &DropTableStmt{}
_ DDLNode = &DropSequenceStmt{}
_ DDLNode = &DropPlacementPolicyStmt{}
_ DDLNode = &RenameTableStmt{}
_ DDLNode = &TruncateTableStmt{}
_ DDLNode = &RepairTableStmt{}
Expand Down Expand Up @@ -1163,6 +1164,33 @@ func (n *DropTableStmt) Accept(v Visitor) (Node, bool) {
return v.Leave(n)
}

// DropPlacementPolicyStmt is a statement to drop a Policy.
type DropPlacementPolicyStmt struct {
ddlNode

IfExists bool
PolicyName model.CIStr
}

// Restore implements Restore interface.
func (n *DropPlacementPolicyStmt) Restore(ctx *format.RestoreCtx) error {
ctx.WriteKeyWord("DROP PLACEMENT POLICY ")
if n.IfExists {
ctx.WriteKeyWord("IF EXISTS ")
}
ctx.WriteName(n.PolicyName.O)
return nil
}

func (n *DropPlacementPolicyStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
if skipChildren {
return v.Leave(newNode)
}
n = newNode.(*DropPlacementPolicyStmt)
return v.Leave(n)
}

// DropSequenceStmt is a statement to drop a Sequence.
type DropSequenceStmt struct {
ddlNode
Expand Down
Loading

0 comments on commit 55074f2

Please sign in to comment.