-
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
Support dumping sequences #32538
Labels
component/dumpling
This is related to Dumpling of TiDB.
feature/accepted
This feature request is accepted by product managers
priority/P2
The issue has P2 priority.
type/new-feature
Comments
lichunzhu
added
component/dumpling
This is related to Dumpling of TiDB.
feature/accepted
This feature request is accepted by product managers
type/new-feature
labels
Feb 22, 2022
TiDB's show table next_row_id handle can get mysql> show create sequence s;
+----------+--------------------------------------------------------------------------------------------------------------------------+
| Sequence | Create Sequence |
+----------+--------------------------------------------------------------------------------------------------------------------------+
| s | CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB |
+----------+--------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> show table test.s next_row_id;
+---------+------------+-------------+--------------------+----------------+
| DB_NAME | TABLE_NAME | COLUMN_NAME | NEXT_GLOBAL_ROW_ID | ID_TYPE |
+---------+------------+-------------+--------------------+----------------+
| test | s | _tidb_rowid | 1 | AUTO_INCREMENT |
| test | s | | 1 | SEQUENCE |
+---------+------------+-------------+--------------------+----------------+
2 rows in set (0.00 sec)
mysql> select nextval(s);
+------------+
| nextval(s) |
+------------+
| 1 |
+------------+
1 row in set (0.01 sec)
mysql> show table test.s next_row_id;
+---------+------------+-------------+--------------------+----------------+
| DB_NAME | TABLE_NAME | COLUMN_NAME | NEXT_GLOBAL_ROW_ID | ID_TYPE |
+---------+------------+-------------+--------------------+----------------+
| test | s | _tidb_rowid | 1 | AUTO_INCREMENT |
| test | s | | 1001 | SEQUENCE |
+---------+------------+-------------+--------------------+----------------+
2 rows in set (0.00 sec) Dumpling should support using show create sequence to get sequence SQL and use select setval(seq, next_not_cached_value) to rebase sequence start value to next_not_cached_value. Both SQLs should be written in format like |
sql example: CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB;
select setval(s, 1001); |
ti-chi-bot
pushed a commit
that referenced
this issue
Mar 24, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
component/dumpling
This is related to Dumpling of TiDB.
feature/accepted
This feature request is accepted by product managers
priority/P2
The issue has P2 priority.
type/new-feature
Support dumping MariaDB and TiDB sequences. The sequence schema file should contain two statements:
The sequence value can be obtained by:
SELECT next_not_cached_value FROM seq_name
(a sequence is just a table in MariaDB)The text was updated successfully, but these errors were encountered: