Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drainer: fix failure to update BIT columns with downstream TiDB when message passes through Kafka #667

Merged
merged 14 commits into from
Jul 13, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions pkg/loader/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
package loader

import (
"github.com/pingcap/log"
pb "github.com/pingcap/tidb-tools/tidb-binlog/slave_binlog_proto/go-binlog"
. "github.com/pingcap/tidb/types"
types "github.com/pingcap/tidb/types"
july2993 marked this conversation as resolved.
Show resolved Hide resolved
)

// SlaveBinlogToTxn translate the Binlog format into Txn
Expand Down Expand Up @@ -85,8 +86,15 @@ func columnToArg(mysqlType string, c *pb.Column) (arg interface{}) {
var str string = string(c.GetBytesValue())
return str
}
// issues: TOOL-1346 and TOOL-1374
// for downstream = mysql
// it work for tidb to update binary by translating []byte to uint64
july2993 marked this conversation as resolved.
Show resolved Hide resolved
if mysqlType == "bit" {
val, _ := BinaryLiteral(c.GetBytesValue()).ToInt(nil)
val, err := types.BinaryLiteral(c.GetBytesValue()).ToInt(nil)
july2993 marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
log.S().Error(err)
return nil
}
return val
}
return c.GetBytesValue()
Expand Down
3 changes: 3 additions & 0 deletions tests/dailytest/case.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ var case2Clean = []string{`
DROP TABLE binlog_case2`,
}

// Table name changed in TOOL-1346
july2993 marked this conversation as resolved.
Show resolved Hide resolved
var case3 = []string{`
CREATE TABLE binlog_case3(id INT PRIMARY KEY, a1 INT);
`,
Expand All @@ -120,6 +121,8 @@ var case3Clean = []string{
`DROP TABLE binlog_case3`,
}

july2993 marked this conversation as resolved.
Show resolved Hide resolved
// Ref issue: TOOL-1346
// test bit value synchronization for drainer -> mysql and drainer -> kafka -> mysql
july2993 marked this conversation as resolved.
Show resolved Hide resolved
var case4 = []string{`
lichunzhu marked this conversation as resolved.
Show resolved Hide resolved
CREATE TABLE binlog_case4(a BIT(1) NOT NULL);
`,
Expand Down