Skip to content

Commit

Permalink
cherry pick pingcap#420 to release-4.0
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
YuJuncen authored and ti-srebot committed Jan 26, 2021
1 parent 139df44 commit 08fb9e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/backup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/utils/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 08fb9e3

Please sign in to comment.