Skip to content

Commit

Permalink
syncer(dm): fix wrong MySQL latin1 decoder (#8705) (#8710)
Browse files Browse the repository at this point in the history
ref #7028
  • Loading branch information
ti-chi-bot authored Apr 7, 2023
1 parent ed9ffce commit e221139
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion dm/syncer/dml.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ type genDMLParam struct {
extendData [][]interface{} // all data include extend data
}

var latin1Decoder = charmap.ISO8859_1.NewDecoder()
// latin1Decider is not usually ISO8859_1 in MySQL.
// ref https://dev.mysql.com/doc/refman/8.0/en/charset-we-sets.html
var latin1Decoder = charmap.Windows1252.NewDecoder()

// extractValueFromData adjust the values obtained from go-mysql so that
// - the values can be correctly converted to TiDB datum
Expand Down
2 changes: 1 addition & 1 deletion dm/tests/expression_filter/conf/dm-task2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ expression-filter:
only_muller:
schema: "expr_filter"
table: "t6"
insert-value-expr: "name != 'Müller'"
insert-value-expr: "name != 'Müller'"

black-white-list: # compatible with deprecated config
instance:
Expand Down
4 changes: 2 additions & 2 deletions dm/tests/expression_filter/data/db1.increment2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ update t5 set should_skip = 1, c = 2 where c = 1;
insert into t5 values (4, 1, 1); -- check this `should_skip = 1` row must be updated to `should_skip = 0` in TiDB
update t5 set should_skip = 0, c = 3 where c = 1;

insert into t6 (id, name, msg) values (1, 'Müller', 'Müller'), (2, 'X Æ A-12', 'X Æ A-12');
alter table t6 add column name2 varchar(20) character set latin1 default 'Müller';
insert into t6 (id, name, msg) values (1, 'Müller', 'Müller'), (2, 'X Æ A-12', 'X Æ A-12');
alter table t6 add column name2 varchar(20) character set latin1 default 'Müller';

-- trigger a flush
alter table t5 add column dummy int;
2 changes: 1 addition & 1 deletion dm/tests/expression_filter/data/db1.prepare2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ create table t2 (id int primary key,
);

create table t6 (id int, name varchar(20), msg text, primary key(`id`)) character set latin1;
insert into t6 (id, name, msg) values (0, 'Müller', 'Müller');
insert into t6 (id, name, msg) values (0, 'Müller', 'Müller');
4 changes: 2 additions & 2 deletions dm/tests/expression_filter/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ function complex_behaviour() {
run_sql_tidb "select count(8) from expr_filter.t5 where should_skip = 1"
check_contains "count(8): 0"

run_sql_tidb "select count(9) from expr_filter.t6 where name = 'Müller' and msg = 'Müller' and name2 = 'Müller'"
run_sql_tidb "select count(9) from expr_filter.t6 where name = 'Müller' and msg = 'Müller' and name2 = 'Müller'"
check_contains "count(9): 2"
run_sql_tidb "select count(10) from expr_filter.t6 where name != 'Müller'"
run_sql_tidb "select count(10) from expr_filter.t6 where name != 'Müller'"
check_contains "count(10): 0"

insert_num=$(grep -o '"number of filtered insert"=[0-9]\+' $WORK_DIR/worker1/log/dm-worker.log | grep -o '[0-9]\+' | awk '{n += $1}; END{print n}')
Expand Down

0 comments on commit e221139

Please sign in to comment.