-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
ddl, meta: support altering auto_increment ID to a smaller value #25868
Conversation
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
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 75a772f
|
Good job! Please update the docs @tangenta |
tk.MustExec("insert into t values (3);") | ||
tk.MustExec("insert into t values (3);") | ||
tk.MustQuery("select a, _tidb_rowid from t;").Check(testkit.Rows("3 1", "3 2")) |
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.
do we better report duplicate errors instead of direct overwrite existing data?
for auto pk handle, it seem will report dup err:
mysql> create table t (a bigint primary key auto_increment);
Query OK, 0 rows affected (0.01 sec)
mysql> alter table t FORCE auto_increment = 20;
Query OK, 0 rows affected (0.00 sec)
mysql> insert into t values();
Query OK, 1 row affected (0.00 sec)
mysql> alter table t FORCE auto_increment = 20;
Query OK, 0 rows affected (0.01 sec)
mysql> insert into t values();
ERROR 1062 (23000): Duplicate entry '20' for key 'PRIMARY'
What problem does this PR solve?
Issue Number: close #25400
Problem Summary:
For details, see #25400.
What is changed and how it works?
What's Changed:
This PR introduces a new syntax to force changing the next global auto ID:
Please attention: the
FORCE
keyword should be only used to recover metadata. All the write workload on the target table should be stopped and the ID should be the largest existing ID plus one(select max(id)+1 from t
). Otherwise, it may lose row data.Related changes
pingcap/docs
/pingcap/docs-cn
:Check List
Tests
Side effects
NA
Release note