@@ -829,7 +829,7 @@ func (td *tableDiffer) lastPKFromRow(row []sqltypes.Value) *tabletmanagerdatapb.
829
829
pkColCnt := len (pkCols )
830
830
pkFields := make ([]* querypb.Field , pkColCnt )
831
831
pkVals := make ([]sqltypes.Value , pkColCnt )
832
- for i , colIndex := range td . tablePlan . pkCols {
832
+ for i , colIndex := range pkCols {
833
833
pkFields [i ] = td .tablePlan .table .Fields [colIndex ]
834
834
pkVals [i ] = row [colIndex ]
835
835
}
@@ -935,11 +935,16 @@ func (td *tableDiffer) getSourcePKCols() error {
935
935
}
936
936
return sqltypes .Proto3ToResult (res ), nil
937
937
}
938
- pkeCols , _ , err := mysqlctl .GetPrimaryKeyEquivalentColumns (ctx , executeFetch , td . wd . ct . sourceKeyspace , td .table .Name )
938
+ pkeCols , _ , err := mysqlctl .GetPrimaryKeyEquivalentColumns (ctx , executeFetch , sourceTablet . DbName () , td .table .Name )
939
939
if err != nil {
940
940
return err
941
941
}
942
- sourceTable .PrimaryKeyColumns = pkeCols
942
+ if len (pkeCols ) > 0 {
943
+ sourceTable .PrimaryKeyColumns = pkeCols
944
+ } else {
945
+ // We use every column together as a substitute PK.
946
+ sourceTable .PrimaryKeyColumns = append (sourceTable .PrimaryKeyColumns , td .table .Columns ... )
947
+ }
943
948
}
944
949
sourcePKColumns := make (map [string ]struct {}, len (sourceTable .PrimaryKeyColumns ))
945
950
td .tablePlan .sourcePkCols = make ([]int , 0 , len (sourceTable .PrimaryKeyColumns ))
0 commit comments