mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
MDEV-6076: Optimize the test.
Remove unnecessary restarts by testing multiple tables across a restart. This change almost halves the execution time. Some further restarts could be removed with additional effort.
This commit is contained in:
parent
8777458a6e
commit
cb0ce5c2e9
3 changed files with 129 additions and 341 deletions
|
@ -41,21 +41,17 @@ eval SELECT MAX(a) AS `Expect 124` FROM $table;
|
|||
|
||||
eval OPTIMIZE TABLE $table;
|
||||
|
||||
eval SHOW CREATE TABLE $table;
|
||||
|
||||
--source include/restart_mysqld.inc
|
||||
|
||||
--echo # We expect the counter to still be 125
|
||||
eval SHOW CREATE TABLE $table;
|
||||
|
||||
eval DELETE FROM $table WHERE a >= 123;
|
||||
|
||||
eval CREATE UNIQUE INDEX idx_aa ON $table(a);
|
||||
eval CREATE TABLE i$table(a INT AUTO_INCREMENT, INDEX(a)) AUTO_INCREMENT=125 ENGINE=InnoDB;
|
||||
eval CREATE UNIQUE INDEX idx_aa ON i$table(a);
|
||||
|
||||
--source include/restart_mysqld.inc
|
||||
|
||||
eval INSERT INTO $table VALUES(0), (0);
|
||||
eval INSERT INTO i$table VALUES(0), (0);
|
||||
|
||||
eval SELECT MAX(a) AS `Expect 126` FROM $table;
|
||||
eval SELECT MAX(a) AS `Expect 126` FROM i$table;
|
||||
|
||||
eval DROP TABLE $table;
|
||||
eval DROP TABLE $table, i$table;
|
||||
|
|
|
@ -204,7 +204,6 @@ a
|
|||
20
|
||||
30
|
||||
31
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
CREATE TABLE t12(a DOUBLE AUTO_INCREMENT KEY) ENGINE = InnoDB;
|
||||
INSERT INTO t12 VALUES(0), (0), (0), (0), (-1), (-10), (0),
|
||||
(20), (30), (31);
|
||||
|
@ -220,185 +219,9 @@ a
|
|||
20
|
||||
30
|
||||
31
|
||||
CREATE TABLE t13(a INT AUTO_INCREMENT PRIMARY KEY) ENGINE = InnoDB,
|
||||
AUTO_INCREMENT = 1234;
|
||||
# Scenario 1: Normal restart, to test if the counters are persisted
|
||||
# We expect these results should be equal to above SELECTs
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
-10
|
||||
-1
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
20
|
||||
30
|
||||
31
|
||||
SELECT * FROM t2;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
8
|
||||
10
|
||||
11
|
||||
20
|
||||
30
|
||||
31
|
||||
SELECT * FROM t3;
|
||||
a
|
||||
-10
|
||||
-1
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
20
|
||||
30
|
||||
31
|
||||
1024
|
||||
4096
|
||||
SELECT * FROM t4;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
8
|
||||
10
|
||||
11
|
||||
20
|
||||
30
|
||||
31
|
||||
1024
|
||||
4096
|
||||
SELECT * FROM t5;
|
||||
a
|
||||
-10
|
||||
-1
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
20
|
||||
30
|
||||
31
|
||||
1000000
|
||||
1000005
|
||||
SELECT * FROM t6;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
8
|
||||
10
|
||||
11
|
||||
20
|
||||
30
|
||||
31
|
||||
1000000
|
||||
1000005
|
||||
SELECT * FROM t7;
|
||||
a
|
||||
-10
|
||||
-1
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
20
|
||||
30
|
||||
31
|
||||
100000000
|
||||
100000008
|
||||
SELECT * FROM t8;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
8
|
||||
10
|
||||
11
|
||||
20
|
||||
30
|
||||
31
|
||||
100000000
|
||||
100000008
|
||||
SELECT * FROM t9;
|
||||
a
|
||||
-10
|
||||
-1
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
20
|
||||
30
|
||||
31
|
||||
100000000000
|
||||
100000000006
|
||||
SELECT * FROM t10;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
8
|
||||
10
|
||||
11
|
||||
20
|
||||
30
|
||||
31
|
||||
100000000000
|
||||
100000000006
|
||||
SELECT * FROM t11;
|
||||
a
|
||||
-10
|
||||
-1
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
20
|
||||
30
|
||||
31
|
||||
SELECT * FROM t12;
|
||||
a
|
||||
-10
|
||||
-1
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
20
|
||||
30
|
||||
31
|
||||
SELECT * FROM t13;
|
||||
a
|
||||
SHOW CREATE TABLE t13;
|
||||
Table Create Table
|
||||
t13 CREATE TABLE `t13` (
|
||||
`a` int(11) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1234 DEFAULT CHARSET=latin1
|
||||
INSERT INTO t13 VALUES(0);
|
||||
SELECT a AS `Expect 1234` FROM t13;
|
||||
Expect 1234
|
||||
1234
|
||||
# Scenario 2: Delete some values, to test the counters should not be the
|
||||
# one which is the largest in current table
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
DELETE FROM t1 WHERE a > 30;
|
||||
SELECT MAX(a) AS `Expect 30` FROM t1;
|
||||
Expect 30
|
||||
|
@ -419,6 +242,19 @@ DELETE FROM t9 WHERE a > 100000000000;
|
|||
SELECT MAX(a) AS `Expect 100000000000` FROM t9;
|
||||
Expect 100000000000
|
||||
100000000000
|
||||
CREATE TABLE t13(a INT AUTO_INCREMENT PRIMARY KEY) ENGINE = InnoDB,
|
||||
AUTO_INCREMENT = 1234;
|
||||
SHOW CREATE TABLE t13;
|
||||
Table Create Table
|
||||
t13 CREATE TABLE `t13` (
|
||||
`a` int(11) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1234 DEFAULT CHARSET=latin1
|
||||
INSERT INTO t13 VALUES(0);
|
||||
SELECT a AS `Expect 1234` FROM t13;
|
||||
Expect 1234
|
||||
1234
|
||||
DROP TABLE t13;
|
||||
INSERT INTO t1 VALUES(0), (0);
|
||||
SELECT MAX(a) AS `Expect 33` FROM t1;
|
||||
Expect 33
|
||||
|
@ -543,7 +379,6 @@ INSERT INTO t7 VALUES(0);
|
|||
SELECT MAX(a) AS `Expect 100000109` FROM t7;
|
||||
Expect 100000109
|
||||
100000109
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
INSERT INTO t9 VALUES(100), (200);
|
||||
UPDATE t9 SET a = 100000000105 WHERE a = 5;
|
||||
UPDATE t9 SET a = 100000000100 WHERE a = 100;
|
||||
|
@ -593,6 +428,7 @@ INSERT INTO t5 VALUES(1100200);
|
|||
DELETE FROM t5 WHERE a = 1100200;
|
||||
INSERT INTO t7 VALUES(100000200);
|
||||
DELETE FROM t7 WHERE a = 100000200;
|
||||
# Ensure that all changes before the server is killed are persisted.
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
INSERT INTO t9 VALUES(100000000200);
|
||||
DELETE FROM t9 WHERE a = 100000000200;
|
||||
|
@ -648,12 +484,20 @@ SELECT * FROM t9;
|
|||
a
|
||||
1
|
||||
2
|
||||
# Ensure that all changes before the server is killed are persisted.
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
TRUNCATE TABLE t1;
|
||||
TRUNCATE TABLE t3;
|
||||
TRUNCATE TABLE t5;
|
||||
TRUNCATE TABLE t7;
|
||||
TRUNCATE TABLE t9;
|
||||
# Scenario 7: Test explicit rename table won't change the counter
|
||||
RENAME TABLE t9 to t19;
|
||||
INSERT INTO t19 VALUES(0), (0);
|
||||
SELECT * FROM t19;
|
||||
a
|
||||
1
|
||||
2
|
||||
# Kill and restart
|
||||
INSERT INTO t1 VALUES(0), (0);
|
||||
SELECT * FROM t1;
|
||||
|
@ -675,14 +519,6 @@ SELECT * FROM t7;
|
|||
a
|
||||
1
|
||||
2
|
||||
INSERT INTO t9 VALUES(0), (0);
|
||||
SELECT * FROM t9;
|
||||
a
|
||||
1
|
||||
2
|
||||
# Scenario 7: Test explicit rename table won't change the counter
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
RENAME TABLE t9 to t19;
|
||||
INSERT INTO t19 VALUES(0), (0);
|
||||
SELECT * FROM t19;
|
||||
a
|
||||
|
@ -691,7 +527,6 @@ a
|
|||
3
|
||||
4
|
||||
DELETE FROM t19 WHERE a = 4;
|
||||
# Kill and restart
|
||||
RENAME TABLE t19 to t9;
|
||||
INSERT INTO t9 VALUES(0), (0);
|
||||
SELECT * FROM t9;
|
||||
|
@ -799,20 +634,19 @@ INSERT INTO t3 VALUES(0);
|
|||
SELECT MAX(a) AS `Expect 120` FROM t3;
|
||||
Expect 120
|
||||
120
|
||||
INSERT INTO mdev6076a SET b=0;
|
||||
INSERT INTO mdev6076a SET b=NULL;
|
||||
SELECT * FROM mdev6076a;
|
||||
a b
|
||||
1 2
|
||||
2 1
|
||||
3 0
|
||||
INSERT INTO mdev6076b SET b=0;
|
||||
3 NULL
|
||||
INSERT INTO mdev6076b SET b=NULL;
|
||||
SELECT * FROM mdev6076b;
|
||||
a b
|
||||
100 2
|
||||
101 1
|
||||
102 0
|
||||
102 NULL
|
||||
DROP TABLE mdev6076a, mdev6076b;
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
INSERT INTO t3 VALUES(0), (0), (200), (210);
|
||||
# Test the different algorithms in ALTER TABLE
|
||||
CREATE TABLE t_inplace LIKE t3;
|
||||
|
@ -890,26 +724,18 @@ OPTIMIZE TABLE t_inplace;
|
|||
Table Op Msg_type Msg_text
|
||||
test.t_inplace optimize note Table does not support optimize, doing recreate + analyze instead
|
||||
test.t_inplace optimize status OK
|
||||
SHOW CREATE TABLE t_inplace;
|
||||
Table Create Table
|
||||
t_inplace CREATE TABLE `t_inplace` (
|
||||
`a` smallint(6) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=125 DEFAULT CHARSET=latin1
|
||||
# We expect the counter to still be 125
|
||||
SHOW CREATE TABLE t_inplace;
|
||||
Table Create Table
|
||||
t_inplace CREATE TABLE `t_inplace` (
|
||||
`a` smallint(6) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=125 DEFAULT CHARSET=latin1
|
||||
DELETE FROM t_inplace WHERE a >= 123;
|
||||
CREATE UNIQUE INDEX idx_aa ON t_inplace(a);
|
||||
CREATE TABLE it_inplace(a INT AUTO_INCREMENT, INDEX(a)) AUTO_INCREMENT=125 ENGINE=InnoDB;
|
||||
CREATE UNIQUE INDEX idx_aa ON it_inplace(a);
|
||||
INSERT INTO t_inplace VALUES(0), (0);
|
||||
INSERT INTO it_inplace VALUES(0), (0);
|
||||
SELECT MAX(a) AS `Expect 126` FROM t_inplace;
|
||||
Expect 126
|
||||
126
|
||||
DROP TABLE t_inplace;
|
||||
SELECT MAX(a) AS `Expect 126` FROM it_inplace;
|
||||
Expect 126
|
||||
126
|
||||
DROP TABLE t_inplace, it_inplace;
|
||||
CREATE TABLE t_copy LIKE t3;
|
||||
INSERT INTO t_copy SELECT * FROM t3;
|
||||
SELECT * FROM t_copy;
|
||||
|
@ -985,26 +811,18 @@ OPTIMIZE TABLE t_copy;
|
|||
Table Op Msg_type Msg_text
|
||||
test.t_copy optimize note Table does not support optimize, doing recreate + analyze instead
|
||||
test.t_copy optimize status OK
|
||||
SHOW CREATE TABLE t_copy;
|
||||
Table Create Table
|
||||
t_copy CREATE TABLE `t_copy` (
|
||||
`a` smallint(6) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=125 DEFAULT CHARSET=latin1
|
||||
# We expect the counter to still be 125
|
||||
SHOW CREATE TABLE t_copy;
|
||||
Table Create Table
|
||||
t_copy CREATE TABLE `t_copy` (
|
||||
`a` smallint(6) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`a`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=125 DEFAULT CHARSET=latin1
|
||||
DELETE FROM t_copy WHERE a >= 123;
|
||||
CREATE UNIQUE INDEX idx_aa ON t_copy(a);
|
||||
CREATE TABLE it_copy(a INT AUTO_INCREMENT, INDEX(a)) AUTO_INCREMENT=125 ENGINE=InnoDB;
|
||||
CREATE UNIQUE INDEX idx_aa ON it_copy(a);
|
||||
INSERT INTO t_copy VALUES(0), (0);
|
||||
INSERT INTO it_copy VALUES(0), (0);
|
||||
SELECT MAX(a) AS `Expect 126` FROM t_copy;
|
||||
Expect 126
|
||||
126
|
||||
DROP TABLE t_copy;
|
||||
SELECT MAX(a) AS `Expect 126` FROM it_copy;
|
||||
Expect 126
|
||||
126
|
||||
DROP TABLE t_copy, it_copy;
|
||||
# Scenario 9: Test the sql_mode = NO_AUTO_VALUE_ON_ZERO
|
||||
CREATE TABLE t30 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT, key(b)) ENGINE = InnoDB;
|
||||
set SQL_MODE = NO_AUTO_VALUE_ON_ZERO;
|
||||
|
@ -1029,6 +847,7 @@ a b
|
|||
202 5
|
||||
203 6
|
||||
204 7
|
||||
# Ensure that all changes before the server is killed are persisted.
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
CREATE TABLE t31 (a INT) ENGINE = InnoDB;
|
||||
INSERT INTO t31 VALUES(1), (2);
|
||||
|
@ -1043,6 +862,43 @@ a b
|
|||
2 2
|
||||
4 3
|
||||
5 4
|
||||
SET SQL_MODE = 0;
|
||||
# Scenario 10: Rollback would not rollback the counter
|
||||
CREATE TABLE t32 (
|
||||
a BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
|
||||
INSERT INTO t32 VALUES(0), (0);
|
||||
# Ensure that all changes before the server is killed are persisted.
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
START TRANSACTION;
|
||||
INSERT INTO t32 VALUES(0), (0);
|
||||
SELECT MAX(a) AS `Expect 4` FROM t32;
|
||||
Expect 4
|
||||
4
|
||||
DELETE FROM t32 WHERE a >= 2;
|
||||
ROLLBACK;
|
||||
# Scenario 11: Test duplicate primary key/secondary key will not stop
|
||||
# increasing the counter
|
||||
CREATE TABLE t33 (
|
||||
a BIGINT NOT NULL PRIMARY KEY,
|
||||
b BIGINT NOT NULL AUTO_INCREMENT,
|
||||
KEY(b)) ENGINE = InnoDB;
|
||||
INSERT INTO t33 VALUES(1, NULL);
|
||||
INSERT INTO t33 VALUES(2, NULL);
|
||||
INSERT INTO t33 VALUES(2, NULL);
|
||||
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
|
||||
INSERT INTO t33 VALUES(3, NULL);
|
||||
SELECT MAX(b) AS `Expect 4` FROM t33;
|
||||
Expect 4
|
||||
4
|
||||
TRUNCATE TABLE t33;
|
||||
INSERT INTO t33 VALUES(1, NULL);
|
||||
INSERT INTO t33 VALUES(2, NULL);
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
START TRANSACTION;
|
||||
UPDATE t33 SET a = 10 WHERE a = 1;
|
||||
INSERT INTO t33 VALUES(2, NULL);
|
||||
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
|
||||
COMMIT;
|
||||
# Kill and restart
|
||||
# This will not insert 0
|
||||
INSERT INTO t31(a) VALUES(6), (0);
|
||||
|
@ -1080,19 +936,6 @@ a b
|
|||
0 6
|
||||
300 7
|
||||
SET SQL_MODE = 0;
|
||||
# Scenario 10: Rollback would not rollback the counter
|
||||
CREATE TABLE t32 (
|
||||
a BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
|
||||
INSERT INTO t32 VALUES(0), (0);
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
START TRANSACTION;
|
||||
INSERT INTO t32 VALUES(0), (0);
|
||||
SELECT MAX(a) AS `Expect 4` FROM t32;
|
||||
Expect 4
|
||||
4
|
||||
DELETE FROM t32 WHERE a >= 2;
|
||||
ROLLBACK;
|
||||
# Kill and restart
|
||||
SELECT MAX(a) AS `Expect 2` FROM t32;
|
||||
Expect 2
|
||||
2
|
||||
|
@ -1100,32 +943,8 @@ INSERT INTO t32 VALUES(0), (0);
|
|||
SELECT MAX(a) AS `Expect 6` FROM t32;
|
||||
Expect 6
|
||||
6
|
||||
# Scenario 11: Test duplicate primary key/secondary key will not stop
|
||||
# increasing the counter
|
||||
CREATE TABLE t33 (
|
||||
a BIGINT NOT NULL PRIMARY KEY,
|
||||
b BIGINT NOT NULL AUTO_INCREMENT,
|
||||
KEY(b)) ENGINE = InnoDB;
|
||||
INSERT INTO t33 VALUES(1, NULL);
|
||||
INSERT INTO t33 VALUES(2, NULL);
|
||||
INSERT INTO t33 VALUES(2, NULL);
|
||||
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
|
||||
INSERT INTO t33 VALUES(3, NULL);
|
||||
SELECT MAX(b) AS `Expect 4` FROM t33;
|
||||
Expect 4
|
||||
4
|
||||
TRUNCATE TABLE t33;
|
||||
INSERT INTO t33 VALUES(1, NULL);
|
||||
INSERT INTO t33 VALUES(2, NULL);
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
START TRANSACTION;
|
||||
UPDATE t33 SET a = 10 WHERE a = 1;
|
||||
INSERT INTO t33 VALUES(2, NULL);
|
||||
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
|
||||
COMMIT;
|
||||
# Kill and restart
|
||||
INSERT INTO t33 VALUES(3, NULL);
|
||||
SELECT MAX(b) AS `Expect 4` FROM t33;
|
||||
Expect 4
|
||||
4
|
||||
DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t30, t32, t33;
|
||||
DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t30, t32, t33;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
--source include/have_innodb.inc
|
||||
# Restarting is not supported when testing the embedded server.
|
||||
--source include/not_embedded.inc
|
||||
|
||||
--echo #
|
||||
|
@ -84,45 +85,15 @@ INSERT INTO t11 VALUES(0), (0), (0), (0), (-1), (-10), (0),
|
|||
(20), (30), (31);
|
||||
SELECT * FROM t11;
|
||||
|
||||
# Since autoinc counter is persisted by redo logs, we don't want to
|
||||
# lose them on kill and restart, so to make the result after restart stable.
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
|
||||
CREATE TABLE t12(a DOUBLE AUTO_INCREMENT KEY) ENGINE = InnoDB;
|
||||
INSERT INTO t12 VALUES(0), (0), (0), (0), (-1), (-10), (0),
|
||||
(20), (30), (31);
|
||||
SELECT * FROM t12;
|
||||
|
||||
CREATE TABLE t13(a INT AUTO_INCREMENT PRIMARY KEY) ENGINE = InnoDB,
|
||||
AUTO_INCREMENT = 1234;
|
||||
|
||||
--echo # Scenario 1: Normal restart, to test if the counters are persisted
|
||||
--source include/restart_mysqld.inc
|
||||
|
||||
--echo # We expect these results should be equal to above SELECTs
|
||||
SELECT * FROM t1;
|
||||
SELECT * FROM t2;
|
||||
SELECT * FROM t3;
|
||||
SELECT * FROM t4;
|
||||
SELECT * FROM t5;
|
||||
SELECT * FROM t6;
|
||||
SELECT * FROM t7;
|
||||
SELECT * FROM t8;
|
||||
SELECT * FROM t9;
|
||||
SELECT * FROM t10;
|
||||
SELECT * FROM t11;
|
||||
SELECT * FROM t12;
|
||||
|
||||
SELECT * FROM t13;
|
||||
SHOW CREATE TABLE t13;
|
||||
INSERT INTO t13 VALUES(0);
|
||||
SELECT a AS `Expect 1234` FROM t13;
|
||||
|
||||
--echo # Scenario 2: Delete some values, to test the counters should not be the
|
||||
--echo # one which is the largest in current table
|
||||
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
|
||||
DELETE FROM t1 WHERE a > 30;
|
||||
SELECT MAX(a) AS `Expect 30` FROM t1;
|
||||
DELETE FROM t3 WHERE a > 2000;
|
||||
|
@ -134,8 +105,16 @@ SELECT MAX(a) AS `Expect 100000000` FROM t7;
|
|||
DELETE FROM t9 WHERE a > 100000000000;
|
||||
SELECT MAX(a) AS `Expect 100000000000` FROM t9;
|
||||
|
||||
CREATE TABLE t13(a INT AUTO_INCREMENT PRIMARY KEY) ENGINE = InnoDB,
|
||||
AUTO_INCREMENT = 1234;
|
||||
|
||||
--source include/restart_mysqld.inc
|
||||
|
||||
SHOW CREATE TABLE t13;
|
||||
INSERT INTO t13 VALUES(0);
|
||||
SELECT a AS `Expect 1234` FROM t13;
|
||||
DROP TABLE t13;
|
||||
|
||||
INSERT INTO t1 VALUES(0), (0);
|
||||
SELECT MAX(a) AS `Expect 33` FROM t1;
|
||||
INSERT INTO t3 VALUES(0), (0);
|
||||
|
@ -222,8 +201,6 @@ DELETE FROM t7 WHERE a > 100000105;
|
|||
INSERT INTO t7 VALUES(0);
|
||||
SELECT MAX(a) AS `Expect 100000109` FROM t7;
|
||||
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
|
||||
INSERT INTO t9 VALUES(100), (200);
|
||||
# Updating to bigger value will update the auto-increment counter
|
||||
UPDATE t9 SET a = 100000000105 WHERE a = 5;
|
||||
|
@ -268,6 +245,7 @@ DELETE FROM t5 WHERE a = 1100200;
|
|||
INSERT INTO t7 VALUES(100000200);
|
||||
DELETE FROM t7 WHERE a = 100000200;
|
||||
|
||||
--echo # Ensure that all changes before the server is killed are persisted.
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
|
||||
INSERT INTO t9 VALUES(100000000200);
|
||||
|
@ -313,6 +291,7 @@ SELECT * FROM t7;
|
|||
INSERT INTO t9 VALUES(0), (0);
|
||||
SELECT * FROM t9;
|
||||
|
||||
--echo # Ensure that all changes before the server is killed are persisted.
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
|
||||
TRUNCATE TABLE t1;
|
||||
|
@ -321,6 +300,12 @@ TRUNCATE TABLE t5;
|
|||
TRUNCATE TABLE t7;
|
||||
TRUNCATE TABLE t9;
|
||||
|
||||
--echo # Scenario 7: Test explicit rename table won't change the counter
|
||||
|
||||
RENAME TABLE t9 to t19;
|
||||
INSERT INTO t19 VALUES(0), (0);
|
||||
SELECT * FROM t19;
|
||||
|
||||
--source include/kill_and_restart_mysqld.inc
|
||||
|
||||
INSERT INTO t1 VALUES(0), (0);
|
||||
|
@ -335,20 +320,10 @@ SELECT * FROM t5;
|
|||
INSERT INTO t7 VALUES(0), (0);
|
||||
SELECT * FROM t7;
|
||||
|
||||
INSERT INTO t9 VALUES(0), (0);
|
||||
SELECT * FROM t9;
|
||||
|
||||
--echo # Scenario 7: Test explicit rename table won't change the counter
|
||||
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
|
||||
RENAME TABLE t9 to t19;
|
||||
INSERT INTO t19 VALUES(0), (0);
|
||||
SELECT * FROM t19;
|
||||
DELETE FROM t19 WHERE a = 4;
|
||||
|
||||
--source include/kill_and_restart_mysqld.inc
|
||||
|
||||
RENAME TABLE t19 to t9;
|
||||
INSERT INTO t9 VALUES(0), (0);
|
||||
SELECT * FROM t9;
|
||||
|
@ -413,14 +388,12 @@ ALGORITHM=INPLACE;
|
|||
INSERT INTO t3 VALUES(0);
|
||||
SELECT MAX(a) AS `Expect 120` FROM t3;
|
||||
|
||||
INSERT INTO mdev6076a SET b=0;
|
||||
INSERT INTO mdev6076a SET b=NULL;
|
||||
SELECT * FROM mdev6076a;
|
||||
INSERT INTO mdev6076b SET b=0;
|
||||
INSERT INTO mdev6076b SET b=NULL;
|
||||
SELECT * FROM mdev6076b;
|
||||
DROP TABLE mdev6076a, mdev6076b;
|
||||
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
|
||||
INSERT INTO t3 VALUES(0), (0), (200), (210);
|
||||
|
||||
--echo # Test the different algorithms in ALTER TABLE
|
||||
|
@ -445,6 +418,7 @@ SELECT * FROM t30 ORDER BY b;
|
|||
ALTER TABLE t30 MODIFY b MEDIUMINT;
|
||||
SELECT * FROM t30 ORDER BY b;
|
||||
|
||||
--echo # Ensure that all changes before the server is killed are persisted.
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
|
||||
CREATE TABLE t31 (a INT) ENGINE = InnoDB;
|
||||
|
@ -455,25 +429,6 @@ INSERT INTO t31 VALUES(3, 0), (4, NULL), (5, NULL);
|
|||
INSERT INTO t31 VALUES(6, 0);
|
||||
SELECT * FROM t31;
|
||||
|
||||
--source include/kill_and_restart_mysqld.inc
|
||||
|
||||
--echo # This will not insert 0
|
||||
INSERT INTO t31(a) VALUES(6), (0);
|
||||
SELECT * FROM t31;
|
||||
DROP TABLE t31;
|
||||
|
||||
set SQL_MODE = NO_AUTO_VALUE_ON_ZERO;
|
||||
|
||||
DELETE FROM t30 WHERE a = 0;
|
||||
UPDATE t30 set a = 0 where b = 5;
|
||||
SELECT * FROM t30 ORDER BY b;
|
||||
DELETE FROM t30 WHERE a = 0;
|
||||
|
||||
UPDATE t30 SET a = NULL WHERE b = 6;
|
||||
UPDATE t30 SET a = 300 WHERE b = 7;
|
||||
|
||||
SELECT * FROM t30 ORDER BY b;
|
||||
|
||||
SET SQL_MODE = 0;
|
||||
|
||||
--echo # Scenario 10: Rollback would not rollback the counter
|
||||
|
@ -482,6 +437,7 @@ a BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
|
|||
|
||||
INSERT INTO t32 VALUES(0), (0);
|
||||
|
||||
--echo # Ensure that all changes before the server is killed are persisted.
|
||||
set global innodb_flush_log_at_trx_commit=1;
|
||||
|
||||
START TRANSACTION;
|
||||
|
@ -490,12 +446,6 @@ SELECT MAX(a) AS `Expect 4` FROM t32;
|
|||
DELETE FROM t32 WHERE a >= 2;
|
||||
ROLLBACK;
|
||||
|
||||
--source include/kill_and_restart_mysqld.inc
|
||||
|
||||
SELECT MAX(a) AS `Expect 2` FROM t32;
|
||||
INSERT INTO t32 VALUES(0), (0);
|
||||
SELECT MAX(a) AS `Expect 6` FROM t32;
|
||||
|
||||
--echo # Scenario 11: Test duplicate primary key/secondary key will not stop
|
||||
--echo # increasing the counter
|
||||
|
||||
|
@ -527,7 +477,30 @@ COMMIT;
|
|||
|
||||
--source include/kill_and_restart_mysqld.inc
|
||||
|
||||
--echo # This will not insert 0
|
||||
INSERT INTO t31(a) VALUES(6), (0);
|
||||
SELECT * FROM t31;
|
||||
DROP TABLE t31;
|
||||
|
||||
set SQL_MODE = NO_AUTO_VALUE_ON_ZERO;
|
||||
|
||||
DELETE FROM t30 WHERE a = 0;
|
||||
UPDATE t30 set a = 0 where b = 5;
|
||||
SELECT * FROM t30 ORDER BY b;
|
||||
DELETE FROM t30 WHERE a = 0;
|
||||
|
||||
UPDATE t30 SET a = NULL WHERE b = 6;
|
||||
UPDATE t30 SET a = 300 WHERE b = 7;
|
||||
|
||||
SELECT * FROM t30 ORDER BY b;
|
||||
|
||||
SET SQL_MODE = 0;
|
||||
|
||||
SELECT MAX(a) AS `Expect 2` FROM t32;
|
||||
INSERT INTO t32 VALUES(0), (0);
|
||||
SELECT MAX(a) AS `Expect 6` FROM t32;
|
||||
|
||||
INSERT INTO t33 VALUES(3, NULL);
|
||||
SELECT MAX(b) AS `Expect 4` FROM t33;
|
||||
|
||||
DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t30, t32, t33;
|
||||
DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t30, t32, t33;
|
||||
|
|
Loading…
Reference in a new issue