Skip to content

Commit

Permalink
Fix source PKE handling
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord committed Jan 9, 2025
1 parent 02b7f06 commit f7bd4b8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions go/vt/vttablet/tabletmanager/vdiff/table_differ.go
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ func (td *tableDiffer) lastPKFromRow(row []sqltypes.Value) *tabletmanagerdatapb.
pkColCnt := len(pkCols)
pkFields := make([]*querypb.Field, pkColCnt)
pkVals := make([]sqltypes.Value, pkColCnt)
for i, colIndex := range td.tablePlan.pkCols {
for i, colIndex := range pkCols {
pkFields[i] = td.tablePlan.table.Fields[colIndex]
pkVals[i] = row[colIndex]
}
Expand Down Expand Up @@ -935,11 +935,16 @@ func (td *tableDiffer) getSourcePKCols() error {
}
return sqltypes.Proto3ToResult(res), nil
}
pkeCols, _, err := mysqlctl.GetPrimaryKeyEquivalentColumns(ctx, executeFetch, td.wd.ct.sourceKeyspace, td.table.Name)
pkeCols, _, err := mysqlctl.GetPrimaryKeyEquivalentColumns(ctx, executeFetch, sourceTablet.DbName(), td.table.Name)
if err != nil {
return err
}
sourceTable.PrimaryKeyColumns = pkeCols
if len(pkeCols) > 0 {
sourceTable.PrimaryKeyColumns = pkeCols
} else {
// We use every column together as a substitute PK.
sourceTable.PrimaryKeyColumns = append(sourceTable.PrimaryKeyColumns, td.table.Columns...)
}
}
sourcePKColumns := make(map[string]struct{}, len(sourceTable.PrimaryKeyColumns))
td.tablePlan.sourcePkCols = make([]int, 0, len(sourceTable.PrimaryKeyColumns))
Expand Down

0 comments on commit f7bd4b8

Please sign in to comment.