提交 6eddefa4 编写于 作者: martianzhang's avatar martianzhang

daily update vendor

上级 5eb250bb
......@@ -1093,7 +1093,7 @@ func init() {
Item: "TBL.005",
Severity: "L4",
Summary: "请使用推荐的字符集",
Content: `表字符集只允许设置为` + strings.Join(common.Config.AllowCharsets, ","),
Content: `表字符集只允许设置为'` + strings.Join(common.Config.AllowCharsets, ",") + "'",
Case: "CREATE TABLE tbl (a int) DEFAULT CHARSET = latin1;",
Func: (*Query4Audit).RuleTableCharsetCheck,
},
......@@ -1117,7 +1117,7 @@ func init() {
Item: "TBL.008",
Severity: "L4",
Summary: "请使用推荐的COLLATE",
Content: `COLLATE 只允许设置为` + strings.Join(common.Config.AllowCollates, ","),
Content: `COLLATE 只允许设置为'` + strings.Join(common.Config.AllowCollates, ",") + "'",
Case: "CREATE TABLE tbl (a int) DEFAULT COLLATE = latin1_bin;",
Func: (*Query4Audit).RuleTableCharsetCheck,
},
......
......@@ -1176,7 +1176,7 @@ CREATE TABLE tbl (a int) AUTO_INCREMENT = 10;
* **Item**:TBL.005
* **Severity**:L4
* **Content**:表字符集只允许设置为utf8,utf8mb4
* **Content**:表字符集只允许设置为'utf8,utf8mb4'
* **Case**:
```sql
......@@ -1206,7 +1206,7 @@ CREATE TEMPORARY TABLE `work` (`time` time DEFAULT NULL) ENGINE=InnoDB;
* **Item**:TBL.008
* **Severity**:L4
* **Content**:COLLATE 只允许设置为
* **Content**:COLLATE 只允许设置为''
* **Case**:
```sql
......
......@@ -111,7 +111,7 @@ advisor.Rule{Item:"TBL.001", Severity:"L4", Summary:"不建议使用分区表",
advisor.Rule{Item:"TBL.002", Severity:"L4", Summary:"请为表选择合适的存储引擎", Content:"建表或修改表的存储引擎时建议使用推荐的存储引擎,如:innodb", Case:"create table test(`id` int(11) NOT NULL AUTO_INCREMENT)", Position:0, Func:func(*advisor.Query4Audit) advisor.Rule {...}}
advisor.Rule{Item:"TBL.003", Severity:"L8", Summary:"以DUAL命名的表在数据库中有特殊含义", Content:"DUAL表为虚拟表,不需要创建即可使用,也不建议服务以DUAL命名表。", Case:"create table dual(id int, primary key (id));", Position:0, Func:func(*advisor.Query4Audit) advisor.Rule {...}}
advisor.Rule{Item:"TBL.004", Severity:"L2", Summary:"表的初始AUTO_INCREMENT值不为0", Content:"AUTO_INCREMENT不为0会导致数据空洞。", Case:"CREATE TABLE tbl (a int) AUTO_INCREMENT = 10;", Position:0, Func:func(*advisor.Query4Audit) advisor.Rule {...}}
advisor.Rule{Item:"TBL.005", Severity:"L4", Summary:"请使用推荐的字符集", Content:"表字符集只允许设置为utf8,utf8mb4", Case:"CREATE TABLE tbl (a int) DEFAULT CHARSET = latin1;", Position:0, Func:func(*advisor.Query4Audit) advisor.Rule {...}}
advisor.Rule{Item:"TBL.005", Severity:"L4", Summary:"请使用推荐的字符集", Content:"表字符集只允许设置为'utf8,utf8mb4'", Case:"CREATE TABLE tbl (a int) DEFAULT CHARSET = latin1;", Position:0, Func:func(*advisor.Query4Audit) advisor.Rule {...}}
advisor.Rule{Item:"TBL.006", Severity:"L1", Summary:"不建议使用视图", Content:"不建议使用视图", Case:"create view v_today (today) AS SELECT CURRENT_DATE;", Position:0, Func:func(*advisor.Query4Audit) advisor.Rule {...}}
advisor.Rule{Item:"TBL.007", Severity:"L1", Summary:"不建议使用临时表", Content:"不建议使用临时表", Case:"CREATE TEMPORARY TABLE `work` (`time` time DEFAULT NULL) ENGINE=InnoDB;", Position:0, Func:func(*advisor.Query4Audit) advisor.Rule {...}}
advisor.Rule{Item:"TBL.008", Severity:"L4", Summary:"请使用推荐的COLLATE", Content:"COLLATE 只允许设置为", Case:"CREATE TABLE tbl (a int) DEFAULT COLLATE = latin1_bin;", Position:0, Func:func(*advisor.Query4Audit) advisor.Rule {...}}
advisor.Rule{Item:"TBL.008", Severity:"L4", Summary:"请使用推荐的COLLATE", Content:"COLLATE 只允许设置为''", Case:"CREATE TABLE tbl (a int) DEFAULT COLLATE = latin1_bin;", Position:0, Func:func(*advisor.Query4Audit) advisor.Rule {...}}
......@@ -609,11 +609,10 @@ func readCmdFlags() error {
Config.IgnoreRules = strings.Split(*ignoreRules, ",")
Config.RewriteRules = strings.Split(*rewriteRules, ",")
*blackList = strings.TrimSpace(*blackList)
if strings.HasPrefix(*blackList, "/") || *blackList == "" {
if filepath.IsAbs(*blackList) || *blackList == "" {
Config.BlackList = *blackList
} else {
pwd, _ := os.Getwd()
Config.BlackList = pwd + "/" + *blackList
Config.BlackList = filepath.Join(BaseDir, *blackList)
}
Config.MaxJoinTableCount = *maxJoinTableCount
Config.MaxGroupByColsCount = *maxGroupByColsCount
......@@ -688,8 +687,8 @@ func ParseConfig(configFile string) error {
if configFile == "" {
configs = []string{
"/etc/soar.yaml",
BaseDir + "/etc/soar.yaml",
BaseDir + "/soar.yaml",
filepath.Join(BaseDir, "etc", "soar.yaml"),
filepath.Join(BaseDir, "soar.yaml"),
}
} else {
configs = []string{
......
......@@ -1176,7 +1176,7 @@ CREATE TABLE tbl (a int) AUTO_INCREMENT = 10;
* **Item**:TBL.005
* **Severity**:L4
* **Content**:表字符集只允许设置为utf8,utf8mb4
* **Content**:表字符集只允许设置为'utf8,utf8mb4'
* **Case**:
```sql
......@@ -1202,3 +1202,13 @@ create view v_today (today) AS SELECT CURRENT_DATE;
```sql
CREATE TEMPORARY TABLE `work` (`time` time DEFAULT NULL) ENGINE=InnoDB;
```
## 请使用推荐的COLLATE
* **Item**:TBL.008
* **Severity**:L4
* **Content**:COLLATE 只允许设置为''
* **Case**:
```sql
CREATE TABLE tbl (a int) DEFAULT COLLATE = latin1_bin;
```
......@@ -17,6 +17,7 @@ package ast
import (
"io"
"strings"
"github.com/pingcap/parser/model"
"github.com/pingcap/parser/types"
......@@ -25,6 +26,8 @@ import (
// Node is the basic element of the AST.
// Interfaces embed Node should have 'Node' name suffix.
type Node interface {
// Restore returns the sql text from ast tree
Restore(sb *strings.Builder) error
// Accept accepts Visitor to visit itself.
// The returned node should replace original node.
// ok returns false to stop visiting.
......
......@@ -14,6 +14,9 @@
package ast
import (
"strings"
"github.com/pingcap/errors"
"github.com/pingcap/parser/auth"
"github.com/pingcap/parser/model"
"github.com/pingcap/parser/types"
......@@ -62,6 +65,21 @@ type DatabaseOption struct {
Value string
}
// Restore implements Recoverable interface.
func (n *DatabaseOption) Restore(sb *strings.Builder) error {
switch n.Tp {
case DatabaseOptionCharset:
sb.WriteString("CHARACTER SET = ")
sb.WriteString(n.Value)
case DatabaseOptionCollate:
sb.WriteString("COLLATE = ")
sb.WriteString(n.Value)
default:
return errors.Errorf("invalid DatabaseOptionType: %d", n.Tp)
}
return nil
}
// CreateDatabaseStmt is a statement to create a database.
// See https://dev.mysql.com/doc/refman/5.7/en/create-database.html
type CreateDatabaseStmt struct {
......@@ -72,6 +90,23 @@ type CreateDatabaseStmt struct {
Options []*DatabaseOption
}
// Restore implements Recoverable interface.
func (n *CreateDatabaseStmt) Restore(sb *strings.Builder) error {
sb.WriteString("CREATE DATABASE ")
if n.IfNotExists {
sb.WriteString("IF NOT EXISTS ")
}
WriteName(sb, n.Name)
for _, option := range n.Options {
sb.WriteString(" ")
err := option.Restore(sb)
if err != nil {
return errors.Trace(err)
}
}
return nil
}
// Accept implements Node Accept interface.
func (n *CreateDatabaseStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -91,6 +126,16 @@ type DropDatabaseStmt struct {
Name string
}
// Restore implements Recoverable interface.
func (n *DropDatabaseStmt) Restore(sb *strings.Builder) error {
sb.WriteString("DROP DATABASE ")
if n.IfExists {
sb.WriteString("IF EXISTS ")
}
WriteName(sb, n.Name)
return nil
}
// Accept implements Node Accept interface.
func (n *DropDatabaseStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -109,6 +154,11 @@ type IndexColName struct {
Length int
}
// Restore implements Recoverable interface.
func (n *IndexColName) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *IndexColName) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -135,6 +185,11 @@ type ReferenceDef struct {
OnUpdate *OnUpdateOpt
}
// Restore implements Recoverable interface.
func (n *ReferenceDef) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *ReferenceDef) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -200,6 +255,11 @@ type OnDeleteOpt struct {
ReferOpt ReferOptionType
}
// Restore implements Recoverable interface.
func (n *OnDeleteOpt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *OnDeleteOpt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -216,6 +276,11 @@ type OnUpdateOpt struct {
ReferOpt ReferOptionType
}
// Restore implements Recoverable interface.
func (n *OnUpdateOpt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *OnUpdateOpt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -260,6 +325,11 @@ type ColumnOption struct {
Refer *ReferenceDef
}
// Restore implements Recoverable interface.
func (n *ColumnOption) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *ColumnOption) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -291,6 +361,11 @@ type IndexOption struct {
Comment string
}
// Restore implements Recoverable interface.
func (n *IndexOption) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *IndexOption) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -331,6 +406,11 @@ type Constraint struct {
Option *IndexOption // Index Options
}
// Restore implements Recoverable interface.
func (n *Constraint) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *Constraint) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -371,6 +451,11 @@ type ColumnDef struct {
Options []*ColumnOption
}
// Restore implements Recoverable interface.
func (n *ColumnDef) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *ColumnDef) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -409,6 +494,11 @@ type CreateTableStmt struct {
Select ResultSetNode
}
// Restore implements Recoverable interface.
func (n *CreateTableStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *CreateTableStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -462,6 +552,11 @@ type DropTableStmt struct {
Tables []*TableName
}
// Restore implements Recoverable interface.
func (n *DropTableStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *DropTableStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -492,6 +587,11 @@ type RenameTableStmt struct {
TableToTables []*TableToTable
}
// Restore implements Recoverable interface.
func (n *RenameTableStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *RenameTableStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -528,6 +628,11 @@ type TableToTable struct {
NewTable *TableName
}
// Restore implements Recoverable interface.
func (n *TableToTable) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *TableToTable) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -563,6 +668,11 @@ type CreateViewStmt struct {
CheckOption model.ViewCheckOption
}
// Restore implements Recoverable interface.
func (n *CreateViewStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *CreateViewStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -595,6 +705,11 @@ type CreateIndexStmt struct {
IndexOption *IndexOption
}
// Restore implements Recoverable interface.
func (n *CreateIndexStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *CreateIndexStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -634,6 +749,11 @@ type DropIndexStmt struct {
Table *TableName
}
// Restore implements Recoverable interface.
func (n *DropIndexStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *DropIndexStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -722,6 +842,11 @@ type ColumnPosition struct {
RelativeColumn *ColumnName
}
// Restore implements Recoverable interface.
func (n *ColumnPosition) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *ColumnPosition) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -763,7 +888,7 @@ const (
AlterTableCoalescePartitions
AlterTableDropPartition
// TODO: Add more actions
// TODO: Add more actions
)
// LockType is the type for AlterTableSpec.
......@@ -798,6 +923,11 @@ type AlterTableSpec struct {
Num uint64
}
// Restore implements Recoverable interface.
func (n *AlterTableSpec) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *AlterTableSpec) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -852,6 +982,11 @@ type AlterTableStmt struct {
Specs []*AlterTableSpec
}
// Restore implements Recoverable interface.
func (n *AlterTableStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *AlterTableStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -882,6 +1017,11 @@ type TruncateTableStmt struct {
Table *TableName
}
// Restore implements Recoverable interface.
func (n *TruncateTableStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *TruncateTableStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......
......@@ -14,6 +14,9 @@
package ast
import (
"strings"
"github.com/pingcap/errors"
"github.com/pingcap/parser/auth"
"github.com/pingcap/parser/model"
"github.com/pingcap/parser/mysql"
......@@ -82,6 +85,11 @@ type Join struct {
StraightJoin bool
}
// Restore implements Recoverable interface.
func (n *Join) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *Join) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -125,6 +133,11 @@ type TableName struct {
IndexHints []*IndexHint
}
// Restore implements Recoverable interface.
func (n *TableName) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// IndexHintType is the type for index hint use, ignore or force.
type IndexHintType int
......@@ -169,6 +182,11 @@ type DeleteTableList struct {
Tables []*TableName
}
// Restore implements Recoverable interface.
func (n *DeleteTableList) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *DeleteTableList) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -195,6 +213,11 @@ type OnCondition struct {
Expr ExprNode
}
// Restore implements Recoverable interface.
func (n *OnCondition) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *OnCondition) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -222,6 +245,11 @@ type TableSource struct {
AsName model.CIStr
}
// Restore implements Recoverable interface.
func (n *TableSource) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *TableSource) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -268,6 +296,11 @@ type WildCardField struct {
Schema model.CIStr
}
// Restore implements Recoverable interface.
func (n *WildCardField) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *WildCardField) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -298,6 +331,11 @@ type SelectField struct {
Auxiliary bool
}
// Restore implements Recoverable interface.
func (n *SelectField) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *SelectField) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -322,6 +360,11 @@ type FieldList struct {
Fields []*SelectField
}
// Restore implements Recoverable interface.
func (n *FieldList) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *FieldList) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -346,6 +389,11 @@ type TableRefsClause struct {
TableRefs *Join
}
// Restore implements Recoverable interface.
func (n *TableRefsClause) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *TableRefsClause) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -369,6 +417,11 @@ type ByItem struct {
Desc bool
}
// Restore implements Recoverable interface.
func (n *ByItem) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *ByItem) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -390,6 +443,11 @@ type GroupByClause struct {
Items []*ByItem
}
// Restore implements Recoverable interface.
func (n *GroupByClause) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *GroupByClause) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -413,6 +471,11 @@ type HavingClause struct {
Expr ExprNode
}
// Restore implements Recoverable interface.
func (n *HavingClause) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *HavingClause) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -435,6 +498,11 @@ type OrderByClause struct {
ForUnion bool
}
// Restore implements Recoverable interface.
func (n *OrderByClause) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *OrderByClause) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -488,6 +556,11 @@ type SelectStmt struct {
IsInBraces bool
}
// Restore implements Recoverable interface.
func (n *SelectStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *SelectStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -582,6 +655,11 @@ type UnionSelectList struct {
Selects []*SelectStmt
}
// Restore implements Recoverable interface.
func (n *UnionSelectList) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *UnionSelectList) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -610,6 +688,11 @@ type UnionStmt struct {
Limit *Limit
}
// Restore implements Recoverable interface.
func (n *UnionStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *UnionStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -650,6 +733,11 @@ type Assignment struct {
Expr ExprNode
}
// Restore implements Recoverable interface.
func (n *Assignment) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *Assignment) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -684,6 +772,11 @@ type LoadDataStmt struct {
IgnoreLines uint64
}
// Restore implements Recoverable interface.
func (n *LoadDataStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *LoadDataStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -737,6 +830,11 @@ type InsertStmt struct {
Select ResultSetNode
}
// Restore implements Recoverable interface.
func (n *InsertStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *InsertStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -813,6 +911,11 @@ type DeleteStmt struct {
TableHints []*TableOptimizerHint
}
// Restore implements Recoverable interface.
func (n *DeleteStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *DeleteStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -873,6 +976,11 @@ type UpdateStmt struct {
TableHints []*TableOptimizerHint
}
// Restore implements Recoverable interface.
func (n *UpdateStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *UpdateStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -924,6 +1032,11 @@ type Limit struct {
Offset ExprNode
}
// Restore implements Recoverable interface.
func (n *Limit) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *Limit) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -1004,6 +1117,11 @@ type ShowStmt struct {
Where ExprNode
}
// Restore implements Recoverable interface.
func (n *ShowStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *ShowStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -1064,6 +1182,11 @@ type WindowSpec struct {
Frame *FrameClause
}
// Restore implements Recoverable interface.
func (n *WindowSpec) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *WindowSpec) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -1102,6 +1225,11 @@ type PartitionByClause struct {
Items []*ByItem
}
// Restore implements Recoverable interface.
func (n *PartitionByClause) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *PartitionByClause) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -1138,6 +1266,11 @@ type FrameClause struct {
Extent FrameExtent
}
// Restore implements Recoverable interface.
func (n *FrameClause) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *FrameClause) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -1186,6 +1319,11 @@ type FrameBound struct {
Unit ExprNode
}
// Restore implements Recoverable interface.
func (n *FrameBound) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *FrameBound) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......
......@@ -19,6 +19,7 @@ import (
"regexp"
"strings"
"github.com/pingcap/errors"
"github.com/pingcap/parser/model"
"github.com/pingcap/parser/opcode"
)
......@@ -78,6 +79,11 @@ type BetweenExpr struct {
Not bool
}
// Restore implements Recoverable interface.
func (n *BetweenExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *BetweenExpr) Format(w io.Writer) {
n.Expr.Format(w)
......@@ -131,6 +137,11 @@ type BinaryOperationExpr struct {
R ExprNode
}
// Restore implements Recoverable interface.
func (n *BinaryOperationExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *BinaryOperationExpr) Format(w io.Writer) {
n.L.Format(w)
......@@ -172,6 +183,11 @@ type WhenClause struct {
Result ExprNode
}
// Restore implements Recoverable interface.
func (n *WhenClause) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *WhenClause) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -205,6 +221,11 @@ type CaseExpr struct {
ElseClause ExprNode
}
// Restore implements Recoverable interface.
func (n *CaseExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *CaseExpr) Format(w io.Writer) {
fmt.Fprint(w, "CASE ")
......@@ -269,6 +290,11 @@ type SubqueryExpr struct {
Exists bool
}
// Restore implements Recoverable interface.
func (n *SubqueryExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *SubqueryExpr) Format(w io.Writer) {
panic("Not implemented")
......@@ -305,6 +331,11 @@ type CompareSubqueryExpr struct {
All bool
}
// Restore implements Recoverable interface.
func (n *CompareSubqueryExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *CompareSubqueryExpr) Format(w io.Writer) {
panic("Not implemented")
......@@ -338,6 +369,20 @@ type ColumnName struct {
Name model.CIStr
}
// Restore implements Recoverable interface.
func (n *ColumnName) Restore(sb *strings.Builder) error {
if n.Schema.O != "" {
WriteName(sb, n.Schema.O)
sb.WriteString(".")
}
if n.Table.O != "" {
WriteName(sb, n.Table.O)
sb.WriteString(".")
}
WriteName(sb, n.Name.O)
return nil
}
// Accept implements Node Accept interface.
func (n *ColumnName) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -386,6 +431,15 @@ type ColumnNameExpr struct {
Refer *ResultField
}
// Restore implements Recoverable interface.
func (n *ColumnNameExpr) Restore(sb *strings.Builder) error {
err := n.Name.Restore(sb)
if err != nil {
return errors.Trace(err)
}
return nil
}
// Format the ExprNode into a Writer.
func (n *ColumnNameExpr) Format(w io.Writer) {
name := strings.Replace(n.Name.String(), ".", "`.`", -1)
......@@ -414,6 +468,11 @@ type DefaultExpr struct {
Name *ColumnName
}
// Restore implements Recoverable interface.
func (n *DefaultExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *DefaultExpr) Format(w io.Writer) {
panic("Not implemented")
......@@ -446,6 +505,11 @@ type ExistsSubqueryExpr struct {
Not bool
}
// Restore implements Recoverable interface.
func (n *ExistsSubqueryExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *ExistsSubqueryExpr) Format(w io.Writer) {
panic("Not implemented")
......@@ -479,6 +543,11 @@ type PatternInExpr struct {
Sel ExprNode
}
// Restore implements Recoverable interface.
func (n *PatternInExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *PatternInExpr) Format(w io.Writer) {
n.Expr.Format(w)
......@@ -534,6 +603,11 @@ type IsNullExpr struct {
Not bool
}
// Restore implements Recoverable interface.
func (n *IsNullExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *IsNullExpr) Format(w io.Writer) {
n.Expr.Format(w)
......@@ -570,6 +644,11 @@ type IsTruthExpr struct {
True int64
}
// Restore implements Recoverable interface.
func (n *IsTruthExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *IsTruthExpr) Format(w io.Writer) {
n.Expr.Format(w)
......@@ -616,6 +695,11 @@ type PatternLikeExpr struct {
PatTypes []byte
}
// Restore implements Recoverable interface.
func (n *PatternLikeExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *PatternLikeExpr) Format(w io.Writer) {
n.Expr.Format(w)
......@@ -669,6 +753,11 @@ type ParenthesesExpr struct {
Expr ExprNode
}
// Restore implements Recoverable interface.
func (n *ParenthesesExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *ParenthesesExpr) Format(w io.Writer) {
fmt.Fprint(w, "(")
......@@ -706,6 +795,11 @@ type PositionExpr struct {
Refer *ResultField
}
// Restore implements Recoverable interface.
func (n *PositionExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *PositionExpr) Format(w io.Writer) {
panic("Not implemented")
......@@ -744,6 +838,11 @@ type PatternRegexpExpr struct {
Sexpr *string
}
// Restore implements Recoverable interface.
func (n *PatternRegexpExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *PatternRegexpExpr) Format(w io.Writer) {
n.Expr.Format(w)
......@@ -783,6 +882,11 @@ type RowExpr struct {
Values []ExprNode
}
// Restore implements Recoverable interface.
func (n *RowExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *RowExpr) Format(w io.Writer) {
panic("Not implemented")
......@@ -814,6 +918,12 @@ type UnaryOperationExpr struct {
V ExprNode
}
// Restore implements Recoverable interface.
func (n *UnaryOperationExpr) Restore(sb *strings.Builder) error {
n.Format(sb)
return nil
}
// Format the ExprNode into a Writer.
func (n *UnaryOperationExpr) Format(w io.Writer) {
n.Op.Format(w)
......@@ -842,6 +952,11 @@ type ValuesExpr struct {
Column *ColumnNameExpr
}
// Restore implements Recoverable interface.
func (n *ValuesExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *ValuesExpr) Format(w io.Writer) {
panic("Not implemented")
......@@ -879,6 +994,11 @@ type VariableExpr struct {
Value ExprNode
}
// Restore implements Recoverable interface.
func (n *VariableExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *VariableExpr) Format(w io.Writer) {
panic("Not implemented")
......@@ -908,6 +1028,11 @@ type MaxValueExpr struct {
exprNode
}
// Restore implements Recoverable interface.
func (n *MaxValueExpr) Restore(sb *strings.Builder) error {
panic("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *MaxValueExpr) Format(w io.Writer) {
fmt.Fprint(w, "MAXVALUE")
......
......@@ -16,7 +16,9 @@ package ast
import (
"fmt"
"io"
"strings"
"github.com/pingcap/errors"
"github.com/pingcap/parser/model"
"github.com/pingcap/parser/types"
)
......@@ -327,6 +329,11 @@ type FuncCallExpr struct {
Args []ExprNode
}
// Restore implements Recoverable interface.
func (n *FuncCallExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *FuncCallExpr) Format(w io.Writer) {
fmt.Fprintf(w, "%s(", n.FnName.L)
......@@ -399,6 +406,11 @@ type FuncCastExpr struct {
FunctionType CastFunctionType
}
// Restore implements Recoverable interface.
func (n *FuncCastExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *FuncCastExpr) Format(w io.Writer) {
switch n.FunctionType {
......@@ -507,6 +519,11 @@ type AggregateFuncExpr struct {
Distinct bool
}
// Restore implements Recoverable interface.
func (n *AggregateFuncExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format the ExprNode into a Writer.
func (n *AggregateFuncExpr) Format(w io.Writer) {
panic("Not implemented")
......@@ -575,6 +592,11 @@ type WindowFuncExpr struct {
Spec WindowSpec
}
// Restore implements Recoverable interface.
func (n *WindowFuncExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Format formats the window function expression into a Writer.
func (n *WindowFuncExpr) Format(w io.Writer) {
panic("Not implemented")
......
......@@ -18,6 +18,7 @@ import (
"fmt"
"strings"
"github.com/pingcap/errors"
"github.com/pingcap/parser/auth"
"github.com/pingcap/parser/model"
"github.com/pingcap/parser/mysql"
......@@ -97,6 +98,11 @@ type TraceStmt struct {
Format string
}
// Restore implements Recoverable interface.
func (n *TraceStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *TraceStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -123,6 +129,11 @@ type ExplainStmt struct {
Analyze bool
}
// Restore implements Recoverable interface.
func (n *ExplainStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *ExplainStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -149,6 +160,11 @@ type PrepareStmt struct {
SQLVar *VariableExpr
}
// Restore implements Recoverable interface.
func (n *PrepareStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *PrepareStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -174,6 +190,11 @@ type DeallocateStmt struct {
Name string
}
// Restore implements Recoverable interface.
func (n *DeallocateStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *DeallocateStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -202,6 +223,11 @@ type ExecuteStmt struct {
ExecID uint32
}
// Restore implements Recoverable interface.
func (n *ExecuteStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *ExecuteStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -225,6 +251,11 @@ type BeginStmt struct {
stmtNode
}
// Restore implements Recoverable interface.
func (n *BeginStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *BeginStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -243,6 +274,11 @@ type BinlogStmt struct {
Str string
}
// Restore implements Recoverable interface.
func (n *BinlogStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *BinlogStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -259,6 +295,11 @@ type CommitStmt struct {
stmtNode
}
// Restore implements Recoverable interface.
func (n *CommitStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *CommitStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -275,6 +316,11 @@ type RollbackStmt struct {
stmtNode
}
// Restore implements Recoverable interface.
func (n *RollbackStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *RollbackStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -293,6 +339,13 @@ type UseStmt struct {
DBName string
}
// Restore implements Recoverable interface.
func (n *UseStmt) Restore(sb *strings.Builder) error {
sb.WriteString("USE ")
WriteName(sb, n.DBName)
return nil
}
// Accept implements Node Accept interface.
func (n *UseStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -324,6 +377,11 @@ type VariableAssignment struct {
ExtendValue ValueExpr
}
// Restore implements Recoverable interface.
func (n *VariableAssignment) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node interface.
func (n *VariableAssignment) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -360,6 +418,11 @@ type FlushStmt struct {
ReadLock bool
}
// Restore implements Recoverable interface.
func (n *FlushStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *FlushStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -390,6 +453,11 @@ type KillStmt struct {
TiDBExtension bool
}
// Restore implements Recoverable interface.
func (n *KillStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *KillStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -407,6 +475,11 @@ type SetStmt struct {
Variables []*VariableAssignment
}
// Restore implements Recoverable interface.
func (n *SetStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *SetStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -454,6 +527,11 @@ type SetPwdStmt struct {
Password string
}
// Restore implements Recoverable interface.
func (n *SetPwdStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// SecureText implements SensitiveStatement interface.
func (n *SetPwdStmt) SecureText() string {
return fmt.Sprintf("set password for user %s", n.User)
......@@ -517,6 +595,11 @@ type CreateUserStmt struct {
Specs []*UserSpec
}
// Restore implements Recoverable interface.
func (n *CreateUserStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *CreateUserStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -548,6 +631,11 @@ type AlterUserStmt struct {
Specs []*UserSpec
}
// Restore implements Recoverable interface.
func (n *AlterUserStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// SecureText implements SensitiveStatement interface.
func (n *AlterUserStmt) SecureText() string {
var buf bytes.Buffer
......@@ -578,6 +666,11 @@ type DropUserStmt struct {
UserList []*auth.UserIdentity
}
// Restore implements Recoverable interface.
func (n *DropUserStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *DropUserStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -595,6 +688,11 @@ type DoStmt struct {
Exprs []ExprNode
}
// Restore implements Recoverable interface.
func (n *DoStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *DoStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -682,6 +780,11 @@ type AdminStmt struct {
ShowSlow *ShowSlow
}
// Restore implements Recoverable interface.
func (n *AdminStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *AdminStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -709,6 +812,11 @@ type PrivElem struct {
Cols []*ColumnName
}
// Restore implements Recoverable interface.
func (n *PrivElem) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *PrivElem) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -767,6 +875,11 @@ type RevokeStmt struct {
Users []*UserSpec
}
// Restore implements Recoverable interface.
func (n *RevokeStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *RevokeStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -795,6 +908,11 @@ type GrantStmt struct {
WithGrant bool
}
// Restore implements Recoverable interface.
func (n *GrantStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// SecureText implements SensitiveStatement interface.
func (n *GrantStmt) SecureText() string {
text := n.text
......@@ -860,6 +978,11 @@ type TableOptimizerHint struct {
MaxExecutionTime uint64
}
// Restore implements Recoverable interface.
func (n *TableOptimizerHint) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *TableOptimizerHint) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......
......@@ -13,7 +13,12 @@
package ast
import "github.com/pingcap/parser/model"
import (
"strings"
"github.com/pingcap/errors"
"github.com/pingcap/parser/model"
)
var (
_ StmtNode = &AnalyzeTableStmt{}
......@@ -34,6 +39,11 @@ type AnalyzeTableStmt struct {
IndexFlag bool
}
// Restore implements Recoverable interface.
func (n *AnalyzeTableStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *AnalyzeTableStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -58,6 +68,11 @@ type DropStatsStmt struct {
Table *TableName
}
// Restore implements Recoverable interface.
func (n *DropStatsStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *DropStatsStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......@@ -80,6 +95,11 @@ type LoadStatsStmt struct {
Path string
}
// Restore implements Recoverable interface.
func (n *LoadStatsStmt) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
}
// Accept implements Node Accept interface.
func (n *LoadStatsStmt) Accept(v Visitor) (Node, bool) {
newNode, skipChildren := v.Enter(n)
......
// Copyright 2017 PingCAP, Inc.
// Copyright 2018 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
......@@ -13,6 +13,8 @@
package ast
import "strings"
// IsReadOnly checks whether the input ast is readOnly.
func IsReadOnly(node Node) bool {
switch st := node.(type) {
......@@ -59,3 +61,15 @@ func (checker *readOnlyChecker) Enter(in Node) (out Node, skipChildren bool) {
func (checker *readOnlyChecker) Leave(in Node) (out Node, ok bool) {
return in, checker.readOnly
}
// WriteName append escaped `name` with back quote to `sb`.
func WriteName(sb *strings.Builder, name string) {
sb.WriteString("`")
sb.WriteString(EscapeName(name))
sb.WriteString("`")
}
// EscapeName escape the `name`
func EscapeName(name string) string {
return strings.Replace(name, "`", "``", -1)
}
module github.com/pingcap/parser
require (
github.com/cznic/golex v0.0.0-20181122101858-9c343928389c // indirect
github.com/cznic/mathutil v0.0.0-20181021201202-eba54fb065b7
github.com/cznic/parser v0.0.0-20160622100904-31edd927e5b1
github.com/cznic/sortutil v0.0.0-20150617083342-4c7342852e65
......@@ -8,7 +9,7 @@ require (
github.com/cznic/y v0.0.0-20170802143616-045f81c6662a
github.com/pingcap/check v0.0.0-20171206051426-1c287c953996
github.com/pingcap/errors v0.11.0
github.com/pingcap/tidb v0.0.0-20181109062255-f547869f4933
github.com/pingcap/tidb v0.0.0-20181203021530-741adcee43e2
github.com/pingcap/tipb v0.0.0-20181012112600-11e33c750323
github.com/sirupsen/logrus v1.2.0
golang.org/x/net v0.0.0-20181029044818-c44066c5c816
......
......@@ -4,15 +4,18 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.3+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/StackExchange/wmi v0.0.0-20180725035823-b12b22c5341f/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/apache/thrift v0.0.0-20161221203622-b2a4d4ae21c7/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/blacktear23/go-proxyprotocol v0.0.0-20171102103907-62e368e1c470/go.mod h1:VKt7CNAQxpFpSDz3sXyj9hY/GbVsQCr0sB3w59nE7lU=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/chzyer/readline v0.0.0-20171208011716-f6d7a1f6fbf3/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cockroachdb/cmux v0.0.0-20170110192607-30d10be49292/go.mod h1:qRiX68mZX1lGBkTWyp3CLcenw9I94W2dLeRvMzcn9N4=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd h1:qMd81Ts1T2OTKmB4acZcyKaMtRnY5Y44NuXGX2GFJ1w=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
github.com/coreos/bbolt v1.3.0/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/bbolt v1.3.1-coreos.6 h1:uTXKg9gY70s9jMAKdfljFQcuh4e/BXOM+V+d00KFj3A=
github.com/coreos/bbolt v1.3.1-coreos.6/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible h1:KjVWqrZ5U0wa3CxY2AxlH6/UcB+PK2td1DcsYhA+HRs=
......@@ -25,6 +28,8 @@ github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbp
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cznic/golex v0.0.0-20170803123110-4ab7c5e190e4 h1:CVAqftqbj+exlab+8KJQrE+kNIVlQfJt58j4GxCMF1s=
github.com/cznic/golex v0.0.0-20170803123110-4ab7c5e190e4/go.mod h1:+bmmJDNmKlhWNG+gwWCkaBoTy39Fs+bzRxVBzoTQbIc=
github.com/cznic/golex v0.0.0-20181122101858-9c343928389c h1:G8zTsaqyVfIHpgMFcGgdbhHSFhlNc77rAKkhVbQ9kQg=
github.com/cznic/golex v0.0.0-20181122101858-9c343928389c/go.mod h1:+bmmJDNmKlhWNG+gwWCkaBoTy39Fs+bzRxVBzoTQbIc=
github.com/cznic/mathutil v0.0.0-20181021201202-eba54fb065b7 h1:y+DH9ARrWiiNBV+6waYP2IPcsRbxdU1qsnycPfShF4c=
github.com/cznic/mathutil v0.0.0-20181021201202-eba54fb065b7/go.mod h1:e6NPNENfs9mPDVNRekM7lKScauxd5kXTr1Mfyig6TDM=
github.com/cznic/parser v0.0.0-20160622100904-31edd927e5b1 h1:uWcWCkSP+E1w1z8r082miT+c+9vzg+5UdrgGCo15lMo=
......@@ -52,6 +57,7 @@ github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8=
github.com/go-sql-driver/mysql v0.0.0-20170715192408-3955978caca4/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/gogo/protobuf v1.1.1 h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
......@@ -74,6 +80,7 @@ github.com/gorilla/mux v1.6.2 h1:Pgr17XVTNXAk3q/r4CpKzC5xBM/qW1uVLV+IhRZpIIk=
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/websocket v1.2.0 h1:VJtLvh6VQym50czpZzx07z/kw9EgAxI3x1ZB8taTMQQ=
github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 h1:BWIsLfhgKhV5g/oF34aRjniBHLTZe5DNekSjbAjIS6c=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=
......@@ -102,6 +109,14 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/leoppro/tidb v0.0.0-00000000000000-5791a57a03b7 h1:t9oZ5f5OO46px5blv5m45vFGxT1Ee97BF0fKYrLmj2s=
github.com/leoppro/tidb v0.0.0-00000000000000-5791a57a03b7/go.mod h1:B8fFZPvn+zh0LEJODdc+br1SRRbljoZakm3ATyH0JuY=
github.com/leoppro/tidb v0.0.0-00000000000000-812fd5698f7b h1:RGNCcA7g6cl0x6Dk9FjxLC9XHRggitWe4lH7EvewyaA=
github.com/leoppro/tidb v0.0.0-00000000000000-812fd5698f7b/go.mod h1:B8fFZPvn+zh0LEJODdc+br1SRRbljoZakm3ATyH0JuY=
github.com/leoppro/tidb v0.0.0-00000000000000-aa8ec4ce061f h1:/m009OmMg7sgg2WrdiTfotiLYiZBBRZSHH9ECVD8WMQ=
github.com/leoppro/tidb v0.0.0-00000000000000-aa8ec4ce061f/go.mod h1:B8fFZPvn+zh0LEJODdc+br1SRRbljoZakm3ATyH0JuY=
github.com/leoppro/tidb v0.0.0-00000000000000-f790373f69fa h1:42ueISbhV36GHTYwiWeFAP0WxunRka1BD4z6GtzPglQ=
github.com/leoppro/tidb v0.0.0-00000000000000-f790373f69fa/go.mod h1:B8fFZPvn+zh0LEJODdc+br1SRRbljoZakm3ATyH0JuY=
github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
......@@ -116,8 +131,10 @@ github.com/ngaut/sync2 v0.0.0-20141008032647-7a24ed77b2ef h1:K0Fn+DoFqNqktdZtdV3
github.com/ngaut/sync2 v0.0.0-20141008032647-7a24ed77b2ef/go.mod h1:7WjlapSfwQyo6LNmIvEWzsW1hbBQfpUO4JWnuQRmva8=
github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.2 h1:3mYCb7aPxS/RU7TI1y4rkEn1oKmPRjNJLNEXgw7MH2I=
github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/opentracing/basictracer-go v1.0.0 h1:YyUAhaEfjoWXclZVJ9sGoNct7j4TVk7lZWlQw5UXuoo=
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg4X946/Y5Zwg=
......@@ -136,6 +153,8 @@ github.com/pingcap/kvproto v0.0.0-20181028030329-855d2192cdc7 h1:CYssSnPvf90ZSbF
github.com/pingcap/kvproto v0.0.0-20181028030329-855d2192cdc7/go.mod h1:0gwbe1F2iBIjuQ9AH0DbQhL+Dpr5GofU8fgYyXk+ykk=
github.com/pingcap/kvproto v0.0.0-20181105061835-1b5d69cd1d26/go.mod h1:0gwbe1F2iBIjuQ9AH0DbQhL+Dpr5GofU8fgYyXk+ykk=
github.com/pingcap/parser v0.0.0-20181102070703-4acd198f5092/go.mod h1:1FNvfp9+J0wvc4kl8eGNh7Rqrxveg15jJoWo/a0uHwA=
github.com/pingcap/parser v0.0.0-20181120072820-10951bcfca73/go.mod h1:1FNvfp9+J0wvc4kl8eGNh7Rqrxveg15jJoWo/a0uHwA=
github.com/pingcap/parser v0.0.0-20181126111651-a38036a60de7/go.mod h1:1FNvfp9+J0wvc4kl8eGNh7Rqrxveg15jJoWo/a0uHwA=
github.com/pingcap/pd v2.1.0-rc.4+incompatible h1:/buwGk04aHO5odk/+O8ZOXGs4qkUjYTJ2UpCJXna8NE=
github.com/pingcap/pd v2.1.0-rc.4+incompatible/go.mod h1:nD3+EoYes4+aNNODO99ES59V83MZSI+dFbhyr667a0E=
github.com/pingcap/tidb v0.0.0-20181105182855-379ee5b1915a h1:Qd8qbDnsmAIXxefGBgFrWh4y0GDO6froUNFqZYmC568=
......@@ -144,10 +163,15 @@ github.com/pingcap/tidb v0.0.0-20181106092750-bb6d0a935d70 h1:a71Zzbf3hautypbfre
github.com/pingcap/tidb v0.0.0-20181106092750-bb6d0a935d70/go.mod h1:tq1TVnaDUrh46KbB+oJA34Ob3eMbinTopWVzhX5Rj94=
github.com/pingcap/tidb v0.0.0-20181109062255-f547869f4933 h1:YwXtZpzgqq6LymXQXHBpneC7yQpxeXpAO5cuafuFgMQ=
github.com/pingcap/tidb v0.0.0-20181109062255-f547869f4933/go.mod h1:GJ1YwdkgaTo6oaWlg9K8nKZ3RaYaP5qXJl/lCywOQ5I=
github.com/pingcap/tidb v0.0.0-20181203021530-741adcee43e2 h1:A95bj50yYZMa1z655BmojZWKAu1zC3FONdSrfN9s8k0=
github.com/pingcap/tidb v0.0.0-20181203021530-741adcee43e2/go.mod h1:xn+3XVdDK//tvavk1V5iNfEDq7dI3klo1xvCiFgBOLs=
github.com/pingcap/tidb v2.0.8+incompatible h1:4G85C71eFTQRJ0Icwul/z3gJfR0u0aWXq1t/f4O8R40=
github.com/pingcap/tidb v2.0.8+incompatible/go.mod h1:I8C6jrPINP2rrVunTRd7C9fRRhQrtR43S1/CL5ix/yQ=
github.com/pingcap/tidb v2.0.9+incompatible h1:O6vEjpNZfHcO0XBYjMvqozyYrOyJCrzTt/I8wHmBkbw=
github.com/pingcap/tidb v2.0.9+incompatible/go.mod h1:I8C6jrPINP2rrVunTRd7C9fRRhQrtR43S1/CL5ix/yQ=
github.com/pingcap/tidb-tools v0.0.0-20181101090416-cfac1096162e h1:LKGiK9RwOntq4kniQdGM9q1Cg4AGeIyHBeiFc2OIlpo=
github.com/pingcap/tidb-tools v0.0.0-20181101090416-cfac1096162e/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM=
github.com/pingcap/tidb-tools v0.0.0-20181112132202-4860a0d5de03/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM=
github.com/pingcap/tipb v0.0.0-20181012112600-11e33c750323 h1:mRKKzRjDNaUNPnAkPAHnRqpNmwNWBX1iA+hxlmvQ93I=
github.com/pingcap/tipb v0.0.0-20181012112600-11e33c750323/go.mod h1:RtkHW8WbcNxj8lsbzjaILci01CtYnYbIkQhjyZWrWVI=
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
......@@ -166,6 +190,10 @@ github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqn
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446 h1:/NRJ5vAYoqz+7sG51ubIDHXeWO8DlTSrToPu6q11ziA=
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/shirou/gopsutil v2.18.10+incompatible h1:cy84jW6EVRPa5g9HAHrlbxMSIjBhDSX0OFYyMYminYs=
github.com/shirou/gopsutil v2.18.10+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
github.com/shurcooL/vfsgen v0.0.0-20181020040650-a97a25d856ca/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
......@@ -179,6 +207,7 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/syndtr/goleveldb v0.0.0-20180815032940-ae2bd5eed72d/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2/go.mod h1:2PfKggNGDuadAa0LElHrByyrz4JPZ9fFx6Gs7nx7ZZU=
github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6 h1:lYIiVDtZnyTWlNwiAxLj0bbpTcx1BWCFhXjfsvmPdNc=
github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/twinj/uuid v1.0.0 h1:fzz7COZnDrXGTAOHGuUGYd6sG+JMq+AoE7+Jlu0przk=
......@@ -191,6 +220,7 @@ github.com/uber/jaeger-lib v1.5.0 h1:OHbgr8l656Ub3Fw5k9SWnBfIEwvoHQ+W2y+Aa9D1Uyo
github.com/uber/jaeger-lib v1.5.0/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U=
github.com/ugorji/go v1.1.1 h1:gmervu+jDMvXTbcHQ0pd2wee85nEoE0BsVyEuzkfK8w=
github.com/ugorji/go v1.1.1/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
github.com/ugorji/go/codec v0.0.0-20181127175209-856da096dbdf/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/unrolled/render v0.0.0-20180914162206-b9786414de4d h1:ggUgChAeyge4NZ4QUw6lhHsVymzwSDJOZcE0s2X8S20=
github.com/unrolled/render v0.0.0-20180914162206-b9786414de4d/go.mod h1:tu82oB5W2ykJRVioYsB+IQKcft7ryBr7w12qMBUPyXg=
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
......@@ -202,6 +232,7 @@ go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.8.0 h1:r6Za1Rii8+EGOYRDLvpooNOF6kP3iyDnkpzbw67gCQ8=
go.uber.org/zap v1.8.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16 h1:y6ce7gCWtnH+m3dCjzQ1PCuwl28DDIc3VNnvY29DlIA=
......@@ -220,6 +251,7 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181031143558-9b800f95dbbc h1:SdCq5U4J+PpbSDIl9bM0V1e1Ug1jsnBkAFvTs1htn7U=
golang.org/x/sys v0.0.0-20181031143558-9b800f95dbbc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
......@@ -227,6 +259,7 @@ golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 h1:+DCIGbF/swA92ohVg0//6X2IVY3KZs6p9mix0ziNYJM=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
......@@ -255,3 +288,5 @@ gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
sourcegraph.com/sourcegraph/appdash v0.0.0-20180531100431-4c381bd170b4/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k=
......@@ -195,9 +195,9 @@ func (s *Scanner) GetSQLMode() mysql.SQLMode {
return s.sqlMode
}
// EnableWindowFunc enables the scanner to recognize the keywords of window function.
func (s *Scanner) EnableWindowFunc() {
s.supportWindowFunc = true
// EnableWindowFunc controls whether the scanner recognize the keywords of window function.
func (s *Scanner) EnableWindowFunc(val bool) {
s.supportWindowFunc = val
}
// NewScanner returns a new scanner object.
......
......@@ -135,9 +135,9 @@ func (parser *Parser) SetSQLMode(mode mysql.SQLMode) {
parser.lexer.SetSQLMode(mode)
}
// EnableWindowFunc enables the parser to parse syntax related with window function.
func (parser *Parser) EnableWindowFunc() {
parser.lexer.EnableWindowFunc()
// EnableWindowFunc controls whether the parser to parse syntax related with window function.
func (parser *Parser) EnableWindowFunc(val bool) {
parser.lexer.EnableWindowFunc(val)
}
// ParseErrorWith returns "You have a syntax error near..." error message compatible with mysql.
......
......@@ -1527,7 +1527,7 @@ func extractSingleTimeValue(unit string, format string) (int64, int64, int64, fl
if err != nil {
return 0, 0, 0, 0, ErrIncorrectDatetimeValue.GenWithStackByArgs(format)
}
iv := int64(fv + 0.5)
iv := int64(math.Round(fv))
switch strings.ToUpper(unit) {
case "MICROSECOND":
......
......@@ -105,106 +105,106 @@
"revisionTime": "2018-10-24T15:10:47Z"
},
{
"checksumSHA1": "jBf42FXXePd8z/qP4g5n1K0H2vQ=",
"checksumSHA1": "V/4P8kb4QDozn9w++U8G+Kvt0+g=",
"path": "github.com/pingcap/parser",
"revision": "83f31aa7980adf30ef67a744d599804c4ca67faa",
"revisionTime": "2018-12-04T02:04:44Z"
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
},
{
"checksumSHA1": "xuDucshl6h8s/D6FVXIiWcgdu9I=",
"checksumSHA1": "Fj3tju6yXL0IHhhu6pYwvU5xzJo=",
"path": "github.com/pingcap/parser/ast",
"revision": "83f31aa7980adf30ef67a744d599804c4ca67faa",
"revisionTime": "2018-12-04T02:04:44Z"
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
},
{
"checksumSHA1": "skWGV4FNvD3vr+5olepaPPnylUw=",
"path": "github.com/pingcap/parser/auth",
"revision": "83f31aa7980adf30ef67a744d599804c4ca67faa",
"revisionTime": "2018-12-04T02:04:44Z"
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
},
{
"checksumSHA1": "grkBf/zf8cTJRtI64P1jV6B+p/4=",
"path": "github.com/pingcap/parser/charset",
"revision": "83f31aa7980adf30ef67a744d599804c4ca67faa",
"revisionTime": "2018-12-04T02:04:44Z"
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
},
{
"checksumSHA1": "SInoXbsRe0tnBwmatmtZYfSFbdk=",
"path": "github.com/pingcap/parser/format",
"revision": "83f31aa7980adf30ef67a744d599804c4ca67faa",
"revisionTime": "2018-12-04T02:04:44Z"
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
},
{
"checksumSHA1": "+rJd1MX+3A1gwbrFZHFWbC8l8ao=",
"path": "github.com/pingcap/parser/model",
"revision": "83f31aa7980adf30ef67a744d599804c4ca67faa",
"revisionTime": "2018-12-04T02:04:44Z"
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
},
{
"checksumSHA1": "QBa9yiMDQNl2cLLwqlRoNTpCPNg=",
"path": "github.com/pingcap/parser/mysql",
"revision": "83f31aa7980adf30ef67a744d599804c4ca67faa",
"revisionTime": "2018-12-04T02:04:44Z"
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
},
{
"checksumSHA1": "oNBCSwJRykKuzIKgPCttatB9hAo=",
"path": "github.com/pingcap/parser/opcode",
"revision": "83f31aa7980adf30ef67a744d599804c4ca67faa",
"revisionTime": "2018-12-04T02:04:44Z"
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
},
{
"checksumSHA1": "XvnUllvwMYd6HrMvMiKnn4cGN2M=",
"path": "github.com/pingcap/parser/terror",
"revision": "83f31aa7980adf30ef67a744d599804c4ca67faa",
"revisionTime": "2018-12-04T02:04:44Z"
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
},
{
"checksumSHA1": "s96v2EoeGKcWHO3mpMOQk/z2iaI=",
"path": "github.com/pingcap/parser/types",
"revision": "83f31aa7980adf30ef67a744d599804c4ca67faa",
"revisionTime": "2018-12-04T02:04:44Z"
"revision": "c563561800a23fd1edeae4a592400cc2d0b47f5f",
"revisionTime": "2018-12-05T02:39:50Z"
},
{
"checksumSHA1": "kO63T5plq+V7HWnkzB9WlOnp9Iw=",
"path": "github.com/pingcap/tidb/sessionctx/stmtctx",
"revision": "8ddeeea939747e2d4634beb792d9d3281c49129d",
"revisionTime": "2018-12-03T15:37:39Z"
"revision": "350a046975a1f86fa6f05f177e81ae838388f4bb",
"revisionTime": "2018-12-04T14:10:08Z"
},
{
"checksumSHA1": "U/Wz15G+PgX5yjPBvxRpTywvvCw=",
"checksumSHA1": "SH/wISM1ueh/ENPJhiq1KssPLDA=",
"path": "github.com/pingcap/tidb/types",
"revision": "8ddeeea939747e2d4634beb792d9d3281c49129d",
"revisionTime": "2018-12-03T15:37:39Z"
"revision": "350a046975a1f86fa6f05f177e81ae838388f4bb",
"revisionTime": "2018-12-04T14:10:08Z"
},
{
"checksumSHA1": "DWVD7+ygtT66IQ+cqXmMJ5OVqUk=",
"path": "github.com/pingcap/tidb/types/json",
"revision": "8ddeeea939747e2d4634beb792d9d3281c49129d",
"revisionTime": "2018-12-03T15:37:39Z"
"revision": "350a046975a1f86fa6f05f177e81ae838388f4bb",
"revisionTime": "2018-12-04T14:10:08Z"
},
{
"checksumSHA1": "Zp5ME8OXNTmHnYTwJJUZlydN4/U=",
"path": "github.com/pingcap/tidb/types/parser_driver",
"revision": "8ddeeea939747e2d4634beb792d9d3281c49129d",
"revisionTime": "2018-12-03T15:37:39Z"
"revision": "350a046975a1f86fa6f05f177e81ae838388f4bb",
"revisionTime": "2018-12-04T14:10:08Z"
},
{
"checksumSHA1": "s709bhSrG2Ec35406mGtrySid4s=",
"path": "github.com/pingcap/tidb/util/execdetails",
"revision": "8ddeeea939747e2d4634beb792d9d3281c49129d",
"revisionTime": "2018-12-03T15:37:39Z"
"revision": "350a046975a1f86fa6f05f177e81ae838388f4bb",
"revisionTime": "2018-12-04T14:10:08Z"
},
{
"checksumSHA1": "nUC7zVoAMNR2a+z2iGqHoN2AkFE=",
"path": "github.com/pingcap/tidb/util/hack",
"revision": "8ddeeea939747e2d4634beb792d9d3281c49129d",
"revisionTime": "2018-12-03T15:37:39Z"
"revision": "350a046975a1f86fa6f05f177e81ae838388f4bb",
"revisionTime": "2018-12-04T14:10:08Z"
},
{
"checksumSHA1": "xSyepiuqsoaaeDch7cXeumvVHKM=",
"path": "github.com/pingcap/tidb/util/memory",
"revision": "8ddeeea939747e2d4634beb792d9d3281c49129d",
"revisionTime": "2018-12-03T15:37:39Z"
"revision": "350a046975a1f86fa6f05f177e81ae838388f4bb",
"revisionTime": "2018-12-04T14:10:08Z"
},
{
"checksumSHA1": "SmYeIK/fIYXNu8IKxD6HOVQVTuU=",
......@@ -401,62 +401,62 @@
{
"checksumSHA1": "aKn1oKcY74N8TRLm3Ayt7Q4bbI4=",
"path": "vitess.io/vitess/go/bytes2",
"revision": "63d2180c9442f64cec8f5cc6e5eb43947034e8ef",
"revisionTime": "2018-12-03T23:57:47Z"
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
},
{
"checksumSHA1": "JVCEN4UGRmg3TofIBdzZMZ3G0Ww=",
"path": "vitess.io/vitess/go/hack",
"revision": "63d2180c9442f64cec8f5cc6e5eb43947034e8ef",
"revisionTime": "2018-12-03T23:57:47Z"
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
},
{
"checksumSHA1": "e1WJ7vCnVrlQQQlc6n/FewCDMso=",
"path": "vitess.io/vitess/go/sqltypes",
"revision": "63d2180c9442f64cec8f5cc6e5eb43947034e8ef",
"revisionTime": "2018-12-03T23:57:47Z"
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
},
{
"checksumSHA1": "ntFIQYkBS51G6y+FEkjFW40+HOU=",
"path": "vitess.io/vitess/go/vt/log",
"revision": "63d2180c9442f64cec8f5cc6e5eb43947034e8ef",
"revisionTime": "2018-12-03T23:57:47Z"
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
},
{
"checksumSHA1": "tPQFPwbMdjuX0qjNl4Zl8zc37JQ=",
"path": "vitess.io/vitess/go/vt/proto/query",
"revision": "63d2180c9442f64cec8f5cc6e5eb43947034e8ef",
"revisionTime": "2018-12-03T23:57:47Z"
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
},
{
"checksumSHA1": "o0tR/c7lgr0pLkxk7CdvjiNDAKU=",
"path": "vitess.io/vitess/go/vt/proto/topodata",
"revision": "63d2180c9442f64cec8f5cc6e5eb43947034e8ef",
"revisionTime": "2018-12-03T23:57:47Z"
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
},
{
"checksumSHA1": "77UojBqi0yyeQvR70j7C3kcKclQ=",
"path": "vitess.io/vitess/go/vt/proto/vtgate",
"revision": "63d2180c9442f64cec8f5cc6e5eb43947034e8ef",
"revisionTime": "2018-12-03T23:57:47Z"
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
},
{
"checksumSHA1": "QpWGhoVDwM+8+sgYLI/YU+95iGU=",
"path": "vitess.io/vitess/go/vt/proto/vtrpc",
"revision": "63d2180c9442f64cec8f5cc6e5eb43947034e8ef",
"revisionTime": "2018-12-03T23:57:47Z"
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
},
{
"checksumSHA1": "CZ0WbR7TBTgF9HoY+aRxzOzVlSs=",
"path": "vitess.io/vitess/go/vt/sqlparser",
"revision": "63d2180c9442f64cec8f5cc6e5eb43947034e8ef",
"revisionTime": "2018-12-03T23:57:47Z"
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
},
{
"checksumSHA1": "oF4XzuOzwvj1iduX/lYqNSyY/HM=",
"path": "vitess.io/vitess/go/vt/vterrors",
"revision": "63d2180c9442f64cec8f5cc6e5eb43947034e8ef",
"revisionTime": "2018-12-03T23:57:47Z"
"revision": "5bec5a560c87897b5d973bbced81764f3cf0f330",
"revisionTime": "2018-12-05T00:00:15Z"
}
],
"rootPath": "github.com/XiaoMi/soar"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册