diff --git a/go/vt/vttablet/tabletmanager/vdiff/table_differ.go b/go/vt/vttablet/tabletmanager/vdiff/table_differ.go index a98af2d54fa..ebe2901af05 100644 --- a/go/vt/vttablet/tabletmanager/vdiff/table_differ.go +++ b/go/vt/vttablet/tabletmanager/vdiff/table_differ.go @@ -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))