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 1877c95
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions go/vt/vttablet/tabletmanager/vdiff/table_differ.go
Original file line number Diff line number Diff line change
Expand Up @@ -927,19 +927,23 @@ func (td *tableDiffer) getSourcePKCols() error {
// We use the columns from a PKE if there is one.
executeFetch := func(query string, maxrows int, wantfields bool) (*sqltypes.Result, error) {
res, err := td.wd.ct.tmc.ExecuteFetchAsApp(ctx, sourceTablet.Tablet, false, &tabletmanagerdatapb.ExecuteFetchAsAppRequest{
Query: []byte(query),
MaxRows: 1,
Query: []byte(query),
})
if err != nil {
return nil, err
}
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 1877c95

Please sign in to comment.