Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Workaround TiDB compatibilty bug of incorrect TABLE_COLLATION value for View

天舟c6ea6af03c56
diff --git a/plugin/db/mysql/mysql.go b/plugin/db/mysql/mysql.go
index e2282dade2..fa63f76897 100644
--- a/plugin/db/mysql/mysql.go
+++ b/plugin/db/mysql/mysql.go
@@ -345,6 +345,8 @@ func (driver *Driver) SyncSchema(ctx context.Context) ([]*db.DBUser, []*db.DBSch
tableMap := make(map[string][]db.DBTable)
for tableRows.Next() {
var dbName string
+ // Workaround TiDB bug https://github.com/pingcap/tidb/issues/27970
+ var tableCollation sql.NullString
var table db.DBTable
if err := tableRows.Scan(
&dbName,
@@ -353,7 +355,7 @@ func (driver *Driver) SyncSchema(ctx context.Context) ([]*db.DBUser, []*db.DBSch
&table.UpdatedTs,
&table.Type,
&table.Engine,
- &table.Collation,
+ &tableCollation,
&table.RowCount,
&table.DataSize,
&table.IndexSize,
@@ -364,6 +366,10 @@ func (driver *Driver) SyncSchema(ctx context.Context) ([]*db.DBUser, []*db.DBSch
return nil, nil, err
}
+ if tableCollation.Valid {
+ table.Collation = tableCollation.String
+ }
+
key := fmt.Sprintf("%s/%s", dbName, table.Name)
table.ColumnList = columnMap[key]
table.IndexList = indexMap[key]