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

syncer: remove KEY index in DML concurrency keys (#1061) #1063

Merged
merged 1 commit into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions syncer/dml.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,15 @@ func genMultipleKeys(ti *model.TableInfo, value []interface{}, table string) []s
}

for _, indexCols := range ti.Indices {
// PK also has a true Unique
if !indexCols.Unique {
continue
}
cols, vals := getColumnData(ti.Columns, indexCols, value)
key := genKeyList(table, cols, vals)
if len(key) > 0 { // ignore `null` value.
multipleKeys = append(multipleKeys, key)
// TODO: break here? one unique index is enough?
} else {
log.L().Debug("ignore empty key", zap.String("table", table))
}
Expand Down
8 changes: 4 additions & 4 deletions syncer/dml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ func (s *testSyncerSuite) TestGenMultipleKeys(c *C) {
// one ordinary key
schema: `create table t4(a int, b double, key(b))`,
values: []interface{}{60, 70.5},
keys: []string{"70.5table"},
keys: []string{"table"},
},
{
// multiple keys
schema: `create table t5(a int, b text, c int, key(a), key(b(3)))`,
values: []interface{}{13, "abcdef", 15},
keys: []string{"13table", "abcdeftable"},
keys: []string{"table"},
},
{
// multiple keys with primary key
Expand All @@ -180,7 +180,7 @@ func (s *testSyncerSuite) TestGenMultipleKeys(c *C) {
// ordinary key of multiple columns
schema: `create table t75(a int, b int, c int, key(a, b), key(c, b))`,
values: []interface{}{48, 58, 68},
keys: []string{"4858table", "6858table"},
keys: []string{"table"},
},
{
// so many keys
Expand All @@ -194,7 +194,7 @@ func (s *testSyncerSuite) TestGenMultipleKeys(c *C) {
)
`,
values: []interface{}{27, 37, 47},
keys: []string{"2737table", "3747table", "273747table", "4727table"},
keys: []string{"2737table", "3747table", "4727table"},
},
{
// `null` for unique key
Expand Down