Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meta/autoid : fix the issue that MaxUint64 and MaxInt64 autoID is incorrectly allocated (#12119) #12162

Merged
merged 16 commits into from
Sep 16, 2019
Merged
Prev Previous commit
Next Next commit
fix session_test comment
  • Loading branch information
AilinKid authored and root committed Sep 11, 2019
commit 177eb26258655c6a5369ed90ae2ab82e121dabe4
8 changes: 4 additions & 4 deletions session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,8 @@ func (s *testSessionSuite) TestAutoIncrementID(c *C) {
tk.MustExec("insert into autoid values();")
tk.MustExec("insert into autoid values();")
tk.MustQuery("select * from autoid").Check(testkit.Rows("9223372036854775808", "9223372036854775810", "9223372036854775812"))
// TiDB characteristics : _tidb_rowid will also consume the autoID when the auto_increment column is not the primary key.
// Behaviour like MySQL using the MaxUint64 and MaxInt64 as the autoID upper limit will cause _tidb_rowid alloc fail here.
// In TiDB : _tidb_rowid will also consume the autoID when the auto_increment column is not the primary key.
// Using the MaxUint64 and MaxInt64 as the autoID upper limit like MySQL will cause _tidb_rowid alloc fail here.
_, err := tk.Exec("insert into autoid values(18446744073709551614)")
c.Assert(terror.ErrorEqual(err, autoid.ErrAutoincReadFailed), IsTrue)
_, err = tk.Exec("insert into autoid values()")
Expand All @@ -869,8 +869,8 @@ func (s *testSessionSuite) TestAutoIncrementID(c *C) {
// Corner cases for signed bigint auto_increment Columns.
tk.MustExec("drop table if exists autoid")
tk.MustExec("create table autoid(`auto_inc_id` bigint(20) NOT NULL AUTO_INCREMENT,UNIQUE KEY `auto_inc_id` (`auto_inc_id`))")
// TiDB characteristics: _tidb_rowid will also consume the autoID when the auto_increment column is not the primary key.
// Behaviour like MySQL using the MaxUint64 and MaxInt64 as autoID upper limit will cause insert fail if the values is
// In TiDB : _tidb_rowid will also consume the autoID when the auto_increment column is not the primary key.
// Using the MaxUint64 and MaxInt64 as autoID upper limit like MySQL will cause insert fail if the values is
// 9223372036854775806. Because _tidb_rowid will be allocated 9223372036854775807 at same time.
tk.MustExec("insert into autoid values(9223372036854775805);")
tk.MustQuery("select auto_inc_id, _tidb_rowid from autoid use index()").Check(testkit.Rows("9223372036854775805 9223372036854775806"))
Expand Down