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

AUTO_INCREMENT relates to a restriction whose behavior is inconsistent with the document description. #45136

Closed
zimulala opened this issue Jul 3, 2023 · 0 comments · Fixed by #45235
Assignees
Labels
severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@zimulala
Copy link
Contributor

zimulala commented Jul 3, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Docs in : https://docs.pingcap.com/tidb/stable/auto-increment#restrictions

Currently, AUTO_INCREMENT has the following restrictions when used in TiDB:
...
It cannot be specified on the same column with the DEFAULT column value.
...

create table t (a bigint auto_increment primary key);
alter table t modify column a bigint auto_increment default 3;
show create table t;

2. What did you expect to see? (Required)

Execute alter table failed. The error message like : Invalid auto increment: auto_increment is incompatible with default

3. What did you see instead (Required)

tidb> alter table t modify column a bigint auto_increment default 3;
Query OK, 0 rows affected (0.03 sec)

tidb> show create table t;
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                    |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `a` bigint(20) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

4. What is your TiDB version? (Required)

master

Release Version: v7.3.0-alpha-94-gc44ba1c1a8
Edition: Community
Git Commit Hash: c44ba1c1a868220764d9f11274b683d1aaecacb6
Git Branch: master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants