Skip to content

Commit

Permalink
syncer: remove KEY index in DML concurrency keys (pingcap#1061)
Browse files Browse the repository at this point in the history
  • Loading branch information
lance6716 committed Sep 18, 2020
1 parent 62dae90 commit 433572d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
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

0 comments on commit 433572d

Please sign in to comment.