diff --git a/common/config.go b/common/config.go index 8f2b451d528eeb7235148667df805669760de7b5..a8a78bba1ce34c8f5e4074ed0bab74814b279dcf 100644 --- a/common/config.go +++ b/common/config.go @@ -257,7 +257,7 @@ func parseDSN(odbc string, d *dsn) *dsn { if d != nil { // 原来有个判断,后来判断条件被删除了就导致第一次addr无论如何都会被修改。所以这边先注释掉 - //addr = d.Addr + // addr = d.Addr user = d.User password = d.Password schema = d.Schema @@ -273,27 +273,24 @@ func parseDSN(odbc string, d *dsn) *dsn { var userInfo, hostInfo, query string // DSN 格式匹配 - // userInfo@hostInfo/database - if res := regexp.MustCompile( `^(.*)@(.*?)/(.*?)($|\?)(.*)`).FindStringSubmatch(odbc); len(res) > 5 { + if res := regexp.MustCompile(`^(.*)@(.*?)/(.*?)($|\?)(.*)`).FindStringSubmatch(odbc); len(res) > 5 { + // userInfo@hostInfo/database userInfo = res[1] hostInfo = res[2] schema = res[3] query = res[5] - - // hostInfo/database } else if res := regexp.MustCompile(`^(.*)/(.*?)($|\?)(.*)`).FindStringSubmatch(odbc); len(res) > 4 { + // hostInfo/database hostInfo = res[1] schema = res[2] query = res[4] - - // userInfo@hostInfo } else if res := regexp.MustCompile(`^(.*)@(.*?)($|\?)(.*)`).FindStringSubmatch(odbc); len(res) > 4 { + // userInfo@hostInfo userInfo = res[1] hostInfo = res[2] query = res[4] - - // hostInfo } else { + // hostInfo hostInfo = odbc } @@ -301,7 +298,7 @@ func parseDSN(odbc string, d *dsn) *dsn { if userInfo != "" { user = strings.Split(userInfo, ":")[0] // 防止密码中含有与用户名相同的字符, 所以用正则替换, 剩下的就是密码 - password = strings.TrimLeft(regexp.MustCompile("^" + user).ReplaceAllString(userInfo, ""), ":") + password = strings.TrimLeft(regexp.MustCompile("^"+user).ReplaceAllString(userInfo, ""), ":") } // 解析主机信息 @@ -310,13 +307,13 @@ func parseDSN(odbc string, d *dsn) *dsn { if host == "" { host = "127.0.0.1" } - if port == ""{ + if port == "" { port = "3306" } addr = host + ":" + port // 解析查询字符串 - if (query != "") { + if query != "" { params := strings.Split(query, "&") for _, f := range params { attr := strings.Split(f, "=") diff --git a/vendor/github.com/pingcap/parser/ast/ast.go b/vendor/github.com/pingcap/parser/ast/ast.go index c80a7ad8bc586dfc292292fc0d796da1d1612d72..c13e592c2948c4d3832aed5c62ddb1308ed4125e 100644 --- a/vendor/github.com/pingcap/parser/ast/ast.go +++ b/vendor/github.com/pingcap/parser/ast/ast.go @@ -17,7 +17,6 @@ package ast import ( "io" - "strings" "github.com/pingcap/parser/model" "github.com/pingcap/parser/types" @@ -27,7 +26,7 @@ import ( // Interfaces embed Node should have 'Node' name suffix. type Node interface { // Restore returns the sql text from ast tree - Restore(sb *strings.Builder) error + Restore(ctx *RestoreCtx) error // Accept accepts Visitor to visit itself. // The returned node should replace original node. // ok returns false to stop visiting. diff --git a/vendor/github.com/pingcap/parser/ast/ddl.go b/vendor/github.com/pingcap/parser/ast/ddl.go index e4ac1f16145c289c84bf1dccc1da69159e99554e..4ce72d1097339d05751108714395032c9384b867 100644 --- a/vendor/github.com/pingcap/parser/ast/ddl.go +++ b/vendor/github.com/pingcap/parser/ast/ddl.go @@ -14,8 +14,6 @@ package ast import ( - "strings" - "github.com/pingcap/errors" "github.com/pingcap/parser/auth" "github.com/pingcap/parser/model" @@ -65,15 +63,17 @@ type DatabaseOption struct { Value string } -// Restore implements Recoverable interface. -func (n *DatabaseOption) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *DatabaseOption) Restore(ctx *RestoreCtx) error { switch n.Tp { case DatabaseOptionCharset: - sb.WriteString("CHARACTER SET = ") - sb.WriteString(n.Value) + ctx.WriteKeyWord("CHARACTER SET") + ctx.WritePlain(" = ") + ctx.WritePlain(n.Value) case DatabaseOptionCollate: - sb.WriteString("COLLATE = ") - sb.WriteString(n.Value) + ctx.WriteKeyWord("COLLATE") + ctx.WritePlain(" = ") + ctx.WritePlain(n.Value) default: return errors.Errorf("invalid DatabaseOptionType: %d", n.Tp) } @@ -90,16 +90,16 @@ type CreateDatabaseStmt struct { Options []*DatabaseOption } -// Restore implements Recoverable interface. -func (n *CreateDatabaseStmt) Restore(sb *strings.Builder) error { - sb.WriteString("CREATE DATABASE ") +// Restore implements Node interface. +func (n *CreateDatabaseStmt) Restore(ctx *RestoreCtx) error { + ctx.WriteKeyWord("CREATE DATABASE ") if n.IfNotExists { - sb.WriteString("IF NOT EXISTS ") + ctx.WriteKeyWord("IF NOT EXISTS ") } - WriteName(sb, n.Name) + ctx.WriteName(n.Name) for _, option := range n.Options { - sb.WriteString(" ") - err := option.Restore(sb) + ctx.WritePlain(" ") + err := option.Restore(ctx) if err != nil { return errors.Trace(err) } @@ -126,13 +126,13 @@ type DropDatabaseStmt struct { Name string } -// Restore implements Recoverable interface. -func (n *DropDatabaseStmt) Restore(sb *strings.Builder) error { - sb.WriteString("DROP DATABASE ") +// Restore implements Node interface. +func (n *DropDatabaseStmt) Restore(ctx *RestoreCtx) error { + ctx.WriteKeyWord("DROP DATABASE ") if n.IfExists { - sb.WriteString("IF EXISTS ") + ctx.WriteKeyWord("IF EXISTS ") } - WriteName(sb, n.Name) + ctx.WriteName(n.Name) return nil } @@ -154,8 +154,8 @@ type IndexColName struct { Length int } -// Restore implements Recoverable interface. -func (n *IndexColName) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *IndexColName) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -185,8 +185,8 @@ type ReferenceDef struct { OnUpdate *OnUpdateOpt } -// Restore implements Recoverable interface. -func (n *ReferenceDef) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *ReferenceDef) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -255,8 +255,8 @@ type OnDeleteOpt struct { ReferOpt ReferOptionType } -// Restore implements Recoverable interface. -func (n *OnDeleteOpt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *OnDeleteOpt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -276,8 +276,8 @@ type OnUpdateOpt struct { ReferOpt ReferOptionType } -// Restore implements Recoverable interface. -func (n *OnUpdateOpt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *OnUpdateOpt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -325,8 +325,8 @@ type ColumnOption struct { Refer *ReferenceDef } -// Restore implements Recoverable interface. -func (n *ColumnOption) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *ColumnOption) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -361,8 +361,8 @@ type IndexOption struct { Comment string } -// Restore implements Recoverable interface. -func (n *IndexOption) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *IndexOption) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -406,8 +406,8 @@ type Constraint struct { Option *IndexOption // Index Options } -// Restore implements Recoverable interface. -func (n *Constraint) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *Constraint) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -451,8 +451,8 @@ type ColumnDef struct { Options []*ColumnOption } -// Restore implements Recoverable interface. -func (n *ColumnDef) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *ColumnDef) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -494,8 +494,8 @@ type CreateTableStmt struct { Select ResultSetNode } -// Restore implements Recoverable interface. -func (n *CreateTableStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *CreateTableStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -553,8 +553,8 @@ type DropTableStmt struct { IsView bool } -// Restore implements Recoverable interface. -func (n *DropTableStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *DropTableStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -588,8 +588,8 @@ type RenameTableStmt struct { TableToTables []*TableToTable } -// Restore implements Recoverable interface. -func (n *RenameTableStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *RenameTableStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -629,8 +629,8 @@ type TableToTable struct { NewTable *TableName } -// Restore implements Recoverable interface. -func (n *TableToTable) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *TableToTable) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -669,8 +669,8 @@ type CreateViewStmt struct { CheckOption model.ViewCheckOption } -// Restore implements Recoverable interface. -func (n *CreateViewStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *CreateViewStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -706,8 +706,8 @@ type CreateIndexStmt struct { IndexOption *IndexOption } -// Restore implements Recoverable interface. -func (n *CreateIndexStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *CreateIndexStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -750,8 +750,8 @@ type DropIndexStmt struct { Table *TableName } -// Restore implements Recoverable interface. -func (n *DropIndexStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *DropIndexStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -843,8 +843,8 @@ type ColumnPosition struct { RelativeColumn *ColumnName } -// Restore implements Recoverable interface. -func (n *ColumnPosition) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *ColumnPosition) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -925,8 +925,8 @@ type AlterTableSpec struct { Num uint64 } -// Restore implements Recoverable interface. -func (n *AlterTableSpec) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *AlterTableSpec) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -984,8 +984,8 @@ type AlterTableStmt struct { Specs []*AlterTableSpec } -// Restore implements Recoverable interface. -func (n *AlterTableStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *AlterTableStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -1019,8 +1019,8 @@ type TruncateTableStmt struct { Table *TableName } -// Restore implements Recoverable interface. -func (n *TruncateTableStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *TruncateTableStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } diff --git a/vendor/github.com/pingcap/parser/ast/dml.go b/vendor/github.com/pingcap/parser/ast/dml.go index 088eb74446a5935dcf2afb905601ec413d3dfe0b..504b6270f32a58fd2dbb71e88127ab46209b0b12 100644 --- a/vendor/github.com/pingcap/parser/ast/dml.go +++ b/vendor/github.com/pingcap/parser/ast/dml.go @@ -14,8 +14,6 @@ package ast import ( - "strings" - "github.com/pingcap/errors" "github.com/pingcap/parser/auth" "github.com/pingcap/parser/model" @@ -85,8 +83,8 @@ type Join struct { StraightJoin bool } -// Restore implements Recoverable interface. -func (n *Join) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *Join) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -133,16 +131,16 @@ type TableName struct { IndexHints []*IndexHint } -// Restore implements Recoverable interface. -func (n *TableName) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *TableName) Restore(ctx *RestoreCtx) error { if n.Schema.String() != "" { - WriteName(sb, n.Schema.String()) - sb.WriteString(".") + ctx.WriteName(n.Schema.String()) + ctx.WritePlain(".") } - WriteName(sb, n.Name.String()) + ctx.WriteName(n.Name.String()) for _, value := range n.IndexHints { - sb.WriteString(" ") - if err := value.Restore(sb); err != nil { + ctx.WritePlain(" ") + if err := value.Restore(ctx); err != nil { return errors.Annotate(err, "An error occurred while splicing IndexHints") } } @@ -178,7 +176,7 @@ type IndexHint struct { } // IndexHint Restore (The const field uses switch to facilitate understanding) -func (n *IndexHint) Restore(sb *strings.Builder) error { +func (n *IndexHint) Restore(ctx *RestoreCtx) error { indexHintType := "" switch n.HintType { case 1: @@ -204,17 +202,16 @@ func (n *IndexHint) Restore(sb *strings.Builder) error { default: // Prevent accidents return errors.New("IndexHintScope has an error while matching") } - - sb.WriteString(indexHintType) - sb.WriteString(indexHintScope) - sb.WriteString(" (") + ctx.WriteKeyWord(indexHintType) + ctx.WriteKeyWord(indexHintScope) + ctx.WritePlain(" (") for i, value := range n.IndexNames { if i > 0 { - sb.WriteString(", ") + ctx.WritePlain(", ") } - WriteName(sb, value.O) + ctx.WriteName(value.O) } - sb.WriteString(")") + ctx.WritePlain(")") return nil } @@ -235,8 +232,8 @@ type DeleteTableList struct { Tables []*TableName } -// Restore implements Recoverable interface. -func (n *DeleteTableList) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *DeleteTableList) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -266,8 +263,8 @@ type OnCondition struct { Expr ExprNode } -// Restore implements Recoverable interface. -func (n *OnCondition) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *OnCondition) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -298,8 +295,8 @@ type TableSource struct { AsName model.CIStr } -// Restore implements Recoverable interface. -func (n *TableSource) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *TableSource) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -349,8 +346,8 @@ type WildCardField struct { Schema model.CIStr } -// Restore implements Recoverable interface. -func (n *WildCardField) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *WildCardField) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -384,8 +381,8 @@ type SelectField struct { Auxiliary bool } -// Restore implements Recoverable interface. -func (n *SelectField) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *SelectField) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -413,8 +410,8 @@ type FieldList struct { Fields []*SelectField } -// Restore implements Recoverable interface. -func (n *FieldList) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *FieldList) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -442,8 +439,8 @@ type TableRefsClause struct { TableRefs *Join } -// Restore implements Recoverable interface. -func (n *TableRefsClause) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *TableRefsClause) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -470,8 +467,8 @@ type ByItem struct { Desc bool } -// Restore implements Recoverable interface. -func (n *ByItem) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *ByItem) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -496,8 +493,8 @@ type GroupByClause struct { Items []*ByItem } -// Restore implements Recoverable interface. -func (n *GroupByClause) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *GroupByClause) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -524,8 +521,8 @@ type HavingClause struct { Expr ExprNode } -// Restore implements Recoverable interface. -func (n *HavingClause) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *HavingClause) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -551,8 +548,8 @@ type OrderByClause struct { ForUnion bool } -// Restore implements Recoverable interface. -func (n *OrderByClause) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *OrderByClause) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -609,8 +606,8 @@ type SelectStmt struct { IsInBraces bool } -// Restore implements Recoverable interface. -func (n *SelectStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *SelectStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -708,8 +705,8 @@ type UnionSelectList struct { Selects []*SelectStmt } -// Restore implements Recoverable interface. -func (n *UnionSelectList) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *UnionSelectList) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -741,8 +738,8 @@ type UnionStmt struct { Limit *Limit } -// Restore implements Recoverable interface. -func (n *UnionStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *UnionStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -786,8 +783,8 @@ type Assignment struct { Expr ExprNode } -// Restore implements Recoverable interface. -func (n *Assignment) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *Assignment) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -825,8 +822,8 @@ type LoadDataStmt struct { IgnoreLines uint64 } -// Restore implements Recoverable interface. -func (n *LoadDataStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *LoadDataStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -883,8 +880,8 @@ type InsertStmt struct { Select ResultSetNode } -// Restore implements Recoverable interface. -func (n *InsertStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *InsertStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -964,8 +961,8 @@ type DeleteStmt struct { TableHints []*TableOptimizerHint } -// Restore implements Recoverable interface. -func (n *DeleteStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *DeleteStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -1029,8 +1026,8 @@ type UpdateStmt struct { TableHints []*TableOptimizerHint } -// Restore implements Recoverable interface. -func (n *UpdateStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *UpdateStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -1085,8 +1082,8 @@ type Limit struct { Offset ExprNode } -// Restore implements Recoverable interface. -func (n *Limit) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *Limit) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -1170,8 +1167,8 @@ type ShowStmt struct { Where ExprNode } -// Restore implements Recoverable interface. -func (n *ShowStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *ShowStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -1235,8 +1232,8 @@ type WindowSpec struct { Frame *FrameClause } -// Restore implements Recoverable interface. -func (n *WindowSpec) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *WindowSpec) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -1278,8 +1275,8 @@ type PartitionByClause struct { Items []*ByItem } -// Restore implements Recoverable interface. -func (n *PartitionByClause) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *PartitionByClause) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -1319,8 +1316,8 @@ type FrameClause struct { Extent FrameExtent } -// Restore implements Recoverable interface. -func (n *FrameClause) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *FrameClause) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -1372,8 +1369,8 @@ type FrameBound struct { Unit ExprNode } -// Restore implements Recoverable interface. -func (n *FrameBound) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *FrameBound) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } diff --git a/vendor/github.com/pingcap/parser/ast/expressions.go b/vendor/github.com/pingcap/parser/ast/expressions.go index 4e7224b249ee26a3c3875fc9d5539172004660e3..dd0302a18ee2370201a638086ba12ba290c14dd2 100644 --- a/vendor/github.com/pingcap/parser/ast/expressions.go +++ b/vendor/github.com/pingcap/parser/ast/expressions.go @@ -79,9 +79,24 @@ type BetweenExpr struct { Not bool } -// Restore implements Recoverable interface. -func (n *BetweenExpr) Restore(sb *strings.Builder) error { - return errors.New("Not implemented") +// Restore implements Node interface. +func (n *BetweenExpr) Restore(ctx *RestoreCtx) error { + if err := n.Expr.Restore(ctx); err != nil { + return errors.Annotate(err, "An error occurred while restore BetweenExpr.Expr") + } + if n.Not { + ctx.WriteKeyWord(" NOT BETWEEN ") + } else { + ctx.WriteKeyWord(" BETWEEN ") + } + if err := n.Left.Restore(ctx); err != nil { + return errors.Annotate(err, "An error occurred while restore BetweenExpr.Left") + } + ctx.WriteKeyWord(" AND ") + if err := n.Right.Restore(ctx); err != nil { + return errors.Annotate(err, "An error occurred while restore BetweenExpr.Right ") + } + return nil } // Format the ExprNode into a Writer. @@ -137,8 +152,8 @@ type BinaryOperationExpr struct { R ExprNode } -// Restore implements Recoverable interface. -func (n *BinaryOperationExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *BinaryOperationExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -183,8 +198,8 @@ type WhenClause struct { Result ExprNode } -// Restore implements Recoverable interface. -func (n *WhenClause) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *WhenClause) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -221,8 +236,8 @@ type CaseExpr struct { ElseClause ExprNode } -// Restore implements Recoverable interface. -func (n *CaseExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *CaseExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -290,8 +305,8 @@ type SubqueryExpr struct { Exists bool } -// Restore implements Recoverable interface. -func (n *SubqueryExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *SubqueryExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -331,8 +346,8 @@ type CompareSubqueryExpr struct { All bool } -// Restore implements Recoverable interface. -func (n *CompareSubqueryExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *CompareSubqueryExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -369,17 +384,17 @@ type ColumnName struct { Name model.CIStr } -// Restore implements Recoverable interface. -func (n *ColumnName) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *ColumnName) Restore(ctx *RestoreCtx) error { if n.Schema.O != "" { - WriteName(sb, n.Schema.O) - sb.WriteString(".") + ctx.WriteName(n.Schema.O) + ctx.WritePlain(".") } if n.Table.O != "" { - WriteName(sb, n.Table.O) - sb.WriteString(".") + ctx.WriteName(n.Table.O) + ctx.WritePlain(".") } - WriteName(sb, n.Name.O) + ctx.WriteName(n.Name.O) return nil } @@ -431,10 +446,9 @@ 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 { +// Restore implements Node interface. +func (n *ColumnNameExpr) Restore(ctx *RestoreCtx) error { + if err := n.Name.Restore(ctx); err != nil { return errors.Trace(err) } return nil @@ -468,8 +482,8 @@ type DefaultExpr struct { Name *ColumnName } -// Restore implements Recoverable interface. -func (n *DefaultExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *DefaultExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -505,8 +519,8 @@ type ExistsSubqueryExpr struct { Not bool } -// Restore implements Recoverable interface. -func (n *ExistsSubqueryExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *ExistsSubqueryExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -543,8 +557,8 @@ type PatternInExpr struct { Sel ExprNode } -// Restore implements Recoverable interface. -func (n *PatternInExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *PatternInExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -603,9 +617,16 @@ type IsNullExpr struct { Not bool } -// Restore implements Recoverable interface. -func (n *IsNullExpr) Restore(sb *strings.Builder) error { - n.Format(sb) +// Restore implements Node interface. +func (n *IsNullExpr) Restore(ctx *RestoreCtx) error { + if err := n.Expr.Restore(ctx); err != nil { + return errors.Trace(err) + } + if n.Not { + ctx.WriteKeyWord(" IS NOT NULL") + } else { + ctx.WriteKeyWord(" IS NULL") + } return nil } @@ -645,8 +666,8 @@ type IsTruthExpr struct { True int64 } -// Restore implements Recoverable interface. -func (n *IsTruthExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *IsTruthExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -696,8 +717,8 @@ type PatternLikeExpr struct { PatTypes []byte } -// Restore implements Recoverable interface. -func (n *PatternLikeExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *PatternLikeExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -754,8 +775,8 @@ type ParenthesesExpr struct { Expr ExprNode } -// Restore implements Recoverable interface. -func (n *ParenthesesExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *ParenthesesExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -796,8 +817,8 @@ type PositionExpr struct { Refer *ResultField } -// Restore implements Recoverable interface. -func (n *PositionExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *PositionExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -839,8 +860,8 @@ type PatternRegexpExpr struct { Sexpr *string } -// Restore implements Recoverable interface. -func (n *PatternRegexpExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *PatternRegexpExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -883,8 +904,8 @@ type RowExpr struct { Values []ExprNode } -// Restore implements Recoverable interface. -func (n *RowExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *RowExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -919,9 +940,14 @@ type UnaryOperationExpr struct { V ExprNode } -// Restore implements Recoverable interface. -func (n *UnaryOperationExpr) Restore(sb *strings.Builder) error { - n.Format(sb) +// Restore implements Node interface. +func (n *UnaryOperationExpr) Restore(ctx *RestoreCtx) error { + if err := n.Op.Restore(ctx.In); err != nil { + return errors.Trace(err) + } + if err := n.V.Restore(ctx); err != nil { + return errors.Trace(err) + } return nil } @@ -953,8 +979,8 @@ type ValuesExpr struct { Column *ColumnNameExpr } -// Restore implements Recoverable interface. -func (n *ValuesExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *ValuesExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -995,8 +1021,8 @@ type VariableExpr struct { Value ExprNode } -// Restore implements Recoverable interface. -func (n *VariableExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *VariableExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -1029,8 +1055,8 @@ type MaxValueExpr struct { exprNode } -// Restore implements Recoverable interface. -func (n *MaxValueExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *MaxValueExpr) Restore(ctx *RestoreCtx) error { panic("Not implemented") } diff --git a/vendor/github.com/pingcap/parser/ast/functions.go b/vendor/github.com/pingcap/parser/ast/functions.go index 6de8d586604629f332209678f3ade538bdd83db0..e3500c67e5f8c9b4236a527b0c360b1090652229 100644 --- a/vendor/github.com/pingcap/parser/ast/functions.go +++ b/vendor/github.com/pingcap/parser/ast/functions.go @@ -16,7 +16,6 @@ package ast import ( "fmt" "io" - "strings" "github.com/pingcap/errors" "github.com/pingcap/parser/model" @@ -329,8 +328,8 @@ type FuncCallExpr struct { Args []ExprNode } -// Restore implements Recoverable interface. -func (n *FuncCallExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *FuncCallExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -406,8 +405,8 @@ type FuncCastExpr struct { FunctionType CastFunctionType } -// Restore implements Recoverable interface. -func (n *FuncCastExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *FuncCastExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -519,8 +518,8 @@ type AggregateFuncExpr struct { Distinct bool } -// Restore implements Recoverable interface. -func (n *AggregateFuncExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *AggregateFuncExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -592,8 +591,8 @@ type WindowFuncExpr struct { Spec WindowSpec } -// Restore implements Recoverable interface. -func (n *WindowFuncExpr) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *WindowFuncExpr) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } diff --git a/vendor/github.com/pingcap/parser/ast/misc.go b/vendor/github.com/pingcap/parser/ast/misc.go index 20d7120c740449b15d734ffa2c0632af9abe0b5e..b96210789ffcc6eaa86cc6097406487c398aef05 100644 --- a/vendor/github.com/pingcap/parser/ast/misc.go +++ b/vendor/github.com/pingcap/parser/ast/misc.go @@ -98,8 +98,8 @@ type TraceStmt struct { Format string } -// Restore implements Recoverable interface. -func (n *TraceStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *TraceStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -129,8 +129,8 @@ type ExplainStmt struct { Analyze bool } -// Restore implements Recoverable interface. -func (n *ExplainStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *ExplainStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -160,8 +160,8 @@ type PrepareStmt struct { SQLVar *VariableExpr } -// Restore implements Recoverable interface. -func (n *PrepareStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *PrepareStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -190,8 +190,8 @@ type DeallocateStmt struct { Name string } -// Restore implements Recoverable interface. -func (n *DeallocateStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *DeallocateStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -223,8 +223,8 @@ type ExecuteStmt struct { ExecID uint32 } -// Restore implements Recoverable interface. -func (n *ExecuteStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *ExecuteStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -251,8 +251,8 @@ type BeginStmt struct { stmtNode } -// Restore implements Recoverable interface. -func (n *BeginStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *BeginStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -274,8 +274,8 @@ type BinlogStmt struct { Str string } -// Restore implements Recoverable interface. -func (n *BinlogStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *BinlogStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -295,8 +295,8 @@ type CommitStmt struct { stmtNode } -// Restore implements Recoverable interface. -func (n *CommitStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *CommitStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -316,8 +316,8 @@ type RollbackStmt struct { stmtNode } -// Restore implements Recoverable interface. -func (n *RollbackStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *RollbackStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -339,10 +339,10 @@ type UseStmt struct { DBName string } -// Restore implements Recoverable interface. -func (n *UseStmt) Restore(sb *strings.Builder) error { - sb.WriteString("USE ") - WriteName(sb, n.DBName) +// Restore implements Node interface. +func (n *UseStmt) Restore(ctx *RestoreCtx) error { + ctx.WriteKeyWord("USE ") + ctx.WriteName(n.DBName) return nil } @@ -377,8 +377,8 @@ type VariableAssignment struct { ExtendValue ValueExpr } -// Restore implements Recoverable interface. -func (n *VariableAssignment) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *VariableAssignment) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -418,8 +418,8 @@ type FlushStmt struct { ReadLock bool } -// Restore implements Recoverable interface. -func (n *FlushStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *FlushStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -453,8 +453,8 @@ type KillStmt struct { TiDBExtension bool } -// Restore implements Recoverable interface. -func (n *KillStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *KillStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -475,8 +475,8 @@ type SetStmt struct { Variables []*VariableAssignment } -// Restore implements Recoverable interface. -func (n *SetStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *SetStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -527,8 +527,8 @@ type SetPwdStmt struct { Password string } -// Restore implements Recoverable interface. -func (n *SetPwdStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *SetPwdStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -595,8 +595,8 @@ type CreateUserStmt struct { Specs []*UserSpec } -// Restore implements Recoverable interface. -func (n *CreateUserStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *CreateUserStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -631,8 +631,8 @@ type AlterUserStmt struct { Specs []*UserSpec } -// Restore implements Recoverable interface. -func (n *AlterUserStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *AlterUserStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -666,8 +666,8 @@ type DropUserStmt struct { UserList []*auth.UserIdentity } -// Restore implements Recoverable interface. -func (n *DropUserStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *DropUserStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -688,8 +688,8 @@ type DoStmt struct { Exprs []ExprNode } -// Restore implements Recoverable interface. -func (n *DoStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *DoStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -780,8 +780,8 @@ type AdminStmt struct { ShowSlow *ShowSlow } -// Restore implements Recoverable interface. -func (n *AdminStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *AdminStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -812,8 +812,8 @@ type PrivElem struct { Cols []*ColumnName } -// Restore implements Recoverable interface. -func (n *PrivElem) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *PrivElem) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -875,8 +875,8 @@ type RevokeStmt struct { Users []*UserSpec } -// Restore implements Recoverable interface. -func (n *RevokeStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *RevokeStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -908,8 +908,8 @@ type GrantStmt struct { WithGrant bool } -// Restore implements Recoverable interface. -func (n *GrantStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *GrantStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -978,8 +978,8 @@ type TableOptimizerHint struct { MaxExecutionTime uint64 } -// Restore implements Recoverable interface. -func (n *TableOptimizerHint) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *TableOptimizerHint) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } diff --git a/vendor/github.com/pingcap/parser/ast/stats.go b/vendor/github.com/pingcap/parser/ast/stats.go index aad6a84037eba34abf6b140d86d742849c84b706..2a26cb919ba9d266ec1aed44e6e0eef4638f0464 100644 --- a/vendor/github.com/pingcap/parser/ast/stats.go +++ b/vendor/github.com/pingcap/parser/ast/stats.go @@ -14,8 +14,6 @@ package ast import ( - "strings" - "github.com/pingcap/errors" "github.com/pingcap/parser/model" ) @@ -39,8 +37,8 @@ type AnalyzeTableStmt struct { IndexFlag bool } -// Restore implements Recoverable interface. -func (n *AnalyzeTableStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *AnalyzeTableStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -68,8 +66,8 @@ type DropStatsStmt struct { Table *TableName } -// Restore implements Recoverable interface. -func (n *DropStatsStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *DropStatsStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } @@ -95,8 +93,8 @@ type LoadStatsStmt struct { Path string } -// Restore implements Recoverable interface. -func (n *LoadStatsStmt) Restore(sb *strings.Builder) error { +// Restore implements Node interface. +func (n *LoadStatsStmt) Restore(ctx *RestoreCtx) error { return errors.New("Not implemented") } diff --git a/vendor/github.com/pingcap/parser/ast/util.go b/vendor/github.com/pingcap/parser/ast/util.go index b2bd5468901daaa465826a31678a5af5d015a374..1569d2462bffc62bbfb305d7649421599edd7047 100644 --- a/vendor/github.com/pingcap/parser/ast/util.go +++ b/vendor/github.com/pingcap/parser/ast/util.go @@ -13,7 +13,11 @@ package ast -import "strings" +import ( + "fmt" + "io" + "strings" +) // IsReadOnly checks whether the input ast is readOnly. func IsReadOnly(node Node) bool { @@ -62,14 +66,150 @@ 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("`") +//RestoreFlag mark the Restore format +type RestoreFlags uint64 + +// Mutually exclusive group of `RestoreFlags`: +// [RestoreStringSingleQuotes, RestoreStringDoubleQuotes] +// [RestoreKeyWordUppercase, RestoreKeyWordLowercase] +// [RestoreNameUppercase, RestoreNameLowercase] +// [RestoreNameDoubleQuotes, RestoreNameBackQuotes] +// The flag with the left position in each group has a higher priority. +const ( + RestoreStringSingleQuotes RestoreFlags = 1 << iota + RestoreStringDoubleQuotes + RestoreStringEscapeBackslash + + RestoreKeyWordUppercase + RestoreKeyWordLowercase + + RestoreNameUppercase + RestoreNameLowercase + RestoreNameDoubleQuotes + RestoreNameBackQuotes +) + +const ( + DefaultRestoreFlags = RestoreStringSingleQuotes | RestoreKeyWordUppercase | RestoreNameBackQuotes +) + +func (rf RestoreFlags) has(flag RestoreFlags) bool { + return rf&flag != 0 +} + +// HasStringSingleQuotesFlag returns a boolean indicating when `rf` has `RestoreStringSingleQuotes` flag. +func (rf RestoreFlags) HasStringSingleQuotesFlag() bool { + return rf.has(RestoreStringSingleQuotes) +} + +// HasStringDoubleQuotesFlag returns a boolean indicating whether `rf` has `RestoreStringDoubleQuotes` flag. +func (rf RestoreFlags) HasStringDoubleQuotesFlag() bool { + return rf.has(RestoreStringDoubleQuotes) +} + +// HasStringEscapeBackslashFlag returns a boolean indicating whether `rf` has `RestoreStringEscapeBackslash` flag. +func (rf RestoreFlags) HasStringEscapeBackslashFlag() bool { + return rf.has(RestoreStringEscapeBackslash) +} + +// HasKeyWordUppercaseFlag returns a boolean indicating whether `rf` has `RestoreKeyWordUppercase` flag. +func (rf RestoreFlags) HasKeyWordUppercaseFlag() bool { + return rf.has(RestoreKeyWordUppercase) +} + +// HasKeyWordLowercaseFlag returns a boolean indicating whether `rf` has `RestoreKeyWordLowercase` flag. +func (rf RestoreFlags) HasKeyWordLowercaseFlag() bool { + return rf.has(RestoreKeyWordLowercase) +} + +// HasNameUppercaseFlag returns a boolean indicating whether `rf` has `RestoreNameUppercase` flag. +func (rf RestoreFlags) HasNameUppercaseFlag() bool { + return rf.has(RestoreNameUppercase) +} + +// HasNameLowercaseFlag returns a boolean indicating whether `rf` has `RestoreNameLowercase` flag. +func (rf RestoreFlags) HasNameLowercaseFlag() bool { + return rf.has(RestoreNameLowercase) +} + +// HasNameDoubleQuotesFlag returns a boolean indicating whether `rf` has `RestoreNameDoubleQuotes` flag. +func (rf RestoreFlags) HasNameDoubleQuotesFlag() bool { + return rf.has(RestoreNameDoubleQuotes) +} + +// HasNameBackQuotesFlag returns a boolean indicating whether `rf` has `RestoreNameBackQuotes` flag. +func (rf RestoreFlags) HasNameBackQuotesFlag() bool { + return rf.has(RestoreNameBackQuotes) +} + +// RestoreCtx is `Restore` context to hold flags and writer. +type RestoreCtx struct { + Flags RestoreFlags + In io.Writer +} + +// NewRestoreCtx returns a new `RestoreCtx`. +func NewRestoreCtx(flags RestoreFlags, in io.Writer) *RestoreCtx { + return &RestoreCtx{flags, in} +} + +// WriteKeyWord writes the `keyWord` into writer. +// `keyWord` will be converted format(uppercase and lowercase for now) according to `RestoreFlags`. +func (ctx *RestoreCtx) WriteKeyWord(keyWord string) { + switch { + case ctx.Flags.HasKeyWordUppercaseFlag(): + keyWord = strings.ToUpper(keyWord) + case ctx.Flags.HasKeyWordLowercaseFlag(): + keyWord = strings.ToLower(keyWord) + } + fmt.Fprint(ctx.In, keyWord) +} + +// WriteString writes the string into writer +// `str` may be wrapped in quotes and escaped according to RestoreFlags. +func (ctx *RestoreCtx) WriteString(str string) { + if ctx.Flags.HasStringEscapeBackslashFlag() { + str = strings.Replace(str, `\`, `\\`, -1) + } + quotes := "" + switch { + case ctx.Flags.HasStringSingleQuotesFlag(): + str = strings.Replace(str, `'`, `''`, -1) + quotes = `'` + case ctx.Flags.HasStringDoubleQuotesFlag(): + str = strings.Replace(str, `"`, `""`, -1) + quotes = `"` + } + fmt.Fprint(ctx.In, quotes, str, quotes) +} + +// WriteName writes the name into writer +// `name` maybe wrapped in quotes and escaped according to RestoreFlags. +func (ctx *RestoreCtx) WriteName(name string) { + switch { + case ctx.Flags.HasNameUppercaseFlag(): + name = strings.ToUpper(name) + case ctx.Flags.HasNameLowercaseFlag(): + name = strings.ToLower(name) + } + quotes := "" + switch { + case ctx.Flags.HasNameDoubleQuotesFlag(): + name = strings.Replace(name, `"`, `""`, -1) + quotes = `"` + case ctx.Flags.HasNameBackQuotesFlag(): + name = strings.Replace(name, "`", "``", -1) + quotes = "`" + } + fmt.Fprint(ctx.In, quotes, name, quotes) +} + +// WritePlain writes the plain text into writer without any handling. +func (ctx *RestoreCtx) WritePlain(plainText string) { + fmt.Fprint(ctx.In, plainText) } -// EscapeName escape the `name` -func EscapeName(name string) string { - return strings.Replace(name, "`", "``", -1) +// WritePlainf write the plain text into writer without any handling. +func (ctx *RestoreCtx) WritePlainf(format string, a ...interface{}) { + fmt.Fprintf(ctx.In, format, a...) } diff --git a/vendor/github.com/pingcap/parser/go.mod1 b/vendor/github.com/pingcap/parser/go.mod1 index 9b6f5fdf8d70091bf5cd28614ba71561ed325dbc..cfc68ae2e2375e699107ec5c1ea17e46cab73788 100644 --- a/vendor/github.com/pingcap/parser/go.mod1 +++ b/vendor/github.com/pingcap/parser/go.mod1 @@ -7,11 +7,10 @@ require ( github.com/cznic/sortutil v0.0.0-20150617083342-4c7342852e65 github.com/cznic/strutil v0.0.0-20171016134553-529a34b1c186 github.com/cznic/y v0.0.0-20170802143616-045f81c6662a - github.com/pingcap/check v0.0.0-20171206051426-1c287c953996 + github.com/pingcap/check v0.0.0-20181213055612-5c2b07721bdb github.com/pingcap/errors v0.11.0 - github.com/pingcap/tidb v0.0.0-20181203021530-741adcee43e2 + github.com/pingcap/tidb v0.0.0-20181217070741-096bb68e6bef 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 golang.org/x/text v0.3.0 ) diff --git a/vendor/github.com/pingcap/parser/go.sum1 b/vendor/github.com/pingcap/parser/go.sum1 index 24313c746a0cb35c7994608bdf8d109ba5bff709..02668a3f0423d05c8251c9f8819ee7c91e2b1f4e 100644 --- a/vendor/github.com/pingcap/parser/go.sum1 +++ b/vendor/github.com/pingcap/parser/go.sum1 @@ -1,23 +1,18 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.31.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 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 h1:5ZfJxyXo8KyX8DgGXC5B7ILL8y51fci/qYz2B4j8iLY= 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 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4= 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 h1:HIgH5xUWXT914HCI671AxuTTqjj64UOFr7pHn48LUTI= 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= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-semver v0.2.0 h1:3Jm3tLmsgAYcjC+4Up7hJrFBPr+n7rAqYeSw/SZazuY= @@ -26,8 +21,6 @@ github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142 h1:3jFq2xL4ZajGK github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg= 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= @@ -46,9 +39,6 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumC github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= -github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= -github.com/eapache/queue v0.0.0-20180227141424-093482f3f8ce/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 h1:clC1lXBpe2kTj2VHdaIu9ajZQe4kcEY9j0NsnDDBZ3o= github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= github.com/etcd-io/gofail v0.0.0-20180808172546-51ce9a71510a h1:QNEenQIsGDEEfFNSnN+h6hE1OwnHqTg7Dl9gEk1Cko4= @@ -57,6 +47,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 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E= 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= @@ -66,7 +57,6 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff h1:kOkM9whyQYodu09SJ6W3NCsHG7crFaJILQ22Gozp3lg= github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= -github.com/golang/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -78,8 +68,7 @@ github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8 github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= 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 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= 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= @@ -89,88 +78,47 @@ github.com/grpc-ecosystem/grpc-gateway v1.5.1 h1:3scN4iuXkNOyP98jF55Lv8a9j1o/Iwv github.com/grpc-ecosystem/grpc-gateway v1.5.1/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/juju/errors v0.0.0-20181012004132-a4583d0a56ea h1:g2k+8WR7cHch4g0tBDhfiEvAp7fXxTNBiD1oC1Oxj3E= -github.com/juju/errors v0.0.0-20181012004132-a4583d0a56ea/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= -github.com/juju/loggo v0.0.0-20180524022052-584905176618 h1:MK144iBQF9hTSwBW/9eJm034bVoG30IshVm688T2hi8= -github.com/juju/loggo v0.0.0-20180524022052-584905176618/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= -github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073 h1:WQM1NildKThwdP7qWrNAFGzp4ijNLw8RlgENkaI4MJs= -github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5 h1:2U0HzY8BJ8hVwDKIzp7y4voR9CX/nvcfymLmg2UiOio= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -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= github.com/montanaflynn/stats v0.0.0-20180911141734-db72e6cae808 h1:pmpDGKLw4n82EtrNiLqB+xSz/JQwFOaZuMALYUHwX5s= github.com/montanaflynn/stats v0.0.0-20180911141734-db72e6cae808/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/myesui/uuid v1.0.0 h1:xCBmH4l5KuvLYc5L7AS7SZg9/jKdIFubM7OVoLqaQUI= github.com/myesui/uuid v1.0.0/go.mod h1:2CDfNgU0LR8mIdO8vdWd8i9gWWxLlcoIGGpSNgafq84= -github.com/ngaut/log v0.0.0-20180314031856-b8e36e7ba5ac/go.mod h1:ueVCjKQllPmX7uEvCYnZD5b8qjidGf1TCH61arVe4SU= github.com/ngaut/pools v0.0.0-20180318154953-b7bc8c42aac7 h1:7KAv7KMGTTqSmYZtNdcNTgsos+vFzULLwyElndwn+5c= github.com/ngaut/pools v0.0.0-20180318154953-b7bc8c42aac7/go.mod h1:iWMfgwqYW+e8n5lC/jjNEhwcjbRDpl5NT7n2h+4UNcI= github.com/ngaut/sync2 v0.0.0-20141008032647-7a24ed77b2ef h1:K0Fn+DoFqNqktdZtdV3bPQ/0cuYh2H4rkg0tytX/07k= 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 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= 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 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= 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= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/petar/GoLLRB v0.0.0-20130427215148-53be0d36a84c/go.mod h1:HUpKUBZnpzkdx0kD/+Yfuft+uD3zHGtXF/XJB14TUr4= -github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pierrec/xxHash v0.1.1/go.mod h1:w2waW5Zoa/Wc4Yqe0wgrIYAGKqRMf7czn2HNKXmuL+I= -github.com/pingcap/check v0.0.0-20171206051426-1c287c953996 h1:ZBdiJCMan6GSo/aPAM7gywcUKa0z58gczVrnG6TQnAQ= -github.com/pingcap/check v0.0.0-20171206051426-1c287c953996/go.mod h1:B1+S9LNcuMyLH/4HMTViQOJevkGiik3wW2AN9zb2fNQ= -github.com/pingcap/errcode v0.0.0-20180921232412-a1a7271709d9/go.mod h1:4b2X8xSqxIroj/IZ9MX/VGZhAwc11wB9wRIzHvz6SeM= +github.com/pingcap/check v0.0.0-20181213055612-5c2b07721bdb h1:RGm4hzUgf7wxELKAzOBV27WFMxBD33OQkDwX6VOs/W4= +github.com/pingcap/check v0.0.0-20181213055612-5c2b07721bdb/go.mod h1:B1+S9LNcuMyLH/4HMTViQOJevkGiik3wW2AN9zb2fNQ= github.com/pingcap/errors v0.11.0 h1:DCJQB8jrHbQ1VVlMFIrbj2ApScNNotVmkSNplu2yUt4= github.com/pingcap/errors v0.11.0/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pingcap/goleveldb v0.0.0-20171020122428-b9ff6c35079e h1:P73/4dPCL96rGrobssy1nVy2VaVpNCuLpCbr+FEaTA8= github.com/pingcap/goleveldb v0.0.0-20171020122428-b9ff6c35079e/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw= -github.com/pingcap/kvproto v0.0.0-20181028030329-855d2192cdc7 h1:CYssSnPvf90ZSbFdZpsZGSI7y+drG1EfKxqTOnKnHb0= -github.com/pingcap/kvproto v0.0.0-20181028030329-855d2192cdc7/go.mod h1:0gwbe1F2iBIjuQ9AH0DbQhL+Dpr5GofU8fgYyXk+ykk= +github.com/pingcap/kvproto v0.0.0-20181105061835-1b5d69cd1d26 h1:JK4VLNYbSn36QSbCnqALi2ySXdH0DfcMssT/zmLf4Ls= 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/parser v0.0.0-20181214132045-732efe993f70/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= -github.com/pingcap/tidb v0.0.0-20181105182855-379ee5b1915a/go.mod h1:tq1TVnaDUrh46KbB+oJA34Ob3eMbinTopWVzhX5Rj94= -github.com/pingcap/tidb v0.0.0-20181106092750-bb6d0a935d70 h1:a71Zzbf3hautypbfreDgnT+NWtTTJATGGcssArxl/WQ= -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 v0.0.0-20181217070741-096bb68e6bef h1:a00XEAUzCi+RlsZcAg/LJx3zTL6FY+lwPwyxz5ZlnsI= +github.com/pingcap/tidb v0.0.0-20181217070741-096bb68e6bef/go.mod h1:YrstANCcWGHO/mbgK4nofaNCj3zOpmkhmfMwlltzPSE= +github.com/pingcap/tidb-tools v0.0.0-20181112132202-4860a0d5de03 h1:xVuo5U+l6XAWHsb+xhkZ8zz3jerIwDfCHAO6kR2Kaog= 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= @@ -186,27 +134,22 @@ github.com/prometheus/common v0.0.0-20181020173914-7e9e6cabbd39 h1:Cto4X6SVMWRPB github.com/prometheus/common v0.0.0-20181020173914-7e9e6cabbd39/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d h1:GoAlyOgbOEIFdaDqxJVlbOQ1DtGmZWs/Qau0hIlk+WQ= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= 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= github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/cobra v0.0.2/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 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/struCoder/pidusage v0.1.2/go.mod h1:pWBlW3YuSwRl6h7R5KbvA4N8oOqe9LjaKW5CwT1SPjI= 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= @@ -218,34 +161,26 @@ github.com/uber/jaeger-client-go v2.15.0+incompatible h1:NP3qsSqNxh8VYr956ur1N/1 github.com/uber/jaeger-client-go v2.15.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= 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 h1:BLcwkDfQ8QPXNXBApZUATvuigovcYPXkHzez80QFGNg= 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= github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 h1:MPPkRncZLN9Kh4MEFmbnK4h3BD7AUmskWv2+EeZJCCs= github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= 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 h1:XCJQEf3W6eZaVwhRBof6ImoYGJSITeKWsyeh3HFu/5o= 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= -golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181029044818-c44066c5c816 h1:mVFkLpejdFLXVUv9E42f3XJVfMdqd0IVLVIVLjZWn5o= golang.org/x/net v0.0.0-20181029044818-c44066c5c816/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20181031022657-8527f56f7107/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -253,31 +188,20 @@ golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTu 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= 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 h1:fqgJT0MGcGpPgpWU7VRdRjuArfcOvC4AoJmILihzhDg= 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= -google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2 h1:67iHsV9djwGdZpdZNbLuQj6FOzCaZe3w+vhLjn5AcFA= -google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/grpc v1.16.0 h1:dz5IJGuC2BB7qXR5AyHNwAUBhZscK2xVez7mznh72sY= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= -gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= -gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce h1:xcEWjVhvbDy+nHP67nPDDpbYrY+ILlfndk4bRioVHaU= -gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/stretchr/testify.v1 v1.2.2 h1:yhQC6Uy5CqibAIlk1wlusa/MJ3iAN49/BsR/dCCKz3M= @@ -287,6 +211,6 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD 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 h1:VO9oZbbkvTwqLimlQt15QNdOOBArT2dw/bvzsMZBiqQ= 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= diff --git a/vendor/github.com/pingcap/parser/model/model.go b/vendor/github.com/pingcap/parser/model/model.go index 958a29f83278f4058e69fbe6b4c795904afb0655..a5ebab0ebb98d37575f001783befa4bb5358f5b6 100644 --- a/vendor/github.com/pingcap/parser/model/model.go +++ b/vendor/github.com/pingcap/parser/model/model.go @@ -250,6 +250,14 @@ func (t *TableInfo) GetAutoIncrementColInfo() *ColumnInfo { return nil } +func (t *TableInfo) IsAutoIncColUnsigned() bool { + col := t.GetAutoIncrementColInfo() + if col == nil { + return false + } + return mysql.HasUnsignedFlag(col.Flag) +} + // Cols returns the columns of the table in public state. func (t *TableInfo) Cols() []*ColumnInfo { publicColumns := make([]*ColumnInfo, len(t.Columns)) diff --git a/vendor/github.com/pingcap/parser/opcode/opcode.go b/vendor/github.com/pingcap/parser/opcode/opcode.go index 670fb2b883bd14afd87ded2fb3c21ad3d4348d17..0b2a1936df67318268ce3d3def32a632dfa6cf36 100644 --- a/vendor/github.com/pingcap/parser/opcode/opcode.go +++ b/vendor/github.com/pingcap/parser/opcode/opcode.go @@ -16,6 +16,8 @@ package opcode import ( "fmt" "io" + + "github.com/pingcap/errors" ) // Op is opcode type. @@ -136,3 +138,12 @@ var opsLiteral = map[Op]string{ func (o Op) Format(w io.Writer) { fmt.Fprintf(w, "%s", opsLiteral[o]) } + +// Restore the Op into a Writer +func (o Op) Restore(w io.Writer) error { + if v, ok := opsLiteral[o]; ok { + fmt.Fprint(w, v) + return nil + } + return errors.Errorf("Invalid opcode type %d during restoring AST to SQL text", o) +} diff --git a/vendor/github.com/pingcap/tidb/types/field_type.go b/vendor/github.com/pingcap/tidb/types/field_type.go index 602c27ca9a34f895ad9b17b793ca48a79f677e3f..2178f6ed9a7230a4acb1da668998971f85156221 100644 --- a/vendor/github.com/pingcap/tidb/types/field_type.go +++ b/vendor/github.com/pingcap/tidb/types/field_type.go @@ -128,12 +128,24 @@ func DefaultParamTypeForValue(value interface{}, tp *FieldType) { tp.Decimal = UnspecifiedLength default: DefaultTypeForValue(value, tp) + if hasVariantFieldLength(tp) { + tp.Flen = UnspecifiedLength + } if tp.Tp == mysql.TypeUnspecified { tp.Tp = mysql.TypeVarString } } } +func hasVariantFieldLength(tp *FieldType) bool { + switch tp.Tp { + case mysql.TypeLonglong, mysql.TypeVarString, mysql.TypeDouble, mysql.TypeBlob, + mysql.TypeBit, mysql.TypeDuration, mysql.TypeNewDecimal, mysql.TypeEnum, mysql.TypeSet: + return true + } + return false +} + // DefaultTypeForValue returns the default FieldType for the value. func DefaultTypeForValue(value interface{}, tp *FieldType) { switch x := value.(type) { diff --git a/vendor/github.com/pingcap/tidb/types/parser_driver/value_expr.go b/vendor/github.com/pingcap/tidb/types/parser_driver/value_expr.go index 0e83711912ceb4c420b7a3696a286927214127fc..08b6872ce2f21cac8ae2a7ca1bd58d0b94ed2e97 100644 --- a/vendor/github.com/pingcap/tidb/types/parser_driver/value_expr.go +++ b/vendor/github.com/pingcap/tidb/types/parser_driver/value_expr.go @@ -17,7 +17,6 @@ import ( "fmt" "io" "strconv" - "strings" "github.com/pingcap/errors" "github.com/pingcap/parser/ast" @@ -69,11 +68,45 @@ type ValueExpr struct { projectionOffset int } -// Restore implements Recoverable interface. -func (n *ValueExpr) Restore(sb *strings.Builder) error { - err := n.format(sb) - if err != nil { - return errors.Trace(err) +// Restore implements Node interface. +func (n *ValueExpr) Restore(ctx *ast.RestoreCtx) error { + switch n.Kind() { + case types.KindNull: + ctx.WriteKeyWord("NULL") + case types.KindInt64: + if n.Type.Flag&mysql.IsBooleanFlag != 0 { + if n.GetInt64() > 0 { + ctx.WriteKeyWord("TRUE") + } else { + ctx.WriteKeyWord("FALSE") + } + } else { + ctx.WritePlain(strconv.FormatInt(n.GetInt64(), 10)) + } + case types.KindUint64: + ctx.WritePlain(strconv.FormatUint(n.GetUint64(), 10)) + case types.KindFloat32: + ctx.WritePlain(strconv.FormatFloat(n.GetFloat64(), 'e', -1, 32)) + case types.KindFloat64: + ctx.WritePlain(strconv.FormatFloat(n.GetFloat64(), 'e', -1, 64)) + case types.KindString, types.KindBytes: + ctx.WriteString(n.GetString()) + case types.KindMysqlDecimal: + ctx.WritePlain(n.GetMysqlDecimal().String()) + case types.KindBinaryLiteral: + if n.Type.Flag&mysql.UnsignedFlag != 0 { + ctx.WritePlainf("x'%x'", n.GetBytes()) + } else { + ctx.WritePlain(n.GetBinaryLiteral().ToBitLiteralString(true)) + } + case types.KindMysqlDuration, types.KindMysqlEnum, + types.KindMysqlBit, types.KindMysqlSet, types.KindMysqlTime, + types.KindInterface, types.KindMinNotNull, types.KindMaxValue, + types.KindRaw, types.KindMysqlJSON: + // TODO implement Restore function + return errors.New("Not implemented") + default: + return errors.New("can't format to string") } return nil } @@ -84,7 +117,7 @@ func (n *ValueExpr) GetDatumString() string { } // Format the ExprNode into a Writer. -func (n *ValueExpr) format(w io.Writer) error { +func (n *ValueExpr) Format(w io.Writer) { var s string switch n.Kind() { case types.KindNull: @@ -116,18 +149,9 @@ func (n *ValueExpr) format(w io.Writer) error { s = n.GetBinaryLiteral().ToBitLiteralString(true) } default: - return errors.New("can't format to string") - } - fmt.Fprint(w, s) - return nil -} - -// Format the ExprNode into a Writer. -func (n *ValueExpr) Format(w io.Writer) { - err := n.format(w) - if err != nil { panic("Can't format to string") } + fmt.Fprint(w, s) } // newValueExpr creates a ValueExpr with value, and sets default field type. @@ -170,9 +194,9 @@ type ParamMarkerExpr struct { Order int } -// Restore implements Recoverable interface. -func (n *ParamMarkerExpr) Restore(sb *strings.Builder) error { - sb.WriteString("?") +// Restore implements Node interface. +func (n *ParamMarkerExpr) Restore(ctx *ast.RestoreCtx) error { + ctx.WritePlain("?") return nil } diff --git a/vendor/vendor.json b/vendor/vendor.json index d8fbea1f3a49162f3585cdee9769f5cf8ed45096..f60b573026894719126ab1cf70a60d90384b61e4 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -105,106 +105,106 @@ "revisionTime": "2018-10-24T15:10:47Z" }, { - "checksumSHA1": "xbV0lm0Qw8rFC82Dttxbf5ypBjA=", + "checksumSHA1": "fjZ4hf54cBBlV260wsAMZJ5T3po=", "path": "github.com/pingcap/parser", - "revision": "f20218bc290343c2752c4926c1bf4264343bbef4", - "revisionTime": "2018-12-12T04:21:31Z" + "revision": "b7f4816358997259f649a06fd126db3542b644c8", + "revisionTime": "2018-12-17T08:17:10Z" }, { - "checksumSHA1": "RosqMriA/39ZEtqGgNU+bOfRBVc=", + "checksumSHA1": "nRo2Z/Gyb1ziK+CKQi1OAOMa4hc=", "path": "github.com/pingcap/parser/ast", - "revision": "f20218bc290343c2752c4926c1bf4264343bbef4", - "revisionTime": "2018-12-12T04:21:31Z" + "revision": "b7f4816358997259f649a06fd126db3542b644c8", + "revisionTime": "2018-12-17T08:17:10Z" }, { "checksumSHA1": "skWGV4FNvD3vr+5olepaPPnylUw=", "path": "github.com/pingcap/parser/auth", - "revision": "f20218bc290343c2752c4926c1bf4264343bbef4", - "revisionTime": "2018-12-12T04:21:31Z" + "revision": "b7f4816358997259f649a06fd126db3542b644c8", + "revisionTime": "2018-12-17T08:17:10Z" }, { "checksumSHA1": "t4UHo966WzU9Z0IJkyGHRp0loOk=", "path": "github.com/pingcap/parser/charset", - "revision": "f20218bc290343c2752c4926c1bf4264343bbef4", - "revisionTime": "2018-12-12T04:21:31Z" + "revision": "b7f4816358997259f649a06fd126db3542b644c8", + "revisionTime": "2018-12-17T08:17:10Z" }, { "checksumSHA1": "SInoXbsRe0tnBwmatmtZYfSFbdk=", "path": "github.com/pingcap/parser/format", - "revision": "f20218bc290343c2752c4926c1bf4264343bbef4", - "revisionTime": "2018-12-12T04:21:31Z" + "revision": "b7f4816358997259f649a06fd126db3542b644c8", + "revisionTime": "2018-12-17T08:17:10Z" }, { - "checksumSHA1": "reRV2qecd6NpB7tIW3JeK46K/sk=", + "checksumSHA1": "WZYTGDMnc1UfTdjdZoBbISsnpRY=", "path": "github.com/pingcap/parser/model", - "revision": "f20218bc290343c2752c4926c1bf4264343bbef4", - "revisionTime": "2018-12-12T04:21:31Z" + "revision": "b7f4816358997259f649a06fd126db3542b644c8", + "revisionTime": "2018-12-17T08:17:10Z" }, { "checksumSHA1": "QBa9yiMDQNl2cLLwqlRoNTpCPNg=", "path": "github.com/pingcap/parser/mysql", - "revision": "f20218bc290343c2752c4926c1bf4264343bbef4", - "revisionTime": "2018-12-12T04:21:31Z" + "revision": "b7f4816358997259f649a06fd126db3542b644c8", + "revisionTime": "2018-12-17T08:17:10Z" }, { - "checksumSHA1": "oNBCSwJRykKuzIKgPCttatB9hAo=", + "checksumSHA1": "+O6CYIE0jT8pIDxWRP9FtKwFZjI=", "path": "github.com/pingcap/parser/opcode", - "revision": "f20218bc290343c2752c4926c1bf4264343bbef4", - "revisionTime": "2018-12-12T04:21:31Z" + "revision": "b7f4816358997259f649a06fd126db3542b644c8", + "revisionTime": "2018-12-17T08:17:10Z" }, { "checksumSHA1": "XvnUllvwMYd6HrMvMiKnn4cGN2M=", "path": "github.com/pingcap/parser/terror", - "revision": "f20218bc290343c2752c4926c1bf4264343bbef4", - "revisionTime": "2018-12-12T04:21:31Z" + "revision": "b7f4816358997259f649a06fd126db3542b644c8", + "revisionTime": "2018-12-17T08:17:10Z" }, { "checksumSHA1": "YoDiJ3sniNqxkP5X/BDkx6efteA=", "path": "github.com/pingcap/parser/types", - "revision": "f20218bc290343c2752c4926c1bf4264343bbef4", - "revisionTime": "2018-12-12T04:21:31Z" + "revision": "b7f4816358997259f649a06fd126db3542b644c8", + "revisionTime": "2018-12-17T08:17:10Z" }, { "checksumSHA1": "fWqL/7jTYOiqDNmiUcQi3u45Hw0=", "path": "github.com/pingcap/tidb/sessionctx/stmtctx", - "revision": "4ccd7456fcdc5e62e68f49a0a542cbcf88e38343", - "revisionTime": "2018-12-13T09:52:39Z" + "revision": "ab88f0b1c3b6db829f3e553963673a9bf7752899", + "revisionTime": "2018-12-17T12:08:05Z" }, { - "checksumSHA1": "0CCq+3fAyaXs9XU+xWaRvbbtSOQ=", + "checksumSHA1": "kXyszfR2fQ6bHvuCCFlHRkt1mF0=", "path": "github.com/pingcap/tidb/types", - "revision": "4ccd7456fcdc5e62e68f49a0a542cbcf88e38343", - "revisionTime": "2018-12-13T09:52:39Z" + "revision": "ab88f0b1c3b6db829f3e553963673a9bf7752899", + "revisionTime": "2018-12-17T12:08:05Z" }, { "checksumSHA1": "DWVD7+ygtT66IQ+cqXmMJ5OVqUk=", "path": "github.com/pingcap/tidb/types/json", - "revision": "4ccd7456fcdc5e62e68f49a0a542cbcf88e38343", - "revisionTime": "2018-12-13T09:52:39Z" + "revision": "ab88f0b1c3b6db829f3e553963673a9bf7752899", + "revisionTime": "2018-12-17T12:08:05Z" }, { - "checksumSHA1": "Zp5ME8OXNTmHnYTwJJUZlydN4/U=", + "checksumSHA1": "6vi/eCZXqNTa5eAUpxDZet4LPlY=", "path": "github.com/pingcap/tidb/types/parser_driver", - "revision": "4ccd7456fcdc5e62e68f49a0a542cbcf88e38343", - "revisionTime": "2018-12-13T09:52:39Z" + "revision": "ab88f0b1c3b6db829f3e553963673a9bf7752899", + "revisionTime": "2018-12-17T12:08:05Z" }, { "checksumSHA1": "s709bhSrG2Ec35406mGtrySid4s=", "path": "github.com/pingcap/tidb/util/execdetails", - "revision": "4ccd7456fcdc5e62e68f49a0a542cbcf88e38343", - "revisionTime": "2018-12-13T09:52:39Z" + "revision": "ab88f0b1c3b6db829f3e553963673a9bf7752899", + "revisionTime": "2018-12-17T12:08:05Z" }, { "checksumSHA1": "nUC7zVoAMNR2a+z2iGqHoN2AkFE=", "path": "github.com/pingcap/tidb/util/hack", - "revision": "4ccd7456fcdc5e62e68f49a0a542cbcf88e38343", - "revisionTime": "2018-12-13T09:52:39Z" + "revision": "ab88f0b1c3b6db829f3e553963673a9bf7752899", + "revisionTime": "2018-12-17T12:08:05Z" }, { "checksumSHA1": "xSyepiuqsoaaeDch7cXeumvVHKM=", "path": "github.com/pingcap/tidb/util/memory", - "revision": "4ccd7456fcdc5e62e68f49a0a542cbcf88e38343", - "revisionTime": "2018-12-13T09:52:39Z" + "revision": "ab88f0b1c3b6db829f3e553963673a9bf7752899", + "revisionTime": "2018-12-17T12:08:05Z" }, { "checksumSHA1": "SmYeIK/fIYXNu8IKxD6HOVQVTuU=", @@ -401,62 +401,62 @@ { "checksumSHA1": "aKn1oKcY74N8TRLm3Ayt7Q4bbI4=", "path": "vitess.io/vitess/go/bytes2", - "revision": "eb5a5e0e435db30856600b794d8cff235fdf24b7", - "revisionTime": "2018-12-13T22:28:01Z" + "revision": "935bf8ac1ad1e75bc8fd26a74fbfc906f15aa7d0", + "revisionTime": "2018-12-17T04:01:44Z" }, { "checksumSHA1": "JVCEN4UGRmg3TofIBdzZMZ3G0Ww=", "path": "vitess.io/vitess/go/hack", - "revision": "eb5a5e0e435db30856600b794d8cff235fdf24b7", - "revisionTime": "2018-12-13T22:28:01Z" + "revision": "935bf8ac1ad1e75bc8fd26a74fbfc906f15aa7d0", + "revisionTime": "2018-12-17T04:01:44Z" }, { - "checksumSHA1": "e1WJ7vCnVrlQQQlc6n/FewCDMso=", + "checksumSHA1": "F5pcGq+2W1FHEjgktTdKOE6W8mk=", "path": "vitess.io/vitess/go/sqltypes", - "revision": "eb5a5e0e435db30856600b794d8cff235fdf24b7", - "revisionTime": "2018-12-13T22:28:01Z" + "revision": "935bf8ac1ad1e75bc8fd26a74fbfc906f15aa7d0", + "revisionTime": "2018-12-17T04:01:44Z" }, { "checksumSHA1": "ntFIQYkBS51G6y+FEkjFW40+HOU=", "path": "vitess.io/vitess/go/vt/log", - "revision": "eb5a5e0e435db30856600b794d8cff235fdf24b7", - "revisionTime": "2018-12-13T22:28:01Z" + "revision": "935bf8ac1ad1e75bc8fd26a74fbfc906f15aa7d0", + "revisionTime": "2018-12-17T04:01:44Z" }, { "checksumSHA1": "tPQFPwbMdjuX0qjNl4Zl8zc37JQ=", "path": "vitess.io/vitess/go/vt/proto/query", - "revision": "eb5a5e0e435db30856600b794d8cff235fdf24b7", - "revisionTime": "2018-12-13T22:28:01Z" + "revision": "935bf8ac1ad1e75bc8fd26a74fbfc906f15aa7d0", + "revisionTime": "2018-12-17T04:01:44Z" }, { "checksumSHA1": "o0tR/c7lgr0pLkxk7CdvjiNDAKU=", "path": "vitess.io/vitess/go/vt/proto/topodata", - "revision": "eb5a5e0e435db30856600b794d8cff235fdf24b7", - "revisionTime": "2018-12-13T22:28:01Z" + "revision": "935bf8ac1ad1e75bc8fd26a74fbfc906f15aa7d0", + "revisionTime": "2018-12-17T04:01:44Z" }, { "checksumSHA1": "77UojBqi0yyeQvR70j7C3kcKclQ=", "path": "vitess.io/vitess/go/vt/proto/vtgate", - "revision": "eb5a5e0e435db30856600b794d8cff235fdf24b7", - "revisionTime": "2018-12-13T22:28:01Z" + "revision": "935bf8ac1ad1e75bc8fd26a74fbfc906f15aa7d0", + "revisionTime": "2018-12-17T04:01:44Z" }, { "checksumSHA1": "QpWGhoVDwM+8+sgYLI/YU+95iGU=", "path": "vitess.io/vitess/go/vt/proto/vtrpc", - "revision": "eb5a5e0e435db30856600b794d8cff235fdf24b7", - "revisionTime": "2018-12-13T22:28:01Z" + "revision": "935bf8ac1ad1e75bc8fd26a74fbfc906f15aa7d0", + "revisionTime": "2018-12-17T04:01:44Z" }, { "checksumSHA1": "lENrUY/YyxwYFHYN+21TBH92P3U=", "path": "vitess.io/vitess/go/vt/sqlparser", - "revision": "eb5a5e0e435db30856600b794d8cff235fdf24b7", - "revisionTime": "2018-12-13T22:28:01Z" + "revision": "935bf8ac1ad1e75bc8fd26a74fbfc906f15aa7d0", + "revisionTime": "2018-12-17T04:01:44Z" }, { - "checksumSHA1": "oF4XzuOzwvj1iduX/lYqNSyY/HM=", + "checksumSHA1": "Jx+gOh/kiBDSZxEIWHyYn9brjdo=", "path": "vitess.io/vitess/go/vt/vterrors", - "revision": "eb5a5e0e435db30856600b794d8cff235fdf24b7", - "revisionTime": "2018-12-13T22:28:01Z" + "revision": "935bf8ac1ad1e75bc8fd26a74fbfc906f15aa7d0", + "revisionTime": "2018-12-17T04:01:44Z" } ], "rootPath": "github.com/XiaoMi/soar" diff --git a/vendor/vitess.io/vitess/go/sqltypes/query_response.go b/vendor/vitess.io/vitess/go/sqltypes/query_response.go index eeca6cd6c55f58033087535ca85f640ab0a1ad99..5ce8e58b7653a35ca4fa301c57fcc0b7b4f2911e 100644 --- a/vendor/vitess.io/vitess/go/sqltypes/query_response.go +++ b/vendor/vitess.io/vitess/go/sqltypes/query_response.go @@ -16,7 +16,9 @@ limitations under the License. package sqltypes -import "reflect" +import ( + "vitess.io/vitess/go/vt/vterrors" +) // QueryResponse represents a query response for ExecuteBatch. type QueryResponse struct { @@ -34,7 +36,7 @@ func QueryResponsesEqual(r1, r2 []QueryResponse) bool { if !r.QueryResult.Equal(r2[i].QueryResult) { return false } - if !reflect.DeepEqual(r.QueryError, r2[i].QueryError) { + if !vterrors.Equals(r.QueryError, r2[i].QueryError) { return false } } diff --git a/vendor/vitess.io/vitess/go/vt/vterrors/LICENSE b/vendor/vitess.io/vitess/go/vt/vterrors/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..835ba3e755cef8c0dde475f1ebfd41e4ba0c79bf --- /dev/null +++ b/vendor/vitess.io/vitess/go/vt/vterrors/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2015, Dave Cheney +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/vitess.io/vitess/go/vt/vterrors/doc.go b/vendor/vitess.io/vitess/go/vt/vterrors/doc.go deleted file mode 100644 index a704cc6568b60baf0ff0ab06c439735a5055b8bc..0000000000000000000000000000000000000000 --- a/vendor/vitess.io/vitess/go/vt/vterrors/doc.go +++ /dev/null @@ -1,44 +0,0 @@ -/* -Copyright 2017 Google Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreedto in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package vterrors provides helpers for propagating internal errors -// through the Vitess system (including across RPC boundaries) in a -// structured way. -package vterrors - -/* - -Vitess uses canonical error codes for error reporting. This is based -on years of industry experience with error reporting. This idea is -that errors should be classified into a small set of errors (10 or so) -with very specific meaning. Each error has a code, and a message. When -errors are passed around (even through RPCs), the code is -propagated. To handle errors, only the code should be looked at (and -not string-matching on the error message). - -Vitess defines the error codes in /proto/vtrpc.proto. Along with an -RPCError message that can be used to transmit errors through RPCs, in -the message payloads. These codes match the names and numbers defined -by gRPC. - -Vitess also defines a standardized error implementation that allows -you to build an error with an associated canonical code. - -While sending an error through gRPC, these codes are transmitted -using gRPC's error propagation mechanism and decoded back to -the original code on the other end. - -*/ diff --git a/vendor/vitess.io/vitess/go/vt/vterrors/stack.go b/vendor/vitess.io/vitess/go/vt/vterrors/stack.go new file mode 100644 index 0000000000000000000000000000000000000000..2ba717ad3f0489116f646a08cfdcdeecf347c5b9 --- /dev/null +++ b/vendor/vitess.io/vitess/go/vt/vterrors/stack.go @@ -0,0 +1,191 @@ +package vterrors + +/* This file is copied from https://github.com/pkg/errors/blob/v0.8.0/stack.go */ + +import ( + "fmt" + "io" + "path" + "runtime" + "strings" +) + +// Frame represents a program counter inside a stack frame. +type Frame uintptr + +// pc returns the program counter for this frame; +// multiple frames may have the same PC value. +func (f Frame) pc() uintptr { return uintptr(f) - 1 } + +// file returns the full path to the file that contains the +// function for this Frame's pc. +func (f Frame) file() string { + fn := runtime.FuncForPC(f.pc()) + if fn == nil { + return "unknown" + } + file, _ := fn.FileLine(f.pc()) + return file +} + +// line returns the line number of source code of the +// function for this Frame's pc. +func (f Frame) line() int { + fn := runtime.FuncForPC(f.pc()) + if fn == nil { + return 0 + } + _, line := fn.FileLine(f.pc()) + return line +} + +// Format formats the frame according to the fmt.Formatter interface. +// +// %s source file +// %d source line +// %n function name +// %v equivalent to %s:%d +// +// Format accepts flags that alter the printing of some verbs, as follows: +// +// %+s path of source file relative to the compile time GOPATH +// %+v equivalent to %+s:%d +func (f Frame) Format(s fmt.State, verb rune) { + switch verb { + case 's': + switch { + case s.Flag('+'): + pc := f.pc() + fn := runtime.FuncForPC(pc) + if fn == nil { + io.WriteString(s, "unknown") + } else { + file, _ := fn.FileLine(pc) + fmt.Fprintf(s, "%s\n\t%s", fn.Name(), file) + } + default: + io.WriteString(s, path.Base(f.file())) + } + case 'd': + fmt.Fprintf(s, "%d", f.line()) + case 'n': + name := runtime.FuncForPC(f.pc()).Name() + io.WriteString(s, funcname(name)) + case 'v': + f.Format(s, 's') + io.WriteString(s, ":") + f.Format(s, 'd') + } +} + +// StackTrace is stack of Frames from innermost (newest) to outermost (oldest). +type StackTrace []Frame + +// Format format the stacktrace according to the fmt.Formatter interface. +// +// %s source file +// %d source line +// %n function name +// %v equivalent to %s:%d +// +// Format accepts flags that alter the printing of some verbs, as follows: +// +// %+s path of source file relative to the compile time GOPATH +// %+v equivalent to %+s:%d +func (st StackTrace) Format(s fmt.State, verb rune) { + switch verb { + case 'v': + switch { + case s.Flag('+'): + for _, f := range st { + fmt.Fprintf(s, "\n%+v", f) + } + case s.Flag('#'): + fmt.Fprintf(s, "%#v", []Frame(st)) + default: + fmt.Fprintf(s, "%v", []Frame(st)) + } + case 's': + fmt.Fprintf(s, "%s", []Frame(st)) + } +} + +// stack represents a stack of program counters. +type stack []uintptr + +func (s *stack) Format(st fmt.State, verb rune) { + switch verb { + case 'v': + switch { + case st.Flag('+'): + for _, pc := range *s { + f := Frame(pc) + fmt.Fprintf(st, "\n%+v", f) + } + } + } +} + +func (s *stack) StackTrace() StackTrace { + f := make([]Frame, len(*s)) + for i := 0; i < len(f); i++ { + f[i] = Frame((*s)[i]) + } + return f +} + +func callers() *stack { + const depth = 32 + var pcs [depth]uintptr + n := runtime.Callers(3, pcs[:]) + var st stack = pcs[0:n] + return &st +} + +// funcname removes the path prefix component of a function's name reported by func.Name(). +func funcname(name string) string { + i := strings.LastIndex(name, "/") + name = name[i+1:] + i = strings.Index(name, ".") + return name[i+1:] +} + +func trimGOPATH(name, file string) string { + // Here we want to get the source file path relative to the compile time + // GOPATH. As of Go 1.6.x there is no direct way to know the compiled + // GOPATH at runtime, but we can infer the number of path segments in the + // GOPATH. We note that fn.Name() returns the function name qualified by + // the import path, which does not include the GOPATH. Thus we can trim + // segments from the beginning of the file path until the number of path + // separators remaining is one more than the number of path separators in + // the function name. For example, given: + // + // GOPATH /home/user + // file /home/user/src/pkg/sub/file.go + // fn.Name() pkg/sub.Type.Method + // + // We want to produce: + // + // pkg/sub/file.go + // + // From this we can easily see that fn.Name() has one less path separator + // than our desired output. We count separators from the end of the file + // path until it finds two more than in the function name and then move + // one character forward to preserve the initial path segment without a + // leading separator. + const sep = "/" + goal := strings.Count(name, sep) + 2 + i := len(file) + for n := 0; n < goal; n++ { + i = strings.LastIndex(file[:i], sep) + if i == -1 { + // not enough separators found, set i so that the slice expression + // below leaves file unmodified + i = -len(sep) + break + } + } + // get back to 0 or trim the leading separator + file = file[i+len(sep):] + return file +} diff --git a/vendor/vitess.io/vitess/go/vt/vterrors/vterrors.go b/vendor/vitess.io/vitess/go/vt/vterrors/vterrors.go index 2ce2416041017aa5792904aa7d025246336dfdc6..6e85542cb101dbba81c400208e02dca984869c96 100644 --- a/vendor/vitess.io/vitess/go/vt/vterrors/vterrors.go +++ b/vendor/vitess.io/vitess/go/vt/vterrors/vterrors.go @@ -1,73 +1,153 @@ -/* -Copyright 2017 Google Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreedto in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - +// Package vterrors provides simple error handling primitives for Vitess +// +// In all Vitess code, errors should be propagated using vterrors.Wrapf() +// and not fmt.Errorf(). +// +// New errors should be created using vterrors.New +// +// Vitess uses canonical error codes for error reporting. This is based +// on years of industry experience with error reporting. This idea is +// that errors should be classified into a small set of errors (10 or so) +// with very specific meaning. Each error has a code, and a message. When +// errors are passed around (even through RPCs), the code is +// propagated. To handle errors, only the code should be looked at (and +// not string-matching on the error message). +// +// Error codes are defined in /proto/vtrpc.proto. Along with an +// RPCError message that can be used to transmit errors through RPCs, in +// the message payloads. These codes match the names and numbers defined +// by gRPC. +// +// A standardized error implementation that allows you to build an error +// with an associated canonical code is also defined. +// While sending an error through gRPC, these codes are transmitted +// using gRPC's error propagation mechanism and decoded back to +// the original code on the other end. +// +// Retrieving the cause of an error +// +// Using vterrors.Wrap constructs a stack of errors, adding context to the +// preceding error. Depending on the nature of the error it may be necessary +// to reverse the operation of errors.Wrap to retrieve the original error +// for inspection. Any error value which implements this interface +// +// type causer interface { +// Cause() error +// } +// +// can be inspected by vterrors.Cause and vterrors.RootCause. +// +// * vterrors.Cause will find the immediate cause if one is available, or nil +// if the error is not a `causer` or if no cause is available. +// * vterrors.RootCause will recursively retrieve +// the topmost error which does not implement causer, which is assumed to be +// the original cause. For example: +// +// switch err := errors.RootCause(err).(type) { +// case *MyError: +// // handle specifically +// default: +// // unknown error +// } +// +// causer interface is not exported by this package, but is considered a part +// of stable public API. +// +// Formatted printing of errors +// +// All error values returned from this package implement fmt.Formatter and can +// be formatted by the fmt package. The following verbs are supported +// +// %s print the error. If the error has a Cause it will be +// printed recursively +// %v see %s +// %+v extended format. Each Frame of the error's StackTrace will +// be printed in detail. +// +// Most but not all of the code in this file was originally copied from +// https://github.com/pkg/errors/blob/v0.8.0/errors.go package vterrors import ( "fmt" - "golang.org/x/net/context" - + "io" vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc" ) -type vtError struct { - code vtrpcpb.Code - err string +// New returns an error with the supplied message. +// New also records the stack trace at the point it was called. +func New(code vtrpcpb.Code, message string) error { + return &fundamental{ + msg: message, + code: code, + stack: callers(), + } } -// New creates a new error using the code and input string. -func New(code vtrpcpb.Code, in string) error { - if code == vtrpcpb.Code_OK { - panic("OK is an invalid error code; use INTERNAL instead") - } - return &vtError{ - code: code, - err: in, +// NewWithoutCode returns an error when no applicable error code is available +// It will record the stack trace when creating the error +func NewWithoutCode(message string) error { + return &fundamental{ + msg: message, + code: vtrpcpb.Code_UNKNOWN, + stack: callers(), } } -// Wrap wraps the given error, returning a new error with the given message as a prefix but with the same error code (if err was a vterror) and message of the passed error. -func Wrap(err error, message string) error { - return New(Code(err), fmt.Sprintf("%v: %v", message, err.Error())) +// Errorf formats according to a format specifier and returns the string +// as a value that satisfies error. +// Errorf also records the stack trace at the point it was called. +func Errorf(code vtrpcpb.Code, format string, args ...interface{}) error { + return &fundamental{ + msg: fmt.Sprintf(format, args...), + code: code, + stack: callers(), + } } -// Wrapf wraps the given error, returning a new error with the given format string as a prefix but with the same error code (if err was a vterror) and message of the passed error. -func Wrapf(err error, format string, args ...interface{}) error { - return Wrap(err, fmt.Sprintf(format, args...)) +// fundamental is an error that has a message and a stack, but no caller. +type fundamental struct { + msg string + code vtrpcpb.Code + *stack } -// Errorf returns a new error built using Printf style arguments. -func Errorf(code vtrpcpb.Code, format string, args ...interface{}) error { - return New(code, fmt.Sprintf(format, args...)) -} +func (f *fundamental) Error() string { return f.msg } -func (e *vtError) Error() string { - return e.err +func (f *fundamental) Format(s fmt.State, verb rune) { + switch verb { + case 'v': + if s.Flag('+') { + io.WriteString(s, "Code: "+f.code.String()+"\n") + io.WriteString(s, f.msg+"\n") + f.stack.Format(s, verb) + return + } + fallthrough + case 's': + io.WriteString(s, f.msg) + case 'q': + fmt.Fprintf(s, "%q", f.msg) + } } // Code returns the error code if it's a vtError. -// If err is nil, it returns ok. Otherwise, it returns unknown. +// If err is nil, it returns ok. func Code(err error) vtrpcpb.Code { if err == nil { return vtrpcpb.Code_OK } - if err, ok := err.(*vtError); ok { + if err, ok := err.(*fundamental); ok { return err.code } + + cause := Cause(err) + if cause != err && cause != nil { + // If we did not find an error code at the outer level, let's find the cause and check it's code + return Code(cause) + } + // Handle some special cases. switch err { case context.Canceled: @@ -78,16 +158,111 @@ func Code(err error) vtrpcpb.Code { return vtrpcpb.Code_UNKNOWN } +// Wrap returns an error annotating err with a stack trace +// at the point Wrap is called, and the supplied message. +// If err is nil, Wrap returns nil. +func Wrap(err error, message string) error { + if err == nil { + return nil + } + return &wrapping{ + cause: err, + msg: message, + stack: callers(), + } +} + +// Wrapf returns an error annotating err with a stack trace +// at the point Wrapf is call, and the format specifier. +// If err is nil, Wrapf returns nil. +func Wrapf(err error, format string, args ...interface{}) error { + if err == nil { + return nil + } + return &wrapping{ + cause: err, + msg: fmt.Sprintf(format, args...), + stack: callers(), + } +} + +type wrapping struct { + cause error + msg string + stack *stack +} + +func (w *wrapping) Error() string { return w.msg + ": " + w.cause.Error() } +func (w *wrapping) Cause() error { return w.cause } + +func (w *wrapping) Format(s fmt.State, verb rune) { + switch verb { + case 'v': + if s.Flag('+') { + fmt.Fprintf(s, "%+v\n", w.Cause()) + io.WriteString(s, w.msg) + w.stack.Format(s, verb) + return + } + fallthrough + case 's', 'q': + io.WriteString(s, w.Error()) + } +} + +// RootCause returns the underlying cause of the error, if possible. +// An error value has a cause if it implements the following +// interface: +// +// type causer interface { +// Cause() error +// } +// +// If the error does not implement Cause, the original error will +// be returned. If the error is nil, nil will be returned without further +// investigation. +func RootCause(err error) error { + for { + cause := Cause(err) + if cause == nil { + return err + } + err = cause + } +} + +// +// Cause will return the immediate cause, if possible. +// An error value has a cause if it implements the following +// interface: +// +// type causer interface { +// Cause() error +// } +// If the error does not implement Cause, nil will be returned +func Cause(err error) error { + type causer interface { + Cause() error + } + + causerObj, ok := err.(causer) + if !ok { + return nil + } + + return causerObj.Cause() +} + // Equals returns true iff the error message and the code returned by Code() -// is equal. +// are equal. func Equals(a, b error) bool { if a == nil && b == nil { // Both are nil. return true } - if a == nil && b != nil || a != nil && b == nil { - // One of the two is nil. + if a == nil || b == nil { + // One of the two is nil, since we know both are not nil. return false } @@ -97,5 +272,5 @@ func Equals(a, b error) bool { // Print is meant to print the vtError object in test failures. // For comparing two vterrors, use Equals() instead. func Print(err error) string { - return fmt.Sprintf("%v: %v", Code(err), err.Error()) + return fmt.Sprintf("%v: %v\n", Code(err), err.Error()) }