@@ -79,6 +79,7 @@ import (
79
79
"github.com/pingcap/dm/dm/pb"
80
80
"github.com/pingcap/dm/pkg/conn"
81
81
tcontext "github.com/pingcap/dm/pkg/context"
82
+ "github.com/pingcap/dm/pkg/log"
82
83
"github.com/pingcap/dm/pkg/terror"
83
84
shardmeta "github.com/pingcap/dm/syncer/sharding-meta"
84
85
@@ -379,7 +380,32 @@ func (sg *ShardingGroup) FlushData(targetTableID string) ([]string, [][]interfac
379
380
}
380
381
381
382
// GenTableID generates table ID
382
- func GenTableID (schema , table string ) (ID string , isSchemaOnly bool ) {
383
+ func GenTableID (schema , table string , upperSchema , upperTable []string ) (ID string , isSchemaOnly bool ) {
384
+ for _ , s := range upperSchema {
385
+ if s == schema {
386
+ oldSchema := schema
387
+ schema = strings .ToLower (schema )
388
+ if oldSchema != schema {
389
+ log .L ().Warn ("hotfix, changing schema to lowercase" ,
390
+ zap .String ("old schema" , oldSchema ),
391
+ zap .String ("schema" , schema ))
392
+ }
393
+ break
394
+ }
395
+ }
396
+ for _ , t := range upperTable {
397
+ if t == table {
398
+ oldTable := table
399
+ table = strings .ToLower (table )
400
+ if oldTable != table {
401
+ log .L ().Warn ("hotfix, changing table to lowercase" ,
402
+ zap .String ("old table" , oldTable ),
403
+ zap .String ("table" , table ))
404
+ }
405
+ break
406
+ }
407
+ }
408
+
383
409
if len (table ) == 0 {
384
410
return fmt .Sprintf ("`%s`" , schema ), true
385
411
}
@@ -425,8 +451,8 @@ func NewShardingGroupKeeper(tctx *tcontext.Context, cfg *config.SubTaskConfig) *
425
451
func (k * ShardingGroupKeeper ) AddGroup (targetSchema , targetTable string , sourceIDs []string , meta * shardmeta.ShardingMeta , merge bool ) (needShardingHandle bool , group * ShardingGroup , synced bool , remain int , err error ) {
426
452
// if need to support target table-level sharding DDL
427
453
// we also need to support target schema-level sharding DDL
428
- schemaID , _ := GenTableID (targetSchema , "" )
429
- targetTableID , _ := GenTableID (targetSchema , targetTable )
454
+ schemaID , _ := GenTableID (targetSchema , "" , k . cfg . UpperSchema , k . cfg . UpperTable )
455
+ targetTableID , _ := GenTableID (targetSchema , targetTable , k . cfg . UpperSchema , k . cfg . UpperTable )
430
456
431
457
k .Lock ()
432
458
defer k .Unlock ()
@@ -486,8 +512,8 @@ func (k *ShardingGroupKeeper) ResetGroups() {
486
512
// LeaveGroup leaves group according to target schema, table and source IDs
487
513
// LeaveGroup doesn't affect in syncing process
488
514
func (k * ShardingGroupKeeper ) LeaveGroup (targetSchema , targetTable string , sources []string ) error {
489
- schemaID , _ := GenTableID (targetSchema , "" )
490
- targetTableID , _ := GenTableID (targetSchema , targetTable )
515
+ schemaID , _ := GenTableID (targetSchema , "" , k . cfg . UpperSchema , k . cfg . UpperTable )
516
+ targetTableID , _ := GenTableID (targetSchema , targetTable , k . cfg . UpperSchema , k . cfg . UpperTable )
491
517
k .Lock ()
492
518
defer k .Unlock ()
493
519
if group , ok := k .groups [targetTableID ]; ok {
@@ -514,7 +540,7 @@ func (k *ShardingGroupKeeper) TrySync(
514
540
targetSchema , targetTable , source string , pos , endPos mysql.Position , ddls []string ) (
515
541
needShardingHandle bool , group * ShardingGroup , synced , active bool , remain int , err error ) {
516
542
517
- targetTableID , schemaOnly := GenTableID (targetSchema , targetTable )
543
+ targetTableID , schemaOnly := GenTableID (targetSchema , targetTable , k . cfg . UpperSchema , k . cfg . UpperTable )
518
544
if schemaOnly {
519
545
// NOTE: now we don't support syncing for schema only sharding DDL
520
546
return false , nil , true , false , 0 , nil
@@ -563,7 +589,7 @@ func (k *ShardingGroupKeeper) UnresolvedTables() (map[string]bool, [][]string) {
563
589
564
590
// Group returns target table's group, nil if not exist
565
591
func (k * ShardingGroupKeeper ) Group (targetSchema , targetTable string ) * ShardingGroup {
566
- targetTableID , _ := GenTableID (targetSchema , targetTable )
592
+ targetTableID , _ := GenTableID (targetSchema , targetTable , k . cfg . UpperSchema , k . cfg . UpperTable )
567
593
k .RLock ()
568
594
defer k .RUnlock ()
569
595
return k .groups [targetTableID ]
0 commit comments