pingcap/tidb-tools

diff: collation should not be applied on non-string columns

Opened this issue · 1 comments

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.
-- mysql @ 172.17.0.2:3306
create table u (a int primary key);
insert into u values (1), (2);

-- tidb @ 127.0.0.1:4000
create table u (a int primary key);
insert into u values (1), (2);
[data-sources.src1]
host = '172.17.0.2'
port = 3306
user = 'root'
password = '111'

[data-sources.src2]
host = '127.0.0.1'
port = 4000
user = 'root'
password = ''

[task]
output-dir = './output'
source-instances = ['src1']
target-instance = 'src2'
target-check-tables = ['test.u']
target-configs = ['cfg1']

[table-configs.cfg1]
target-tables = ['*.*']
collation = 'utf8mb4_general_ci'
chunk-size = 1
bin/sync_diff_inspector -C cfg.toml
  1. What did you expect to see?

The two test.u tables are equivalent

  1. What did you see instead?

Fatal error.

[2023/12/28 01:37:05.737 +08:00] [FATAL] [main.go:139] ["failed to check data difference"] [error="Error 1253 (42000): COLLATION 'utf8mb4_general_ci' is not valid for CHARACTER SET 'binary'"] 

  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?

7.3.0

  1. which tool are you using?

sync-diff-inspector 7.1.3 (master version 8811722)

  1. what versionof tool are you using (pump -V or tidb-lightning -V or syncer -V)?

This is caused by pingcap/tidb#34349.

sync-diff-inspector should check if the column has a string type before attaching the collate clause to it.