-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
infoschema: Support for showing "AUTO_INCREMENT" in "information_schema.tables" #7037
Conversation
/run-all-tests |
testkit.Rows("1")) | ||
tk.MustExec("insert into t(c, d) values(1, 1)") | ||
tk.MustQuery("select auto_increment from information_schema.tables where table_name='t'").Check( | ||
testkit.Rows("30002")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this return 30002?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zimulala Allocate a batch of 30000 AUTO_INCREMENT
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@XuHuaiyu
Because the next global auto ID is 30002.
We can do some operations as follows:
TiDB 1
tidb> create table t(`id` int(11) NOT NULL AUTO_INCREMENT,`c` int(11) DEFAULT NULL, PRIMARY KEY (`id`));
Query OK, 0 rows affected (0.13 sec)
tidb> insert into t values(1,1);
Query OK, 1 row affected (0.14 sec)
tidb> insert into t values(10000,1);
Query OK, 1 row affected (0.02 sec)
tidb> select * from t;
+-------+------+
| id | c |
+-------+------+
| 1 | 1 |
| 10000 | 1 |
+-------+------+
2 rows in set (0.01 sec)
TiDB 2
Then we do the operation as follows:
tidb> insert into t values();
Query OK, 1 row affected (0.13 sec)
tidb> select * from t;
+-------+------+
| id | c |
+-------+------+
| 1 | 1 |
| 10000 | 1 |
| 30002 | NULL |
+-------+------+
3 rows in set (0.01 sec)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ciscoxll
Yes.
hasAutoIncID := false | ||
for _, col := range tblInfo.Cols() { | ||
if mysql.HasAutoIncrementFlag(col.Flag) { | ||
hasAutoIncID = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can break
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zimulala Please change here.
@zimulala please add the "release-note" label for this PR |
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
What have you changed? (mandatory)
Fix #6973
before :
after :
What is the type of the changes? (mandatory)
How has this PR been tested? (mandatory)
Unit test
Does this PR affect documentation (docs/docs-cn) update? (mandatory)
No
Does this PR affect tidb-ansible update? (mandatory)
No
Does this PR need to be added to the release notes? (mandatory)