Skip to content

Commit

Permalink
lightning: save NEXT_GLOBAL_ROW_ID as uint64 instead of int64 (#45614)
Browse files Browse the repository at this point in the history
close #45427
  • Loading branch information
lyzx2001 committed Aug 9, 2023
1 parent b4bfeee commit b59ce11
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions br/pkg/lightning/backend/tidb/tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ func (*Writer) IsSynced() bool {
// TableAutoIDInfo is the auto id information of a table.
type TableAutoIDInfo struct {
Column string
NextID int64
NextID uint64
Type string
}

Expand All @@ -884,7 +884,7 @@ func FetchTableAutoIDInfos(ctx context.Context, exec utils.QueryExecutor, tableN
for rows.Next() {
var (
dbName, tblName, columnName, idType string
nextID int64
nextID uint64
)
columns, err := rows.Columns()
if err != nil {
Expand All @@ -897,7 +897,7 @@ func FetchTableAutoIDInfos(ctx context.Context, exec utils.QueryExecutor, tableN
//| testsysbench | t | _tidb_rowid | 1 | AUTO_INCREMENT |
//+--------------+------------+-------------+--------------------+----------------+

// if columns length is 4, it doesn't contains the last column `ID_TYPE`, and it will always be 'AUTO_INCREMENT'
// if columns length is 4, it doesn't contain the last column `ID_TYPE`, and it will always be 'AUTO_INCREMENT'
// for v4.0.0~v4.0.2 show table t next_row_id only returns 4 columns.
if len(columns) == 4 {
err = rows.Scan(&dbName, &tblName, &columnName, &nextID)
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/lightning/backend/tidb/tidb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func TestFetchRemoteTableModels_4_0(t *testing.T) {
AddRow("t", "id", "bigint(20) unsigned", "", "auto_increment"))
s.mockDB.ExpectQuery("SHOW TABLE `test`.`t` NEXT_ROW_ID").
WillReturnRows(sqlmock.NewRows([]string{"DB_NAME", "TABLE_NAME", "COLUMN_NAME", "NEXT_GLOBAL_ROW_ID"}).
AddRow("test", "t", "id", int64(1)))
AddRow("test", "t", "id", "10942694589135710585"))
s.mockDB.ExpectCommit()

targetInfoGetter := tidb.NewTargetInfoGetter(s.dbHandle)
Expand Down

0 comments on commit b59ce11

Please sign in to comment.