We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please answer these questions before submitting your issue. Thanks!
-- mysql @ 172.17.0.2:3306 create table t (a varchar(200) collate utf8mb4_general_ci not null, b varchar(200) collate utf8mb4_bin not null, primary key(a, b)); insert into t values ('a', 'aa'), ('B', 'bb'), ('c', 'cc'), ('D', 'dd'), ('e', 'ee'), ('F', 'ff'), ('g', 'gg'), ('H', 'hh'), ('*', 'mysql'); -- tidb @ 127.0.0.1:4000 create table t (a varchar(200) collate utf8mb4_bin not null, b varchar(200) collate utf8mb4_bin not null, primary key(a, b)); insert into t values ('a', 'aa'), ('B', 'bb'), ('c', 'cc'), ('D', 'dd'), ('e', 'ee'), ('F', 'ff'), ('g', 'gg'), ('H', 'hh'), ('*', 'tidb');
[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.t'] target-configs = ['cfg1'] [table-configs.cfg1] target-tables = ['test.t'] collation = 'utf8mb4_general_ci'
bin/sync_diff_inspector -C cfg.toml
Only 1 row differs
+------------+---------+--------------------+----------------+---------+-----------+ | TABLE | RESULT | STRUCTURE EQUALITY | DATA DIFF ROWS | UPCOUNT | DOWNCOUNT | +------------+---------+--------------------+----------------+---------+-----------+ | `test`.`t` | succeed | true | +1/-1 | 9 | 9 | +------------+---------+--------------------+----------------+---------+-----------+
5 row differs.
+------------+---------+--------------------+----------------+---------+-----------+ | TABLE | RESULT | STRUCTURE EQUALITY | DATA DIFF ROWS | UPCOUNT | DOWNCOUNT | +------------+---------+--------------------+----------------+---------+-----------+ | `test`.`t` | succeed | true | +5/-5 | 9 | 9 | +------------+---------+--------------------+----------------+---------+-----------+
tidb-server -V
select tidb_version();
7.3.0
sync-diff-inspector 7.1.3 (master version 8811722)
pump -V
tidb-lightning -V
syncer -V
The text was updated successfully, but these errors were encountered:
The collation setting is only applied to the end of ORDER BY, which only affects the last column with a composite PK (or no PK)
collation
ORDER BY
This patch should be applied (this is not the final correct solution because it will amplify #760):
diff --git a/pkg/diff/diff.go b/pkg/diff/diff.go index 06242f9..b76021b 100644 --- a/pkg/diff/diff.go +++ b/pkg/diff/diff.go @@ -986,11 +986,11 @@ func getChunkRows(ctx context.Context, db *sql.DB, schema, table string, tableIn } for i, key := range orderKeys { - orderKeys[i] = dbutil.ColumnName(key) + orderKeys[i] = dbutil.ColumnName(key) + collation } - query := fmt.Sprintf("SELECT /*!40001 SQL_NO_CACHE */ %s FROM %s WHERE %s ORDER BY %s%s", - columns, dbutil.TableName(schema, table), where, strings.Join(orderKeys, ","), collation) + query := fmt.Sprintf("SELECT /*!40001 SQL_NO_CACHE */ %s FROM %s WHERE %s ORDER BY %s", + columns, dbutil.TableName(schema, table), where, strings.Join(orderKeys, ",")) log.Debug("select data", zap.String("sql", query), zap.Reflect("args", args)) rows, err := db.QueryContext(ctx, query, args...) diff --git a/sync_diff_inspector/utils/utils.go b/sync_diff_inspector/utils/utils.go index b8ca447..58c4748 100644 --- a/sync_diff_inspector/utils/utils.go +++ b/sync_diff_inspector/utils/utils.go @@ -163,11 +163,11 @@ func GetTableRowsQueryFormat(schema, table string, tableInfo *model.TableInfo, c } for i, key := range orderKeys { - orderKeys[i] = dbutil.ColumnName(key) + orderKeys[i] = dbutil.ColumnName(key) + collation } - query := fmt.Sprintf("SELECT /*!40001 SQL_NO_CACHE */ %s FROM %s WHERE %%s ORDER BY %s%s", - columns, dbutil.TableName(schema, table), strings.Join(orderKeys, ","), collation) + query := fmt.Sprintf("SELECT /*!40001 SQL_NO_CACHE */ %s FROM %s WHERE %%s ORDER BY %s", + columns, dbutil.TableName(schema, table), strings.Join(orderKeys, ",")) return query, orderKeyCols }
Sorry, something went wrong.
No branches or pull requests
Bug Report
Please answer these questions before submitting your issue. Thanks!
If possible, provide a recipe for reproducing the error.
Only 1 row differs
5 row differs.
tidb-server -V
or runselect tidb_version();
on TiDB)?7.3.0
sync-diff-inspector 7.1.3 (master version 8811722)
pump -V
ortidb-lightning -V
orsyncer -V
)?The text was updated successfully, but these errors were encountered: