Skip to content

Commit

Permalink
*: Add split index region syntax support. (#297) (#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
crazycs520 authored and winkyao committed Jun 19, 2019
1 parent b634efe commit 24bef3c
Show file tree
Hide file tree
Showing 6 changed files with 5,757 additions and 5,660 deletions.
33 changes: 33 additions & 0 deletions ast/dml.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var (
_ DMLNode = &SelectStmt{}
_ DMLNode = &ShowStmt{}
_ DMLNode = &LoadDataStmt{}
_ DMLNode = &SplitIndexRegionStmt{}

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

type SplitIndexRegionStmt struct {
dmlNode

Table *TableName
IndexName string
ValueLists [][]ExprNode
}

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

n = newNode.(*SplitIndexRegionStmt)
node, ok := n.Table.Accept(v)
if !ok {
return n, false
}
n.Table = node.(*TableName)
for i, list := range n.ValueLists {
for j, val := range list {
node, ok := val.Accept(v)
if !ok {
return n, false
}
n.ValueLists[i][j] = node.(ExprNode)
}
}
return v.Leave(n)
}
1 change: 1 addition & 0 deletions misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ var tokenMap = map[string]int{
"SMALLINT": smallIntType,
"SNAPSHOT": snapshot,
"SOME": some,
"SPLIT": split,
"SQL": sql,
"SQL_CACHE": sqlCache,
"SQL_CALC_FOUND_ROWS": sqlCalcFoundRows,
Expand Down
10 changes: 10 additions & 0 deletions model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@ func (t *TableInfo) Cols() []*ColumnInfo {
return publicColumns[0 : maxOffset+1]
}

// FindIndexByName finds index by name.
func (t *TableInfo) FindIndexByName(idxName string) *IndexInfo {
for _, idx := range t.Indices {
if idx.Name.L == idxName {
return idx
}
}
return nil
}

// NewExtraHandleColInfo mocks a column info for extra handle column.
func NewExtraHandleColInfo() *ColumnInfo {
colInfo := &ColumnInfo{
Expand Down
Loading

0 comments on commit 24bef3c

Please sign in to comment.