Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#44743
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
tiancaiamao authored and ti-chi-bot committed Jun 20, 2023
1 parent 2f0ed6f commit 773582b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions br/pkg/backup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,15 @@ func BuildBackupRangeAndSchema(
case tableInfo.IsView() || !utils.NeedAutoID(tableInfo):
// no auto ID for views or table without either rowID nor auto_increment ID.
default:
<<<<<<< HEAD
globalAutoID, err = idAlloc.NextGlobalAutoID()
=======
if tableInfo.SepAutoInc() {
globalAutoID, err = autoIDAccess.IncrementID(tableInfo.Version).Get()
} else {
globalAutoID, err = autoIDAccess.RowID().Get()
}
>>>>>>> e0f62ef19e6 (*: fix 'duplicate entry' error when using br to restore AUTO_ID_CACHE=1 tables (#44743))
}
if err != nil {
return nil, nil, nil, errors.Trace(err)
Expand Down
4 changes: 2 additions & 2 deletions ddl/db_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3139,7 +3139,7 @@ func TestAutoIncrementForceAutoIDCache(t *testing.T) {
"t CREATE TABLE `t` (\n" +
" `a` int(11) NOT NULL AUTO_INCREMENT,\n" +
" PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_id_cache] AUTO_ID_CACHE=1 */"))
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=201 /*T![auto_id_cache] AUTO_ID_CACHE=1 */"))
tk.MustExec("alter table t auto_increment=100;")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 Can't reset AUTO_INCREMENT to 100 without FORCE option, using 201 instead"))
tk.MustExec("insert into t values ()")
Expand All @@ -3148,7 +3148,7 @@ func TestAutoIncrementForceAutoIDCache(t *testing.T) {
"t CREATE TABLE `t` (\n" +
" `a` int(11) NOT NULL AUTO_INCREMENT,\n" +
" PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_id_cache] AUTO_ID_CACHE=1 */"))
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=212 /*T![auto_id_cache] AUTO_ID_CACHE=1 */"))
tk.MustExec("drop table t")
}

Expand Down
2 changes: 1 addition & 1 deletion executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ func ConstructResultOfShowCreateTable(ctx sessionctx.Context, tableInfo *model.T
fmt.Fprintf(buf, " COMPRESSION='%s'", tableInfo.Compression)
}

incrementAllocator := allocators.Get(autoid.RowIDAllocType)
incrementAllocator := allocators.Get(autoid.AutoIncrementType)
if hasAutoIncID && incrementAllocator != nil {
autoIncID, err := incrementAllocator.NextGlobalAutoID()
if err != nil {
Expand Down

0 comments on commit 773582b

Please sign in to comment.