241 lines
8.4 KiB
Plaintext
241 lines
8.4 KiB
Plaintext
Show preservation of autoincrement values via ndb_restore
|
|
Cover some variants including :
|
|
- Basic restore
|
|
- Keyless table use case
|
|
- Restore via a staging table
|
|
- Restore with no data
|
|
----------------------------------------
|
|
1. Create tables and add some data
|
|
----------------------------------------
|
|
use test;
|
|
create table boring (
|
|
a tinyint auto_increment primary key,
|
|
b int
|
|
) engine=ndb;
|
|
Expect next == 7
|
|
insert into boring (b) values (1), (2), (3), (4), (5), (6);
|
|
select table_schema, table_name, auto_increment from information_schema.tables where table_schema="test" and table_name="boring";
|
|
TABLE_SCHEMA TABLE_NAME AUTO_INCREMENT
|
|
test boring 7
|
|
create table boring_keyless (
|
|
a int
|
|
) engine=ndb;
|
|
Expect next == 5
|
|
insert into boring_keyless values (1), (2), (3), (4);
|
|
create table empty_default (
|
|
a mediumint primary key auto_increment,
|
|
b int
|
|
) engine=ndb;
|
|
Expect next == 1
|
|
select table_schema, table_name, auto_increment from information_schema.tables where table_schema="test" and table_name="empty_default";
|
|
TABLE_SCHEMA TABLE_NAME AUTO_INCREMENT
|
|
test empty_default 1
|
|
create table empty_specific (
|
|
a mediumint primary key auto_increment,
|
|
b int
|
|
) engine=ndb auto_increment=73;
|
|
Expect next == 73
|
|
select table_schema, table_name, auto_increment from information_schema.tables where table_schema="test" and table_name="empty_specific";
|
|
TABLE_SCHEMA TABLE_NAME AUTO_INCREMENT
|
|
test empty_specific 73
|
|
create table big_varchars (
|
|
a bigint auto_increment primary key,
|
|
b varchar(2000)
|
|
) engine=ndb;
|
|
insert into big_varchars (b) values (repeat('ILBJC', 400));
|
|
insert into big_varchars (b) values (repeat('ILBJC', 400));
|
|
insert into big_varchars (b) values (repeat('ILBJC', 400));
|
|
insert into big_varchars (b) values (repeat('ILBJC', 400));
|
|
insert into big_varchars (b) values (repeat('ILBJC', 400));
|
|
Expect next == 6
|
|
select table_schema, table_name, auto_increment from information_schema.tables where table_schema="test" and table_name="big_varchars";
|
|
TABLE_SCHEMA TABLE_NAME AUTO_INCREMENT
|
|
test big_varchars 6
|
|
----------------------------------------
|
|
2. Take a backup
|
|
----------------------------------------
|
|
drop table big_varchars;
|
|
drop table empty_specific;
|
|
drop table empty_default;
|
|
drop table boring_keyless;
|
|
drop table boring;
|
|
----------------------------------------
|
|
3. Manually re-create schema via MySQLD with some changes
|
|
----------------------------------------
|
|
Avoid any accidental tableid line-up
|
|
create table filler1(a int primary key) engine=ndb;
|
|
create table filler2(a int primary key) engine=ndb;
|
|
create table filler3(a int primary key) engine=ndb;
|
|
create table filler4(a int primary key) engine=ndb;
|
|
create table filler5(a int primary key) engine=ndb;
|
|
create table filler6(a int primary key) engine=ndb;
|
|
create table filler7(a int primary key) engine=ndb;
|
|
create table filler8(a int primary key) engine=ndb;
|
|
big_varchars table now has a text column
|
|
testing staging area transform
|
|
create table big_varchars (
|
|
a bigint auto_increment primary key,
|
|
b text
|
|
) engine=ndb;
|
|
create table boring (
|
|
a tinyint auto_increment primary key,
|
|
b int
|
|
) engine=ndb;
|
|
create table boring_keyless (
|
|
a int
|
|
) engine=ndb;
|
|
create table empty_default (
|
|
a mediumint primary key auto_increment,
|
|
b int
|
|
) engine=ndb;
|
|
Expect next == 1
|
|
select table_schema, table_name, auto_increment from information_schema.tables where table_schema="test" and table_name="empty_default";
|
|
TABLE_SCHEMA TABLE_NAME AUTO_INCREMENT
|
|
test empty_default 1
|
|
create table empty_specific (
|
|
a mediumint primary key auto_increment,
|
|
b int
|
|
) engine=ndb auto_increment=73;
|
|
Expect next == 73
|
|
select table_schema, table_name, auto_increment from information_schema.tables where table_schema="test" and table_name="empty_specific";
|
|
TABLE_SCHEMA TABLE_NAME AUTO_INCREMENT
|
|
test empty_specific 73
|
|
----------------------------------------
|
|
4. Restore data
|
|
----------------------------------------
|
|
----------------------------------------
|
|
5. Check autoincrement info
|
|
----------------------------------------
|
|
Expect 7
|
|
select table_schema, table_name, auto_increment from information_schema.tables where table_schema="test" and table_name="boring";
|
|
TABLE_SCHEMA TABLE_NAME AUTO_INCREMENT
|
|
test boring 7
|
|
Expect 1
|
|
select table_schema, table_name, auto_increment from information_schema.tables where table_schema="test" and table_name="empty_default";
|
|
TABLE_SCHEMA TABLE_NAME AUTO_INCREMENT
|
|
test empty_default 1
|
|
Expect 73
|
|
select table_schema, table_name, auto_increment from information_schema.tables where table_schema="test" and table_name="empty_specific";
|
|
TABLE_SCHEMA TABLE_NAME AUTO_INCREMENT
|
|
test empty_specific 73
|
|
Expect 6
|
|
select table_schema, table_name, auto_increment from information_schema.tables where table_schema="test" and table_name="big_varchars";
|
|
TABLE_SCHEMA TABLE_NAME AUTO_INCREMENT
|
|
test big_varchars 6
|
|
----------------------------------------
|
|
6. Test via inserts
|
|
----------------------------------------
|
|
insert into boring (b) values (99);
|
|
Expect 7
|
|
select max(a) from boring;
|
|
max(a)
|
|
7
|
|
insert into boring_keyless values (99);
|
|
select * from boring_keyless order by a;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
4
|
|
99
|
|
insert into empty_default (b) values (99);
|
|
Expect 1,99
|
|
select * from empty_default;
|
|
a b
|
|
1 99
|
|
insert into empty_specific (b) values (99);
|
|
Expect 73,99
|
|
select * from empty_specific;
|
|
a b
|
|
73 99
|
|
insert into big_varchars(b) values (repeat('IMBJC', 400));
|
|
Expect 6
|
|
select max(a) from big_varchars;
|
|
max(a)
|
|
6
|
|
----------------------------------------
|
|
7. Cleanup
|
|
----------------------------------------
|
|
drop table boring;
|
|
drop table boring_keyless;
|
|
drop table empty_default;
|
|
drop table empty_specific;
|
|
drop table big_varchars;
|
|
drop table filler1, filler2, filler3, filler4;
|
|
drop table filler5, filler6, filler7, filler8;
|
|
----------------------------------------
|
|
8. Use ndb_restore metadata restore
|
|
----------------------------------------
|
|
SET @old_ndb_metadata_check = @@global.ndb_metadata_check;
|
|
SET GLOBAL ndb_metadata_check = false;
|
|
----------------------------------------
|
|
9. Check autoincrement info
|
|
----------------------------------------
|
|
With just NdbApi metadata restored, auto_increment values are set to default values
|
|
select table_schema, table_name, auto_increment from information_schema.tables where table_schema="test" and table_name="boring";
|
|
TABLE_SCHEMA TABLE_NAME AUTO_INCREMENT
|
|
select table_schema, table_name, auto_increment from information_schema.tables where table_schema="test" and table_name="empty_default";
|
|
TABLE_SCHEMA TABLE_NAME AUTO_INCREMENT
|
|
select table_schema, table_name, auto_increment from information_schema.tables where table_schema="test" and table_name="empty_specific";
|
|
TABLE_SCHEMA TABLE_NAME AUTO_INCREMENT
|
|
select table_schema, table_name, auto_increment from information_schema.tables where table_schema="test" and table_name="big_varchars";
|
|
TABLE_SCHEMA TABLE_NAME AUTO_INCREMENT
|
|
----------------------------------------
|
|
10. Restore data
|
|
----------------------------------------
|
|
----------------------------------------
|
|
11. Check autoincrement info
|
|
----------------------------------------
|
|
Expect 7
|
|
select table_schema, table_name, auto_increment from information_schema.tables where table_schema="test" and table_name="boring";
|
|
TABLE_SCHEMA TABLE_NAME AUTO_INCREMENT
|
|
Expect 1
|
|
select table_schema, table_name, auto_increment from information_schema.tables where table_schema="test" and table_name="empty_default";
|
|
TABLE_SCHEMA TABLE_NAME AUTO_INCREMENT
|
|
Expect 73
|
|
select table_schema, table_name, auto_increment from information_schema.tables where table_schema="test" and table_name="empty_specific";
|
|
TABLE_SCHEMA TABLE_NAME AUTO_INCREMENT
|
|
Expect 6
|
|
select table_schema, table_name, auto_increment from information_schema.tables where table_schema="test" and table_name="big_varchars";
|
|
TABLE_SCHEMA TABLE_NAME AUTO_INCREMENT
|
|
SET GLOBAL ndb_metadata_check = @old_ndb_metadata_check;
|
|
----------------------------------------
|
|
6. Test via inserts
|
|
----------------------------------------
|
|
insert into boring (b) values (99);
|
|
Expect 7
|
|
select max(a) from boring;
|
|
max(a)
|
|
7
|
|
insert into boring_keyless values (99);
|
|
select * from boring_keyless order by a;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
4
|
|
99
|
|
insert into empty_default (b) values (99);
|
|
Expect 1,99
|
|
select * from empty_default;
|
|
a b
|
|
1 99
|
|
insert into empty_specific (b) values (99);
|
|
Expect 73,99
|
|
select * from empty_specific;
|
|
a b
|
|
73 99
|
|
insert into big_varchars(b) values (repeat('IMBJC', 400));
|
|
Expect 6
|
|
select max(a) from big_varchars;
|
|
max(a)
|
|
6
|
|
----------------------------------------
|
|
7. Cleanup
|
|
----------------------------------------
|
|
drop table boring;
|
|
drop table boring_keyless;
|
|
drop table empty_default;
|
|
drop table empty_specific;
|
|
drop table big_varchars;
|