Skip to content

Commit

Permalink
open gomod, and update pkg (#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
WangXiangUSTC authored Feb 20, 2019
1 parent a265f6e commit 1a2a892
Show file tree
Hide file tree
Showing 2,096 changed files with 72 additions and 896,955 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ path_to_add := $(addsuffix /bin,$(subst :,/bin:,$(GOPATH)))
export PATH := $(path_to_add):$(PATH)

GO := go
GOBUILD := GO111MODULE=off CGO_ENABLED=0 $(GO) build $(BUILD_FLAG)
GOTEST := GO111MODULE=off CGO_ENABLED=1 $(GO) test -p 3
GOBUILD := GO111MODULE=on CGO_ENABLED=0 $(GO) build $(BUILD_FLAG)
GOTEST := GO111MODULE=on CGO_ENABLED=1 $(GO) test -p 3

ARCH := "`uname -s`"
LINUX := "Linux"
Expand Down
2 changes: 1 addition & 1 deletion drainer/binlog_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package drainer
import (
"fmt"

"github.com/pingcap/tidb/model"
"github.com/pingcap/parser/model"
pb "github.com/pingcap/tipb/go-binlog"
)

Expand Down
2 changes: 1 addition & 1 deletion drainer/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (

"github.com/ngaut/log"
"github.com/pingcap/errors"
"github.com/pingcap/parser/model"
"github.com/pingcap/tidb-binlog/drainer/checkpoint"
"github.com/pingcap/tidb-binlog/pkg/etcd"
"github.com/pingcap/tidb-binlog/pkg/flags"
"github.com/pingcap/tidb-binlog/pkg/node"
"github.com/pingcap/tidb-binlog/pkg/util"
"github.com/pingcap/tidb-binlog/pump"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/model"
"github.com/pingcap/tidb/session"
"github.com/pingcap/tidb/store/tikv"
"github.com/pingcap/tidb/store/tikv/oracle"
Expand Down
2 changes: 1 addition & 1 deletion drainer/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/ngaut/log"
"github.com/pingcap/errors"
"github.com/pingcap/tidb/model"
"github.com/pingcap/parser/model"
"github.com/pingcap/tidb/mysql"
)

Expand Down
2 changes: 1 addition & 1 deletion drainer/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

. "github.com/pingcap/check"
"github.com/pingcap/errors"
"github.com/pingcap/tidb/model"
"github.com/pingcap/parser/model"
"github.com/pingcap/tidb/mysql"
"github.com/pingcap/tidb/types"
)
Expand Down
4 changes: 2 additions & 2 deletions drainer/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import (
"github.com/gorilla/mux"
"github.com/ngaut/log"
"github.com/pingcap/errors"
"github.com/pingcap/pd/pd-client"
"github.com/pingcap/parser/model"
"github.com/pingcap/pd/client"
"github.com/pingcap/tidb-binlog/drainer/checkpoint"
"github.com/pingcap/tidb-binlog/pkg/flags"
"github.com/pingcap/tidb-binlog/pkg/node"
"github.com/pingcap/tidb-binlog/pkg/util"
"github.com/pingcap/tidb/model"
"github.com/pingcap/tidb/store/tikv/oracle"
"github.com/pingcap/tipb/go-binlog"
"github.com/prometheus/client_golang/prometheus"
Expand Down
2 changes: 1 addition & 1 deletion drainer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (

"github.com/ngaut/log"
"github.com/pingcap/errors"
"github.com/pingcap/parser/model"
"github.com/pingcap/tidb-binlog/drainer/checkpoint"
"github.com/pingcap/tidb-binlog/drainer/executor"
"github.com/pingcap/tidb-binlog/drainer/translator"
"github.com/pingcap/tidb-binlog/pkg/loader"
pkgsql "github.com/pingcap/tidb-binlog/pkg/sql"
"github.com/pingcap/tidb/model"
"github.com/pingcap/tidb/store/tikv/oracle"
pb "github.com/pingcap/tipb/go-binlog"
)
Expand Down
2 changes: 1 addition & 1 deletion drainer/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package drainer

import (
. "github.com/pingcap/check"
"github.com/pingcap/tidb/model"
"github.com/pingcap/parser/model"
"github.com/pingcap/tidb/mysql"
"github.com/pingcap/tidb/types"
)
Expand Down
9 changes: 4 additions & 5 deletions drainer/translator/flash.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (

"github.com/ngaut/log"
"github.com/pingcap/errors"
"github.com/pingcap/parser"
"github.com/pingcap/parser/ast"
"github.com/pingcap/parser/model"
"github.com/pingcap/tidb-binlog/pkg/dml"
"github.com/pingcap/tidb-binlog/pkg/util"
"github.com/pingcap/tidb/ast"
"github.com/pingcap/tidb/model"
"github.com/pingcap/tidb/mysql"
"github.com/pingcap/tidb/parser"
"github.com/pingcap/tidb/tablecodec"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/codec"
Expand Down Expand Up @@ -211,12 +211,11 @@ func (f *flashTranslator) GenDeleteSQLs(schema string, table *model.TableInfo, r

func (f *flashTranslator) GenDDLSQL(sql string, schema string, commitTS int64) (string, error) {
schema = strings.ToLower(schema)
stmts, err := parser.New().Parse(sql, "", "")
stmt, err := parser.New().ParseOneStmt(sql, "", "")
if err != nil {
return "", errors.Trace(err)
}

stmt := stmts[0]
switch stmt.(type) {
case *ast.CreateDatabaseStmt:
createDatabaseStmt, _ := stmt.(*ast.CreateDatabaseStmt)
Expand Down
5 changes: 3 additions & 2 deletions drainer/translator/flash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"time"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/model"
"github.com/pingcap/parser/model"
"github.com/pingcap/tidb/mysql"
"github.com/pingcap/tidb/sessionctx/stmtctx"
"github.com/pingcap/tidb/tablecodec"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/types/json"
_ "github.com/pingcap/tidb/types/parser_driver"
"github.com/pingcap/tidb/util/codec"
)

Expand Down Expand Up @@ -478,7 +479,7 @@ func (t *testTranslatorSuite) TestFlashFormatData(c *C) {
c.Assert(err, IsNil)
check(mysql.TypeBit, types.NewMysqlBitDatum(bl), uint64(5))
// Duration.
d, err := types.ParseDuration("101:10:11", 1)
d, err := types.ParseDuration(new(stmtctx.StatementContext), "101:10:11", 1)
c.Assert(err, IsNil)
check(mysql.TypeDuration, types.NewDurationDatum(d), int64(1011011))
// Time types.
Expand Down
19 changes: 10 additions & 9 deletions drainer/translator/flash_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (

"github.com/ngaut/log"
"github.com/pingcap/errors"
"github.com/pingcap/tidb/ast"
"github.com/pingcap/tidb/model"
"github.com/pingcap/parser/ast"
"github.com/pingcap/parser/model"
"github.com/pingcap/parser/opcode"
"github.com/pingcap/tidb/mysql"
"github.com/pingcap/tidb/parser/opcode"
"github.com/pingcap/tidb/sessionctx/stmtctx"
"github.com/pingcap/tidb/tablecodec"
"github.com/pingcap/tidb/types"
Expand Down Expand Up @@ -264,8 +264,9 @@ func formatFlashLiteral(expr ast.ExprNode, ft *types.FieldType) (string, bool, e
shouldQuote = true
}
switch e := expr.(type) {
case *ast.ValueExpr:
value := *e.GetDatum()
case ast.ValueExpr:
value := new(types.Datum)
value.SetValue(e.GetValue())
if value.GetValue() == nil {
return "NULL", false, nil
}
Expand All @@ -276,7 +277,7 @@ func formatFlashLiteral(expr ast.ExprNode, ft *types.FieldType) (string, bool, e
// TiDB doesn't allow default value for JSON types, and doesn't have Geometry at all.
default:
// Do conversion.
converted, err := convertValueType(value, expr.GetType(), ft)
converted, err := convertValueType(*value, expr.GetType(), ft)
if err != nil {
return "", false, errors.Trace(err)
}
Expand Down Expand Up @@ -381,11 +382,11 @@ func convertValueType(data types.Datum, source *types.FieldType, target *types.F
var err error
switch source.Tp {
case mysql.TypeVarchar, mysql.TypeTinyBlob, mysql.TypeMediumBlob, mysql.TypeLongBlob, mysql.TypeBlob, mysql.TypeVarString, mysql.TypeString:
duration, err = types.ParseDuration(data.GetString(), 0)
duration, err = types.ParseDuration(new(stmtctx.StatementContext), data.GetString(), 0)
case mysql.TypeTiny, mysql.TypeShort, mysql.TypeLong, mysql.TypeLonglong, mysql.TypeInt24:
duration, err = types.ParseDuration(fmt.Sprintf("%v", data.GetInt64()), 0)
duration, err = types.ParseDuration(new(stmtctx.StatementContext), fmt.Sprintf("%v", data.GetInt64()), 0)
case mysql.TypeFloat, mysql.TypeDouble, mysql.TypeNewDecimal:
duration, err = types.ParseDuration(data.GetMysqlDecimal().String(), 0)
duration, err = types.ParseDuration(new(stmtctx.StatementContext), data.GetMysqlDecimal().String(), 0)
}
if err != nil {
return nil, errors.Trace(err)
Expand Down
2 changes: 1 addition & 1 deletion drainer/translator/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"github.com/golang/protobuf/proto"
"github.com/ngaut/log"
"github.com/pingcap/errors"
"github.com/pingcap/parser/model"
"github.com/pingcap/tidb-binlog/pkg/util"
obinlog "github.com/pingcap/tidb-tools/tidb-binlog/slave_binlog_proto/go-binlog"
"github.com/pingcap/tidb/model"
"github.com/pingcap/tidb/mysql"
"github.com/pingcap/tidb/tablecodec"
"github.com/pingcap/tidb/types"
Expand Down
9 changes: 4 additions & 5 deletions drainer/translator/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
"time"

"github.com/pingcap/errors"
"github.com/pingcap/parser"
"github.com/pingcap/parser/ast"
"github.com/pingcap/parser/model"
"github.com/pingcap/tidb-binlog/pkg/dml"
"github.com/pingcap/tidb-binlog/pkg/util"
"github.com/pingcap/tidb/ast"
"github.com/pingcap/tidb/model"
"github.com/pingcap/tidb/mysql"
"github.com/pingcap/tidb/parser"
"github.com/pingcap/tidb/tablecodec"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/codec"
Expand Down Expand Up @@ -292,12 +292,11 @@ func (m *mysqlTranslator) genDeleteSQL(schema string, table *model.TableInfo, co
}

func (m *mysqlTranslator) GenDDLSQL(sql string, schema string, commitTS int64) (string, error) {
stmts, err := parser.New().Parse(sql, "", "")
stmt, err := parser.New().ParseOneStmt(sql, "", "")
if err != nil {
return "", errors.Trace(err)
}

stmt := stmts[0]
_, isCreateDatabase := stmt.(*ast.CreateDatabaseStmt)
if isCreateDatabase {
return fmt.Sprintf("%s;", sql), nil
Expand Down
9 changes: 4 additions & 5 deletions drainer/translator/pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (

"github.com/golang/protobuf/proto"
"github.com/pingcap/errors"
"github.com/pingcap/parser"
"github.com/pingcap/parser/ast"
"github.com/pingcap/parser/model"
"github.com/pingcap/tidb-binlog/pkg/util"
pb "github.com/pingcap/tidb-binlog/proto/binlog"
"github.com/pingcap/tidb/ast"
"github.com/pingcap/tidb/model"
"github.com/pingcap/tidb/mysql"
"github.com/pingcap/tidb/parser"
"github.com/pingcap/tidb/sessionctx/stmtctx"
"github.com/pingcap/tidb/tablecodec"
"github.com/pingcap/tidb/types"
Expand Down Expand Up @@ -206,12 +206,11 @@ func (p *pbTranslator) GenDeleteSQLs(schema string, table *model.TableInfo, rows
}

func (p *pbTranslator) GenDDLSQL(sql string, schema string, commitTS int64) (string, error) {
stmts, err := parser.New().Parse(sql, "", "")
stmt, err := parser.New().ParseOneStmt(sql, "", "")
if err != nil {
return "", errors.Trace(err)
}

stmt := stmts[0]
_, isCreateDatabase := stmt.(*ast.CreateDatabaseStmt)
if isCreateDatabase {
return fmt.Sprintf("%s;", sql), nil
Expand Down
2 changes: 1 addition & 1 deletion drainer/translator/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package translator
import (
"github.com/ngaut/log"
"github.com/pingcap/errors"
"github.com/pingcap/tidb/model"
"github.com/pingcap/parser/model"
)

// OpType represents type of the operation
Expand Down
4 changes: 2 additions & 2 deletions drainer/translator/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/model"
"github.com/pingcap/parser/model"
"github.com/pingcap/tidb/mysql"
"github.com/pingcap/tidb/sessionctx/stmtctx"
"github.com/pingcap/tidb/tablecodec"
Expand Down Expand Up @@ -267,7 +267,7 @@ func testGenDatum(c *C, col *model.ColumnInfo, base int) (types.Datum, interface
d.SetBytes([]byte(val))
e = []byte(val)
case mysql.TypeDuration:
duration, err := types.ParseDuration("10:10:10", 0)
duration, err := types.ParseDuration(new(stmtctx.StatementContext), "10:10:10", 0)
c.Assert(err, IsNil)
d.SetMysqlDuration(duration)
e = "10:10:10"
Expand Down
2 changes: 1 addition & 1 deletion drainer/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
"github.com/Shopify/sarama"
"github.com/ngaut/log"
"github.com/pingcap/errors"
"github.com/pingcap/parser/model"
"github.com/pingcap/tidb-binlog/drainer/checkpoint"
"github.com/pingcap/tidb-binlog/drainer/executor"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/meta"
"github.com/pingcap/tidb/model"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion drainer/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/go-sql-driver/mysql"
. "github.com/pingcap/check"
"github.com/pingcap/parser/model"
"github.com/pingcap/tidb-binlog/pkg/sql"
"github.com/pingcap/tidb/model"
)

func (t *testDrainerSuite) TestIgnoreDDLError(c *C) {
Expand Down
Loading

0 comments on commit 1a2a892

Please sign in to comment.