Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
syncer, binlog: set all UseDecimal to false (#1863) (#1864)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Jul 13, 2021
1 parent 5f11c3f commit 1f0ca8b
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 18 deletions.
4 changes: 3 additions & 1 deletion pkg/binlog/common/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ var (
// SetDefaultReplicationCfg sets some default value for BinlogSyncerConfig
// Note: retryCount should be greater than 0, set retryCount = 1 if you want to disable retry sync.
func SetDefaultReplicationCfg(cfg *replication.BinlogSyncerConfig, retryCount int) {
cfg.UseDecimal = true // must set true. ref: https://github.com/pingcap/tidb-enterprise-tools/pull/272
// after https://github.com/go-mysql-org/go-mysql/pull/598 we could use `false` to improve performance without
// losing precision.
cfg.UseDecimal = false
cfg.VerifyChecksum = true
cfg.MaxReconnectAttempts = retryCount
if retryCount == 1 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/binlog/reader/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (s *FileReaderStatus) String() string {
func NewFileReader(cfg *FileReaderConfig) Reader {
parser := replication.NewBinlogParser()
parser.SetVerifyChecksum(true)
parser.SetUseDecimal(true)
parser.SetUseDecimal(false)
parser.SetRawMode(cfg.EnableRawMode)
if cfg.Timezone != nil {
parser.SetTimestampStringLocation(cfg.Timezone)
Expand Down
4 changes: 2 additions & 2 deletions pkg/binlog/reader/tcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (t *testTCPReaderSuite) TestSyncPos(c *C) {
Port: uint16(t.port),
User: t.user,
Password: t.password,
UseDecimal: true,
UseDecimal: false,
VerifyChecksum: true,
}
pos gmysql.Position // empty position
Expand Down Expand Up @@ -217,7 +217,7 @@ func (t *testTCPReaderSuite) TestSyncGTID(c *C) {
Port: uint16(t.port),
User: t.user,
Password: t.password,
UseDecimal: true,
UseDecimal: false,
VerifyChecksum: true,
}
gSet gtid.Set // nil GTID set
Expand Down
4 changes: 2 additions & 2 deletions pkg/binlog/reader/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (t *testTCPReaderSuite) TestGetGTIDsForPos(c *C) {
Port: uint16(t.port),
User: t.user,
Password: t.password,
UseDecimal: true,
UseDecimal: false,
VerifyChecksum: true,
}
ctx, cancel = context.WithTimeout(context.Background(), utils.DefaultDBTimeout)
Expand Down Expand Up @@ -73,7 +73,7 @@ func (t *testTCPReaderSuite) TestGetPreviousGTIDFromGTIDSet(c *C) {
Port: uint16(t.port),
User: t.user,
Password: t.password,
UseDecimal: true,
UseDecimal: false,
VerifyChecksum: true,
}
ctx, cancel = context.WithTimeout(context.Background(), utils.DefaultDBTimeout)
Expand Down
2 changes: 1 addition & 1 deletion pkg/v1dbschema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func UpdateSchema(tctx *tcontext.Context, db *conn.BaseDB, cfg *config.SubTaskCo
Port: uint16(cfg.From.Port),
User: cfg.From.User,
Password: cfg.From.Password, // plaintext.
UseDecimal: true,
UseDecimal: false,
VerifyChecksum: true,
}
tcpReader := reader.NewTCPReader(syncCfg)
Expand Down
2 changes: 1 addition & 1 deletion syncer/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (s *testDBSuite) resetBinlogSyncer(c *C) {
Port: uint16(s.cfg.From.Port),
User: s.cfg.From.User,
Password: s.cfg.From.Password,
UseDecimal: true,
UseDecimal: false,
VerifyChecksum: true,
}
cfg.TimestampStringLocation = time.UTC
Expand Down
12 changes: 2 additions & 10 deletions syncer/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/pingcap/parser"
bf "github.com/pingcap/tidb-tools/pkg/binlog-filter"
"github.com/pingcap/tidb-tools/pkg/filter"
"github.com/shopspring/decimal"

"github.com/pingcap/dm/dm/config"
"github.com/pingcap/dm/pkg/conn"
Expand Down Expand Up @@ -318,12 +317,6 @@ create table t (
}

func (s *testFilterSuite) TestAllBinaryProtocolTypes(c *C) {
skippedDec, err := decimal.NewFromString("10.10")
c.Assert(err, IsNil)
passedDec, err := decimal.NewFromString("10.11")

// https://github.com/go-mysql-org/go-mysql/blob/a18ba90219c438df600fd3e4a64edb7e344c75aa/replication/row_event.go#L994
c.Assert(err, IsNil)
cases := []struct {
exprStr string
tableStr string
Expand Down Expand Up @@ -391,15 +384,14 @@ create table t (
[]interface{}{int64(200000000)},
},
// MYSQL_TYPE_NEWDECIMAL
// DM always set UseDecimal to true
{
"c = 10.1",
`
create table t (
c decimal(5,2)
);`,
[]interface{}{skippedDec},
[]interface{}{passedDec},
[]interface{}{"10.10"},
[]interface{}{"10.11"},
},
// MYSQL_TYPE_FLOAT
{
Expand Down

0 comments on commit 1f0ca8b

Please sign in to comment.