mirror of
https://github.com/MariaDB/server.git
synced 2025-08-26 01:44:06 +03:00
Major replication test framework cleanup. This does the following: - Ensure that all tests clean up the replication state when they finish, by making check-testcase check the output of SHOW SLAVE STATUS. This implies: - Slave must not be running after test finished. This is good because it removes the risk for sporadic errors in subsequent tests when a test forgets to sync correctly. - Slave SQL and IO errors must be cleared when test ends. This is good because we will notice if a test gets an unexpected error in the slave threads near the end. - We no longer have to clean up before a test starts. - Ensure that all tests that wait for an error in one of the slave threads waits for a specific error. It is no longer possible to source wait_for_slave_[sql|io]_to_stop.inc when there is an error in one of the slave threads. This is good because: - If a test expects an error but there is a bug that causes another error to happen, or if it stops the slave thread without an error, then we will notice. - When developing tests, wait_for_*_to_[start|stop].inc will fail immediately if there is an error in the relevant slave thread. Before this patch, we had to wait for the timeout. - Remove duplicated and repeated code for setting up unusual replication topologies. Now, there is a single file that is capable of setting up arbitrary topologies (include/rpl_init.inc, but include/master-slave.inc is still available for the most common topology). Tests can now end with include/rpl_end.inc, which will clean up correctly no matter what topology is used. The topology can be changed with include/rpl_change_topology.inc. - Improved debug information when tests fail. This includes: - debug info is printed on all servers configured by include/rpl_init.inc - User can set $rpl_debug=1, which makes auxiliary replication files print relevant debug info. - Improved documentation for all auxiliary replication files. Now they describe purpose, usage, parameters, and side effects. - Many small code cleanups: - Made have_innodb.inc output a sensible error message. - Moved contents of rpl000017-slave.sh into rpl000017.test - Added mysqltest variables that expose the current state of disable_warnings/enable_warnings and friends. - Too many to list here: see per-file comments for details.
200 lines
6.1 KiB
Plaintext
200 lines
6.1 KiB
Plaintext
include/master-slave.inc
|
|
[connection master]
|
|
SET SQL_LOG_BIN= 0;
|
|
CREATE TABLE t1(`a` INT, `b` DATE DEFAULT NULL,
|
|
`c` INT DEFAULT NULL,
|
|
PRIMARY KEY(`a`)) ENGINE=Innodb DEFAULT CHARSET=LATIN1;
|
|
CREATE TABLE t2(`a` INT, `b` DATE DEFAULT NULL,
|
|
PRIMARY KEY(`a`)) ENGINE=Innodb DEFAULT CHARSET=LATIN1;
|
|
CREATE TABLE t3(`a` INT, `b` DATE DEFAULT NULL,
|
|
PRIMARY KEY(`a`)) ENGINE=Innodb DEFAULT CHARSET=LATIN1;
|
|
CREATE TABLE t4(`a` INT, `b` DATE DEFAULT NULL,
|
|
`c` INT DEFAULT NULL,
|
|
PRIMARY KEY(`a`)) ENGINE=Innodb DEFAULT CHARSET=LATIN1;
|
|
SET SQL_LOG_BIN= 1;
|
|
CREATE TABLE t1(`a` INT, `b` DATE DEFAULT NULL,
|
|
`c` INT DEFAULT NULL,
|
|
PRIMARY KEY(`a`)) ENGINE=Innodb DEFAULT CHARSET=LATIN1;
|
|
CREATE TABLE t2(`a` INT, `b` DATE DEFAULT NULL,
|
|
PRIMARY KEY(`a`)) ENGINE=Innodb DEFAULT CHARSET=LATIN1;
|
|
CREATE TABLE t3(`a` INT, `b` DATE DEFAULT '0000-00-00',
|
|
`c` INT DEFAULT 500,
|
|
PRIMARY KEY(`a`)) ENGINE=Innodb DEFAULT CHARSET=LATIN1;
|
|
CREATE TABLE t4(`a` INT, `b` DATE DEFAULT '0000-00-00',
|
|
PRIMARY KEY(`a`)) ENGINE=Innodb DEFAULT CHARSET=LATIN1;
|
|
************* EXECUTION WITH INSERTS *************
|
|
INSERT INTO t1(a,b,c) VALUES (1, null, 1);
|
|
INSERT INTO t1(a,b,c) VALUES (2,'1111-11-11', 2);
|
|
INSERT INTO t1(a,b) VALUES (3, null);
|
|
INSERT INTO t1(a,c) VALUES (4, 4);
|
|
INSERT INTO t1(a) VALUES (5);
|
|
INSERT INTO t2(a,b) VALUES (1, null);
|
|
INSERT INTO t2(a,b) VALUES (2,'1111-11-11');
|
|
INSERT INTO t2(a) VALUES (3);
|
|
INSERT INTO t3(a,b) VALUES (1, null);
|
|
INSERT INTO t3(a,b) VALUES (2,'1111-11-11');
|
|
INSERT INTO t3(a) VALUES (3);
|
|
INSERT INTO t4(a,b,c) VALUES (1, null, 1);
|
|
INSERT INTO t4(a,b,c) VALUES (2,'1111-11-11', 2);
|
|
INSERT INTO t4(a,b) VALUES (3, null);
|
|
INSERT INTO t4(a,c) VALUES (4, 4);
|
|
INSERT INTO t4(a) VALUES (5);
|
|
************* SHOWING THE RESULT SETS WITH INSERTS *************
|
|
TABLES t1 and t2 must be equal otherwise an error will be thrown.
|
|
include/diff_tables.inc [master:t1, slave:t1]
|
|
include/diff_tables.inc [master:t2, slave:t2]
|
|
TABLES t2 and t3 must be different.
|
|
SELECT * FROM t3 ORDER BY a;
|
|
a b
|
|
1 NULL
|
|
2 1111-11-11
|
|
3 NULL
|
|
SELECT * FROM t3 ORDER BY a;
|
|
a b c
|
|
1 NULL 500
|
|
2 1111-11-11 500
|
|
3 NULL 500
|
|
SELECT * FROM t4 ORDER BY a;
|
|
a b c
|
|
1 NULL 1
|
|
2 1111-11-11 2
|
|
3 NULL NULL
|
|
4 NULL 4
|
|
5 NULL NULL
|
|
SELECT * FROM t4 ORDER BY a;
|
|
a b
|
|
1 NULL
|
|
2 1111-11-11
|
|
3 NULL
|
|
4 NULL
|
|
5 NULL
|
|
************* EXECUTION WITH UPDATES and REPLACES *************
|
|
DELETE FROM t1;
|
|
INSERT INTO t1(a,b,c) VALUES (1,'1111-11-11', 1);
|
|
REPLACE INTO t1(a,b,c) VALUES (2,'1111-11-11', 2);
|
|
UPDATE t1 set b= NULL, c= 300 where a= 1;
|
|
REPLACE INTO t1(a,b,c) VALUES (2, NULL, 300);
|
|
************* SHOWING THE RESULT SETS WITH UPDATES and REPLACES *************
|
|
TABLES t1 and t2 must be equal otherwise an error will be thrown.
|
|
include/diff_tables.inc [master:t1, slave:t1]
|
|
************* CLEANING *************
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|
|
DROP TABLE t3;
|
|
DROP TABLE t4;
|
|
SET SQL_LOG_BIN= 0;
|
|
CREATE TABLE t1 (`a` INT, `b` BIT DEFAULT NULL, `c` BIT DEFAULT NULL,
|
|
PRIMARY KEY (`a`)) ENGINE= Innodb;
|
|
SET SQL_LOG_BIN= 1;
|
|
CREATE TABLE t1 (`a` INT, `b` BIT DEFAULT b'01', `c` BIT DEFAULT NULL,
|
|
PRIMARY KEY (`a`)) ENGINE= Innodb;
|
|
************* EXECUTION WITH INSERTS *************
|
|
INSERT INTO t1(a,b,c) VALUES (1, null, b'01');
|
|
INSERT INTO t1(a,b,c) VALUES (2,b'00', b'01');
|
|
INSERT INTO t1(a,b) VALUES (3, null);
|
|
INSERT INTO t1(a,c) VALUES (4, b'01');
|
|
INSERT INTO t1(a) VALUES (5);
|
|
************* SHOWING THE RESULT SETS WITH INSERTS *************
|
|
TABLES t1 and t2 must be different.
|
|
SELECT a,b+0,c+0 FROM t1 ORDER BY a;
|
|
a b+0 c+0
|
|
1 NULL 1
|
|
2 0 1
|
|
3 NULL NULL
|
|
4 NULL 1
|
|
5 NULL NULL
|
|
SELECT a,b+0,c+0 FROM t1 ORDER BY a;
|
|
a b+0 c+0
|
|
1 NULL 1
|
|
2 0 1
|
|
3 NULL NULL
|
|
4 NULL 1
|
|
5 NULL NULL
|
|
************* EXECUTION WITH UPDATES and REPLACES *************
|
|
DELETE FROM t1;
|
|
INSERT INTO t1(a,b,c) VALUES (1,b'00', b'01');
|
|
REPLACE INTO t1(a,b,c) VALUES (2,b'00',b'01');
|
|
UPDATE t1 set b= NULL, c= b'00' where a= 1;
|
|
REPLACE INTO t1(a,b,c) VALUES (2, NULL, b'00');
|
|
************* SHOWING THE RESULT SETS WITH UPDATES and REPLACES *************
|
|
TABLES t1 and t2 must be equal otherwise an error will be thrown.
|
|
include/diff_tables.inc [master:t1, slave:t1]
|
|
DROP TABLE t1;
|
|
################################################################################
|
|
# NULL ---> NOT NULL (STRICT MODE)
|
|
# UNCOMMENT THIS AFTER FIXING BUG#43992
|
|
################################################################################
|
|
################################################################################
|
|
# NULL ---> NOT NULL (NON-STRICT MODE)
|
|
################################################################################
|
|
SET SQL_LOG_BIN= 0;
|
|
CREATE TABLE t1(`a` INT NOT NULL, `b` INT,
|
|
PRIMARY KEY(`a`)) ENGINE=Innodb DEFAULT CHARSET=LATIN1;
|
|
CREATE TABLE t2(`a` INT NOT NULL, `b` INT,
|
|
PRIMARY KEY(`a`)) ENGINE=Innodb DEFAULT CHARSET=LATIN1;
|
|
CREATE TABLE t3(`a` INT NOT NULL, `b` INT,
|
|
PRIMARY KEY(`a`)) ENGINE=Innodb DEFAULT CHARSET=LATIN1;
|
|
SET SQL_LOG_BIN= 1;
|
|
CREATE TABLE t1(`a` INT NOT NULL, `b` INT NOT NULL,
|
|
`c` INT NOT NULL,
|
|
PRIMARY KEY(`a`)) ENGINE=Innodb DEFAULT CHARSET=LATIN1;
|
|
CREATE TABLE t2(`a` INT NOT NULL, `b` INT NOT NULL,
|
|
`c` INT,
|
|
PRIMARY KEY(`a`)) ENGINE=Innodb DEFAULT CHARSET=LATIN1;
|
|
CREATE TABLE t3(`a` INT NOT NULL, `b` INT NOT NULL,
|
|
`c` INT DEFAULT 500,
|
|
PRIMARY KEY(`a`)) ENGINE=Innodb DEFAULT CHARSET=LATIN1;
|
|
************* EXECUTION WITH INSERTS *************
|
|
INSERT INTO t1(a) VALUES (1);
|
|
INSERT INTO t1(a, b) VALUES (2, NULL);
|
|
INSERT INTO t1(a, b) VALUES (3, 1);
|
|
INSERT INTO t2(a) VALUES (1);
|
|
INSERT INTO t2(a, b) VALUES (2, NULL);
|
|
INSERT INTO t2(a, b) VALUES (3, 1);
|
|
INSERT INTO t3(a) VALUES (1);
|
|
INSERT INTO t3(a, b) VALUES (2, NULL);
|
|
INSERT INTO t3(a, b) VALUES (3, 1);
|
|
INSERT INTO t3(a, b) VALUES (4, 1);
|
|
REPLACE INTO t3(a, b) VALUES (5, null);
|
|
REPLACE INTO t3(a, b) VALUES (3, null);
|
|
UPDATE t3 SET b = NULL where a = 4;
|
|
************* SHOWING THE RESULT SETS *************
|
|
SELECT * FROM t1 ORDER BY a;
|
|
a b
|
|
1 NULL
|
|
2 NULL
|
|
3 1
|
|
SELECT * FROM t1 ORDER BY a;
|
|
a b c
|
|
1 0 0
|
|
2 0 0
|
|
3 1 0
|
|
SELECT * FROM t2 ORDER BY a;
|
|
a b
|
|
1 NULL
|
|
2 NULL
|
|
3 1
|
|
SELECT * FROM t2 ORDER BY a;
|
|
a b c
|
|
1 0 NULL
|
|
2 0 NULL
|
|
3 1 NULL
|
|
SELECT * FROM t3 ORDER BY a;
|
|
a b
|
|
1 NULL
|
|
2 NULL
|
|
3 NULL
|
|
4 NULL
|
|
5 NULL
|
|
SELECT * FROM t3 ORDER BY a;
|
|
a b c
|
|
1 0 500
|
|
2 0 500
|
|
3 0 500
|
|
4 0 500
|
|
5 0 500
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|
|
DROP TABLE t3;
|
|
include/rpl_end.inc
|