Skip to content

Commit

Permalink
*: update tidb/tikv-client dependency to lastest (#1171)
Browse files Browse the repository at this point in the history
close #1170
  • Loading branch information
lichunzhu authored Jun 23, 2022
1 parent b0214a2 commit 7a48b61
Show file tree
Hide file tree
Showing 34 changed files with 488 additions and 270 deletions.
2 changes: 1 addition & 1 deletion arbiter/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/pingcap/log"
"github.com/pingcap/tidb-binlog/pkg/loader"
"github.com/pingcap/tidb-binlog/pkg/util"
"github.com/pingcap/tidb-tools/tidb-binlog/driver/reader"
"github.com/pingcap/tidb/tidb-binlog/driver/reader"
"github.com/tikv/client-go/v2/oracle"
"go.uber.org/zap"
)
Expand Down
4 changes: 2 additions & 2 deletions arbiter/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
. "github.com/pingcap/check"
"github.com/pingcap/errors"
"github.com/pingcap/tidb-binlog/pkg/loader"
"github.com/pingcap/tidb-tools/tidb-binlog/driver/reader"
pb "github.com/pingcap/tidb-tools/tidb-binlog/proto/go-binlog"
"github.com/pingcap/tidb/tidb-binlog/driver/reader"
pb "github.com/pingcap/tidb/tidb-binlog/proto/go-binlog"
)

type dummyLoader struct {
Expand Down
5 changes: 2 additions & 3 deletions drainer/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ package drainer
import (
"database/sql"

router "github.com/pingcap/tidb-tools/pkg/table-router"

"github.com/pingcap/errors"
"github.com/pingcap/log"
"github.com/pingcap/tidb-binlog/drainer/checkpoint"
"github.com/pingcap/tidb-binlog/drainer/relay"
"github.com/pingcap/tidb-binlog/drainer/sync"
"github.com/pingcap/tidb-binlog/pkg/loader"
obinlog "github.com/pingcap/tidb-tools/tidb-binlog/proto/go-binlog"
obinlog "github.com/pingcap/tidb/tidb-binlog/proto/go-binlog"
router "github.com/pingcap/tidb/util/table-router"
"go.uber.org/zap"
)

Expand Down
2 changes: 1 addition & 1 deletion drainer/relay/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/pingcap/errors"
"github.com/pingcap/log"
"github.com/pingcap/tidb-binlog/pkg/binlogfile"
obinlog "github.com/pingcap/tidb-tools/tidb-binlog/proto/go-binlog"
obinlog "github.com/pingcap/tidb/tidb-binlog/proto/go-binlog"
"github.com/pingcap/tipb/go-binlog"
)

Expand Down
2 changes: 1 addition & 1 deletion drainer/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ func addImplicitColumn(table *model.TableInfo) {
ID: implicitColID,
Name: model.NewCIStr(implicitColName),
}
newColumn.Tp = mysql.TypeInt24
newColumn.SetType(mysql.TypeInt24)
table.Columns = append(table.Columns, newColumn)

newIndex := &model.IndexInfo{
Expand Down
2 changes: 1 addition & 1 deletion drainer/sync/bench_kafka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"testing"

"github.com/gogo/protobuf/proto"
obinlog "github.com/pingcap/tidb-tools/tidb-binlog/proto/go-binlog"
obinlog "github.com/pingcap/tidb/tidb-binlog/proto/go-binlog"
ti "github.com/pingcap/tipb/go-binlog"
)

Expand Down
2 changes: 1 addition & 1 deletion drainer/sync/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/Shopify/sarama"
"github.com/pingcap/errors"
"github.com/pingcap/log"
obinlog "github.com/pingcap/tidb-tools/tidb-binlog/proto/go-binlog"
obinlog "github.com/pingcap/tidb/tidb-binlog/proto/go-binlog"
"go.uber.org/zap"

"github.com/pingcap/tidb-binlog/drainer/translator"
Expand Down
2 changes: 1 addition & 1 deletion drainer/sync/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (

"github.com/pingcap/errors"
"github.com/pingcap/log"
"github.com/pingcap/tidb-tools/pkg/dbutil"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/dbutil"
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/zap"

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

"github.com/pingcap/errors"
"github.com/pingcap/log"
router "github.com/pingcap/tidb-tools/pkg/table-router"
router "github.com/pingcap/tidb/util/table-router"
"github.com/prometheus/client_golang/prometheus"

"github.com/pingcap/tidb-binlog/drainer/relay"
Expand Down
2 changes: 1 addition & 1 deletion drainer/sync/oracle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ package sync
import (
"time"

router "github.com/pingcap/tidb-tools/pkg/table-router"
"github.com/pingcap/tidb/parser/model"
router "github.com/pingcap/tidb/util/table-router"

"github.com/DATA-DOG/go-sqlmock"
"github.com/pingcap/check"
Expand Down
4 changes: 2 additions & 2 deletions drainer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import (
"github.com/pingcap/errors"
"github.com/pingcap/log"
bf "github.com/pingcap/tidb-tools/pkg/binlog-filter"
baf "github.com/pingcap/tidb-tools/pkg/filter"
router "github.com/pingcap/tidb-tools/pkg/table-router"
"github.com/pingcap/tidb/br/pkg/logutil"
"github.com/pingcap/tidb/parser"
"github.com/pingcap/tidb/parser/model"
baf "github.com/pingcap/tidb/util/filter"
router "github.com/pingcap/tidb/util/table-router"
"github.com/pingcap/tipb/go-binlog"
pb "github.com/pingcap/tipb/go-binlog"
"github.com/tikv/client-go/v2/oracle"
Expand Down
18 changes: 9 additions & 9 deletions drainer/translator/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (
"github.com/golang/protobuf/proto"
"github.com/pingcap/errors"
"github.com/pingcap/log"
obinlog "github.com/pingcap/tidb-tools/tidb-binlog/proto/go-binlog"
"github.com/pingcap/tidb/parser/model"
"github.com/pingcap/tidb/parser/mysql"
"github.com/pingcap/tidb/tablecodec"
obinlog "github.com/pingcap/tidb/tidb-binlog/proto/go-binlog"
"github.com/pingcap/tidb/types"
pb "github.com/pingcap/tipb/go-binlog"
"go.uber.org/zap"
Expand Down Expand Up @@ -102,10 +102,10 @@ func genTable(schema string, tableInfo *model.TableInfo) (table *obinlog.Table)
for _, col := range tableInfo.Columns {
info := new(obinlog.ColumnInfo)
info.Name = col.Name.O
info.MysqlType = types.TypeToStr(col.Tp, col.Charset)
info.Flen = int32(col.Flen)
info.Decimal = int32(col.Decimal)
info.IsPrimaryKey = mysql.HasPriKeyFlag(col.Flag)
info.MysqlType = types.TypeToStr(col.GetType(), col.GetCharset())
info.Flen = int32(col.GetFlen())
info.Decimal = int32(col.GetDecimal())
info.IsPrimaryKey = mysql.HasPriKeyFlag(col.GetFlag())
columnInfos = append(columnInfos, info)
}
table.ColumnInfo = columnInfos
Expand Down Expand Up @@ -232,7 +232,7 @@ func DatumToColumn(colInfo *model.ColumnInfo, datum types.Datum) (col *obinlog.C
return
}

switch types.TypeToStr(colInfo.Tp, colInfo.Charset) {
switch types.TypeToStr(colInfo.GetType(), colInfo.GetCharset()) {
// date and time type
case "date", "datetime", "time", "timestamp", "year":
str := fmt.Sprintf("%v", datum.GetValue())
Expand All @@ -242,7 +242,7 @@ func DatumToColumn(colInfo *model.ColumnInfo, datum types.Datum) (col *obinlog.C
// https://dev.mysql.com/doc/refman/8.0/en/integer-types.html
case "int", "bigint", "smallint", "tinyint", "mediumint":
str := fmt.Sprintf("%v", datum.GetValue())
if mysql.HasUnsignedFlag(colInfo.Flag) {
if mysql.HasUnsignedFlag(colInfo.GetFlag()) {
val, err := strconv.ParseUint(str, 10, 64)
if err != nil {
log.Fatal("ParseUint failed", zap.String("str", str), zap.Error(err))
Expand Down Expand Up @@ -276,15 +276,15 @@ func DatumToColumn(colInfo *model.ColumnInfo, datum types.Datum) (col *obinlog.C

// TiDB don't suppose now
case "geometry":
log.Warn("unknown mysql type", zap.Uint8("type", colInfo.Tp))
log.Warn("unknown mysql type", zap.Uint8("type", colInfo.GetType()))
str := fmt.Sprintf("%v", datum.GetValue())
col.StringValue = proto.String(str)

case "json":
col.BytesValue = []byte(datum.GetMysqlJSON().String())

default:
log.Warn("unknown mysql type", zap.Uint8("type", colInfo.Tp))
log.Warn("unknown mysql type", zap.Uint8("type", colInfo.GetType()))
str := fmt.Sprintf("%v", datum.GetValue())
col.StringValue = proto.String(str)

Expand Down
40 changes: 26 additions & 14 deletions drainer/translator/kafka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
//nolint
"github.com/golang/protobuf/proto"
"github.com/pingcap/check"
obinlog "github.com/pingcap/tidb-tools/tidb-binlog/proto/go-binlog"
"github.com/pingcap/tidb/parser/model"
"github.com/pingcap/tidb/parser/mysql"
obinlog "github.com/pingcap/tidb/tidb-binlog/proto/go-binlog"
"github.com/pingcap/tidb/types"
)

Expand Down Expand Up @@ -153,27 +153,33 @@ func (t *testKafkaSuite) TestGenTable(c *check.C) {
// primary key: (c1)
// unique key: (c2, c3)
// non-unique key: (c3)
tp1 := types.NewFieldType(mysql.TypeLong)
tp1.SetFlag(mysql.PriKeyFlag)
tp1.SetFlen(11)
tp1.SetDecimal(1)

tp2 := types.NewFieldType(mysql.TypeLong)
tp2.SetFlen(12)
tp2.SetDecimal(2)

tp3 := types.NewFieldType(mysql.TypeLong)
tp3.SetFlen(13)
tp3.SetDecimal(3)

info := &model.TableInfo{
Name: model.NewCIStr(table),
Columns: []*model.ColumnInfo{
{
Name: model.NewCIStr("c1"),
FieldType: types.FieldType{
Flag: mysql.PriKeyFlag,
Tp: mysql.TypeLong,
},
Name: model.NewCIStr("c1"),
FieldType: *tp1,
},
{
Name: model.NewCIStr("c2"),
FieldType: types.FieldType{
Tp: mysql.TypeLong,
},
Name: model.NewCIStr("c2"),
FieldType: *tp2,
},
{
Name: model.NewCIStr("c3"),
FieldType: types.FieldType{
Tp: mysql.TypeLong,
},
Name: model.NewCIStr("c3"),
FieldType: *tp3,
},
},
Indices: []*model.IndexInfo{
Expand Down Expand Up @@ -223,14 +229,20 @@ func (t *testKafkaSuite) TestGenTable(c *check.C) {
Name: "c1",
IsPrimaryKey: true,
MysqlType: "int",
Flen: 11,
Decimal: 1,
},
{
Name: "c2",
MysqlType: "int",
Flen: 12,
Decimal: 2,
},
{
Name: "c3",
MysqlType: "int",
Flen: 13,
Decimal: 3,
},
},
UniqueKeys: []*obinlog.Key{
Expand Down
4 changes: 2 additions & 2 deletions drainer/translator/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func formatData(data types.Datum, ft types.FieldType, destDBType loader.DBType)
return data, nil
}

switch ft.Tp {
switch ft.GetType() {
case mysql.TypeDate, mysql.TypeDatetime, mysql.TypeNewDate, mysql.TypeTimestamp, mysql.TypeNewDecimal, mysql.TypeJSON:
data = types.NewDatum(fmt.Sprintf("%v", data.GetValue()))
case mysql.TypeDuration:
Expand Down Expand Up @@ -285,7 +285,7 @@ func formatData(data types.Datum, ft types.FieldType, destDBType loader.DBType)
}

func isBlob(ft types.FieldType) bool {
stype := types.TypeToStr(ft.Tp, ft.Charset)
stype := types.TypeToStr(ft.GetType(), ft.GetCharset())
switch stype {
case "blob", "tinyblob", "mediumblob", "longblob":
return true
Expand Down
2 changes: 1 addition & 1 deletion drainer/translator/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func checkMysqlColumn(c *check.C, col *model.ColumnInfo, myValue interface{}, da
tiStr, err := datum.ToString()
c.Assert(err, check.IsNil)

if col.Tp == mysql.TypeEnum {
if col.GetType() == mysql.TypeEnum {
tiStr = fmt.Sprintf("%d", datum.GetInt64())
}

Expand Down
2 changes: 1 addition & 1 deletion drainer/translator/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"time"

"github.com/pingcap/errors"
router "github.com/pingcap/tidb-tools/pkg/table-router"
"github.com/pingcap/tidb/parser/model"
router "github.com/pingcap/tidb/util/table-router"
tipb "github.com/pingcap/tipb/go-binlog"

"github.com/pingcap/tidb-binlog/pkg/loader"
Expand Down
4 changes: 2 additions & 2 deletions drainer/translator/oracle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (

"github.com/pingcap/check"
"github.com/pingcap/tidb-binlog/pkg/loader"
router "github.com/pingcap/tidb-tools/pkg/table-router"
"github.com/pingcap/tidb/parser/model"
"github.com/pingcap/tidb/parser/mysql"
"github.com/pingcap/tidb/types"
router "github.com/pingcap/tidb/util/table-router"
)

type testOracleSuite struct {
Expand Down Expand Up @@ -114,7 +114,7 @@ func checkOracleColumn(c *check.C, col *model.ColumnInfo, myValue interface{}, d
tiStr, err := datum.ToString()
c.Assert(err, check.IsNil)

if col.Tp == mysql.TypeEnum {
if col.GetType() == mysql.TypeEnum {
tiStr = fmt.Sprintf("%d", datum.GetInt64())
}

Expand Down
12 changes: 6 additions & 6 deletions drainer/translator/pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ func genInsert(schema string, ptable, table *model.TableInfo, row []byte) (event

for _, col := range columns {
cols = append(cols, col.Name.O)
tps = append(tps, col.Tp)
mysqlTypes = append(mysqlTypes, types.TypeToStr(col.Tp, col.Charset))
tps = append(tps, col.GetType())
mysqlTypes = append(mysqlTypes, types.TypeToStr(col.GetType(), col.GetCharset()))
val, ok := columnValues[col.ID]
if !ok {
val = getDefaultOrZeroValue(ptable, col)
Expand Down Expand Up @@ -185,8 +185,8 @@ func genUpdate(schema string, ptable, table *model.TableInfo, row []byte, canApp
oldVals = append(oldVals, oldValue)
newVals = append(newVals, newValue)
cols = append(cols, col.Name.O)
tps = append(tps, col.Tp)
mysqlTypes = append(mysqlTypes, types.TypeToStr(col.Tp, col.Charset))
tps = append(tps, col.GetType())
mysqlTypes = append(mysqlTypes, types.TypeToStr(col.GetType(), col.GetCharset()))
}
}

Expand Down Expand Up @@ -224,8 +224,8 @@ func genDelete(schema string, table *model.TableInfo, row []byte) (event *pb.Eve
}
vals = append(vals, value)
cols = append(cols, col.Name.O)
tps = append(tps, col.Tp)
mysqlTypes = append(mysqlTypes, types.TypeToStr(col.Tp, col.Charset))
tps = append(tps, col.GetType())
mysqlTypes = append(mysqlTypes, types.TypeToStr(col.GetType(), col.GetCharset()))
}
}

Expand Down
Loading

0 comments on commit 7a48b61

Please sign in to comment.