diff --git a/pkg/backup/client.go b/pkg/backup/client.go index 85c21c733..e37dd5b52 100644 --- a/pkg/backup/client.go +++ b/pkg/backup/client.go @@ -292,8 +292,8 @@ func BuildBackupRangeAndSchema( switch { case tableInfo.IsSequence(): globalAutoID, err = seqAlloc.NextGlobalAutoID(tableInfo.ID) - case tableInfo.IsView(): - // no auto ID for views. + case tableInfo.IsView() || !utils.NeedAutoID(tableInfo): + // no auto ID for views or table without either rowID nor auto_increment ID. default: globalAutoID, err = idAlloc.NextGlobalAutoID(tableInfo.ID) } diff --git a/pkg/utils/schema.go b/pkg/utils/schema.go index 489b66160..66484c745 100644 --- a/pkg/utils/schema.go +++ b/pkg/utils/schema.go @@ -44,7 +44,11 @@ func (tbl *Table) NoChecksum() bool { // NeedAutoID checks whether the table needs backing up with an autoid. func NeedAutoID(tblInfo *model.TableInfo) bool { +<<<<<<< HEAD hasRowID := !tblInfo.PKIsHandle +======= + hasRowID := !tblInfo.PKIsHandle && !tblInfo.IsCommonHandle +>>>>>>> 6390453... restore: don't restore auto id if the table doesn't has it. (#420) hasAutoIncID := tblInfo.GetAutoIncrementColInfo() != nil return hasRowID || hasAutoIncID }