Skip to content

Commit

Permalink
*: update tidb/tikv-client dependency to lastest (#1171) (#1258)
Browse files Browse the repository at this point in the history
close #1170
  • Loading branch information
lichunzhu authored Jul 3, 2023
1 parent 9f5e669 commit 6e8a30d
Show file tree
Hide file tree
Showing 28 changed files with 262 additions and 1,711 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
2 changes: 1 addition & 1 deletion drainer/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"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"
"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
20 changes: 10 additions & 10 deletions drainer/translator/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ import (
"time"

//nolint
"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"
"google.golang.org/protobuf/proto"

"github.com/pingcap/tidb-binlog/pkg/util"
)
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
28 changes: 14 additions & 14 deletions drainer/translator/kafka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import (
"fmt"

//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"
"google.golang.org/protobuf/proto"
)

type testKafkaSuite struct {
Expand Down Expand Up @@ -158,22 +158,18 @@ func (t *testKafkaSuite) TestGenTable(c *check.C) {
Columns: []*model.ColumnInfo{
{
Name: model.NewCIStr("c1"),
FieldType: types.FieldType{
Flag: mysql.PriKeyFlag,
Tp: mysql.TypeLong,
},
FieldType: types.NewFieldTypeBuilder().
SetFlag(mysql.PriKeyFlag).
SetType(mysql.TypeLong).
Build(),
},
{
Name: model.NewCIStr("c2"),
FieldType: types.FieldType{
Tp: mysql.TypeLong,
},
Name: model.NewCIStr("c2"),
FieldType: *types.NewFieldType(mysql.TypeLong),
},
{
Name: model.NewCIStr("c3"),
FieldType: types.FieldType{
Tp: mysql.TypeLong,
},
Name: model.NewCIStr("c3"),
FieldType: *types.NewFieldType(mysql.TypeLong),
},
},
Indices: []*model.IndexInfo{
Expand Down Expand Up @@ -227,10 +223,14 @@ func (t *testKafkaSuite) TestGenTable(c *check.C) {
{
Name: "c2",
MysqlType: "int",
Flen: types.UnspecifiedLength,
Decimal: types.UnspecifiedLength,
},
{
Name: "c3",
MysqlType: "int",
Flen: types.UnspecifiedLength,
Decimal: types.UnspecifiedLength,
},
},
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_test.go
Original file line number Diff line number Diff line change
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
14 changes: 7 additions & 7 deletions drainer/translator/pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import (
"time"

//nolint
"github.com/golang/protobuf/proto"
"github.com/pingcap/errors"
"github.com/pingcap/tidb/parser/model"
"github.com/pingcap/tidb/sessionctx/stmtctx"
"github.com/pingcap/tidb/tablecodec"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/codec"
tipb "github.com/pingcap/tipb/go-binlog"
"google.golang.org/protobuf/proto"

"github.com/pingcap/tidb-binlog/pkg/loader"
"github.com/pingcap/tidb-binlog/pkg/util"
Expand Down 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
62 changes: 31 additions & 31 deletions drainer/translator/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,53 +212,53 @@ func testGenTable(tt string) *model.TableInfo {
ID: 1,
Name: model.NewCIStr("ID"),
Offset: 0,
FieldType: types.FieldType{
Tp: mysql.TypeLong,
Flag: mysql.BinaryFlag,
Flen: 11,
Decimal: -1,
Charset: "binary",
Collate: "binary",
},
FieldType: types.NewFieldTypeBuilder().
SetType(mysql.TypeLong).
SetFlag(mysql.BinaryFlag).
SetFlen(11).
SetDecimal(-1).
SetCharset("binary").
SetCollate("binary").
Build(),
State: model.StatePublic,
}

userNameCol := &model.ColumnInfo{
ID: 2,
Name: model.NewCIStr("NAME"),
Offset: 1,
FieldType: types.FieldType{
Tp: mysql.TypeVarchar,
Flag: 0,
Flen: 45,
Decimal: -1,
Charset: "utf8",
Collate: "utf8_unicode_ci",
},
FieldType: types.NewFieldTypeBuilder().
SetType(mysql.TypeVarchar).
SetFlag(0).
SetFlen(45).
SetDecimal(-1).
SetCharset("utf8").
SetCollate("utf8_unicode_ci").
Build(),
State: model.StatePublic,
}

sexCol := &model.ColumnInfo{
ID: 3,
Name: model.NewCIStr("SEX"),
Offset: 2,
FieldType: types.FieldType{
Tp: mysql.TypeEnum,
Flag: mysql.BinaryFlag,
Flen: -1,
Decimal: -1,
Charset: "binary",
Collate: "binary",
Elems: []string{"male", "female"},
},
FieldType: types.NewFieldTypeBuilder().
SetType(mysql.TypeEnum).
SetFlag(mysql.BinaryFlag).
SetFlen(-1).
SetDecimal(-1).
SetCharset("binary").
SetCollate("binary").
SetElems([]string{"male", "female"}).
Build(),
State: model.StatePublic,
}

t.Columns = []*model.ColumnInfo{userIDCol, userNameCol, sexCol}

switch tt {
case "hasID":
userIDCol.Flag = mysql.NotNullFlag | mysql.PriKeyFlag | mysql.BinaryFlag | mysql.NoDefaultValueFlag
userIDCol.SetFlag(mysql.NotNullFlag | mysql.PriKeyFlag | mysql.BinaryFlag | mysql.NoDefaultValueFlag)

t.PKIsHandle = true
t.Indices = append(t.Indices, &model.IndexInfo{
Expand All @@ -267,8 +267,8 @@ func testGenTable(tt string) *model.TableInfo {
})

case "hasPK":
userIDCol.Flag = mysql.NotNullFlag | mysql.PriKeyFlag | mysql.BinaryFlag | mysql.NoDefaultValueFlag | mysql.UniqueKeyFlag
userNameCol.Flag = mysql.NotNullFlag | mysql.PriKeyFlag | mysql.NoDefaultValueFlag
userIDCol.SetFlag(mysql.NotNullFlag | mysql.PriKeyFlag | mysql.BinaryFlag | mysql.NoDefaultValueFlag | mysql.UniqueKeyFlag)
userNameCol.SetFlag(mysql.NotNullFlag | mysql.PriKeyFlag | mysql.NoDefaultValueFlag)

t.Indices = append(t.Indices, &model.IndexInfo{
Primary: true,
Expand Down Expand Up @@ -307,9 +307,9 @@ func testGenDeleteBinlog(c *check.C, t *model.TableInfo, r []types.Datum) []byte
func testGenDatum(c *check.C, col *model.ColumnInfo, base int) (types.Datum, interface{}) {
var d types.Datum
var e interface{}
switch col.Tp {
switch col.GetType() {
case mysql.TypeTiny, mysql.TypeInt24, mysql.TypeShort, mysql.TypeLong, mysql.TypeLonglong, mysql.TypeYear:
if mysql.HasUnsignedFlag(col.Flag) {
if mysql.HasUnsignedFlag(col.GetFlag()) {
d.SetUint64(uint64(base))
e = int64(base)
} else {
Expand Down Expand Up @@ -419,5 +419,5 @@ func testGenUpdateBinlog(c *check.C, t *model.TableInfo, oldData []types.Datum,
}

func testIsPKHandleColumn(table *model.TableInfo, column *model.ColumnInfo) bool {
return mysql.HasPriKeyFlag(column.Flag) && table.PKIsHandle
return mysql.HasPriKeyFlag(column.GetFlag()) && table.PKIsHandle
}
Loading

0 comments on commit 6e8a30d

Please sign in to comment.