Comments (1)
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)
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
}
from tidb-tools.
Related Issues (20)
- no need to change go.mod when update go toolchain
- sync-diff-inspector fix.sql can not execute when data has blob column type.
- sync_diff: can't check the upstream with hidden column
- sync_diff: failed to initialize the diff process with downstream MySQL and hidden column. HOT 4
- sync-diff-inspector panics with nonstandard custom `server-version` in TiDB Server HOT 1
- change the default value in [target-check-tables] (sync-diff-inspector)
- sync-diff-inspector : When the range condition is of timestamp type, the time zone cannot be converted correctly HOT 1
- integration test error
- error occurred when the different row's json column is NULL in the one db source, but is not NULL in the other db source
- sync-diff-inspector : don't compare the partition attribute of schema HOT 2
- the tls certificate in the integration test is outdate
- sync-diff-inspector v7.1.1: Long execution time due to parsing data incorrect which COLLATE is utf8_general_ci HOT 1
- sync-diff-inspector: use UNHEX for BINARY and VARBINARY types HOT 1
- *: bump tidb version
- diff: collation should not be applied on non-string columns HOT 1
- ci failed: tls version mismatch
- Add more ddl event type to binlog filter package.
- please provide the table name when compare failed HOT 1
- Update TiDB Dependency
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tidb-tools.