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

infoschema: Support for showing "AUTO_INCREMENT" in "information_schema.tables" #7037

Merged
merged 3 commits into from Jul 14, 2018

Conversation

@zimulala
Copy link
Member

commented Jul 12, 2018

What have you changed? (mandatory)

Fix #6973

tidb>create table t(id int auto_increment primary key, c int);
Query OK, 0 rows affected (0.11 sec)

tidb>insert into t values(1,1);
Query OK, 1 row affected (0.10 sec)

tidb>insert into t values(10000,1);
Query OK, 1 row affected (0.01 sec)

tidb>select * from t;
+-------+------+
| id    | c    |
+-------+------+
|     1 |    1 |
| 10000 |    1 |
+-------+------+
3 rows in set (0.00 sec)

select auto_increment from information_schema.tables where table_name = 't';

before :

+----------------+
| auto_increment |
+----------------+
|             0 |
+----------------+
1 row in set (0.00 sec)

after :

+----------------+
| auto_increment |
+----------------+
|          30002 |
+----------------+
1 row in set (0.00 sec)

What is the type of the changes? (mandatory)

  • Bug fix (non-breaking change which fixes an issue)

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)

release note:
Support for showing "auto_increment" in "information_schema.tables".
@zimulala

This comment has been minimized.

Copy link
Member Author

commented Jul 12, 2018

/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"))

This comment has been minimized.

Copy link
@XuHuaiyu

XuHuaiyu Jul 12, 2018

Contributor

why this return 30002?

This comment has been minimized.

Copy link
@ciscoxll

ciscoxll Jul 12, 2018

Contributor

@zimulala Allocate a batch of 30000 AUTO_INCREMENT?

This comment has been minimized.

Copy link
@zimulala

zimulala Jul 13, 2018

Author Member

@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)

This comment has been minimized.

Copy link
@zimulala

zimulala Jul 13, 2018

Author Member

@ciscoxll
Yes.

hasAutoIncID := false
for _, col := range tblInfo.Cols() {
if mysql.HasAutoIncrementFlag(col.Flag) {
hasAutoIncID = true

This comment has been minimized.

Copy link
@XuHuaiyu

XuHuaiyu Jul 12, 2018

Contributor

can break here?

This comment has been minimized.

Copy link
@ciscoxll

ciscoxll Jul 13, 2018

Contributor

@zimulala Please change here.

@zz-jason

This comment has been minimized.

Copy link
Member

commented Jul 12, 2018

@zimulala please add the "release-note" label for this PR

@zimulala

This comment has been minimized.

Copy link
Member Author

commented Jul 13, 2018

@ciscoxll

This comment has been minimized.

Copy link
Contributor

commented Jul 13, 2018

LGTM

Copy link
Member

left a comment

LGTM

@zz-jason

This comment has been minimized.

Copy link
Member

commented Jul 14, 2018

/run-all-tests

@zz-jason zz-jason merged commit 419e5cf into pingcap:master Jul 14, 2018
11 checks passed
11 checks passed
ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci-tidb/build Jenkins job succeeded.
Details
jenkins-ci-tidb/common-test Jenkins job succeeded.
Details
jenkins-ci-tidb/integration-common-test Jenkins job succeeded.
Details
jenkins-ci-tidb/integration-compatibility-test Jenkins job succeeded.
Details
jenkins-ci-tidb/integration-ddl-test Jenkins job succeeded.
Details
jenkins-ci-tidb/mybatis-test Jenkins job succeeded.
Details
jenkins-ci-tidb/sqllogic-test Jenkins job succeeded.
Details
jenkins-ci-tidb/unit-test Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details
@zimulala zimulala deleted the zimulala:select-autoIncID branch Jul 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.