Skip to content

Commit

Permalink
lightning: save NEXT_GLOBAL_ROW_ID as uint64 instead of int64 (pingca…
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Aug 25, 2023
1 parent a52c366 commit 4cb399e
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 @@ -782,7 +782,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 @@ -796,7 +796,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 @@ -809,7 +809,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 @@ -328,7 +328,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 4cb399e

Please sign in to comment.