From 022d4771a287be63f7c74a4e0cac756cf771a73d Mon Sep 17 00:00:00 2001 From: ti-srebot <66930949+ti-srebot@users.noreply.github.com> Date: Wed, 27 Jan 2021 13:57:05 +0800 Subject: [PATCH] restore: don't restore auto id if the table doesn't has it. (#420) (#720) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * cherry pick #420 to release-4.0 Signed-off-by: ti-srebot * Update schema.go Co-authored-by: 山岚 <36239017+YuJuncen@users.noreply.github.com> Co-authored-by: 3pointer --- pkg/backup/client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/backup/client.go b/pkg/backup/client.go index e30075ff7..e7fbef97b 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) }