Skip to content

Commit

Permalink
*: add admin cleanup table lock syntax (pingcap#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
crazycs520 authored and lzmhhh123 committed Jan 17, 2020
1 parent 2bd497e commit 90c07d3
Show file tree
Hide file tree
Showing 4 changed files with 3,023 additions and 2,964 deletions.
38 changes: 38 additions & 0 deletions ast/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,44 @@ func (n *UnlockTablesStmt) Restore(ctx *RestoreCtx) error {
return nil
}

// CleanupTableLockStmt is a statement to cleanup table lock.
type CleanupTableLockStmt struct {
ddlNode

Tables []*TableName
}

// Accept implements Node Accept interface.
func (n *CleanupTableLockStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
if skipChildren {
return v.Leave(newNode)
}
n = newNode.(*CleanupTableLockStmt)
for i := range n.Tables {
node, ok := n.Tables[i].Accept(v)
if !ok {
return n, false
}
n.Tables[i] = node.(*TableName)
}
return v.Leave(n)
}

// Restore implements Node interface.
func (n *CleanupTableLockStmt) Restore(ctx *RestoreCtx) error {
ctx.WriteKeyWord("ADMIN CLEANUP TABLE LOCK ")
for i, v := range n.Tables {
if i != 0 {
ctx.WritePlain(", ")
}
if err := v.Restore(ctx); err != nil {
return errors.Annotatef(err, "An error occurred while restore CleanupTableLockStmt.Tables[%d]", i)
}
}
return nil
}

// TableOptionType is the type for TableOption
type TableOptionType int

Expand Down
Loading

0 comments on commit 90c07d3

Please sign in to comment.