Skip to content

Commit

Permalink
add syntax (pingcap#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
crazycs520 committed Jun 19, 2019
1 parent 24bef3c commit 4363da1
Show file tree
Hide file tree
Showing 5 changed files with 5,682 additions and 5,581 deletions.
38 changes: 30 additions & 8 deletions ast/dml.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var (
_ DMLNode = &SelectStmt{}
_ DMLNode = &ShowStmt{}
_ DMLNode = &LoadDataStmt{}
_ DMLNode = &SplitIndexRegionStmt{}
_ DMLNode = &SplitRegionStmt{}

_ Node = &Assignment{}
_ Node = &ByItem{}
Expand Down Expand Up @@ -1214,33 +1214,55 @@ func (n *FrameBound) Accept(v Visitor) (Node, bool) {
return v.Leave(n)
}

type SplitIndexRegionStmt struct {
type SplitRegionStmt struct {
dmlNode

Table *TableName
IndexName string
Table *TableName
IndexName model.CIStr

SplitOpt *SplitOption
}

type SplitOption struct {
Lower []ExprNode
Upper []ExprNode
Num int64
ValueLists [][]ExprNode
}

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

n = newNode.(*SplitIndexRegionStmt)
n = newNode.(*SplitRegionStmt)
node, ok := n.Table.Accept(v)
if !ok {
return n, false
}
n.Table = node.(*TableName)
for i, list := range n.ValueLists {
for i, val := range n.SplitOpt.Lower {
node, ok := val.Accept(v)
if !ok {
return n, false
}
n.SplitOpt.Lower[i] = node.(ExprNode)
}
for i, val := range n.SplitOpt.Upper {
node, ok := val.Accept(v)
if !ok {
return n, false
}
n.SplitOpt.Upper[i] = node.(ExprNode)
}
for i, list := range n.SplitOpt.ValueLists {
for j, val := range list {
node, ok := val.Accept(v)
if !ok {
return n, false
}
n.ValueLists[i][j] = node.(ExprNode)
n.SplitOpt.ValueLists[i][j] = node.(ExprNode)
}
}
return v.Leave(n)
Expand Down
1 change: 1 addition & 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{
"REDUNDANT": redundant,
"REFERENCES": references,
"REGEXP": regexpKwd,
"REGIONS": regions,
"RELOAD": reload,
"RENAME": rename,
"REPEAT": repeat,
Expand Down
Loading

0 comments on commit 4363da1

Please sign in to comment.