mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
193 lines
5.7 KiB
Text
193 lines
5.7 KiB
Text
include/master-slave.inc
|
|
[connection master]
|
|
connection master;
|
|
CREATE TABLE t1 (a int, b varchar(100), fulltext(b)) engine=MyISAM;
|
|
INSERT INTO t1 VALUES (1,"a"), (2,"b");
|
|
UPDATE t1 SET b='A' WHERE a=1;
|
|
DELETE FROM t1 WHERE a=2;
|
|
connection slave;
|
|
connection slave;
|
|
SELECT * FROM t1 ORDER BY a;
|
|
a b
|
|
1 A
|
|
connection master;
|
|
DROP TABLE t1;
|
|
connection master;
|
|
CREATE TABLE t1 (d INT PRIMARY KEY) ENGINE=myisam;
|
|
INSERT INTO t1 VALUES (0);
|
|
INSERT INTO t1 SELECT d+1 FROM t1;
|
|
INSERT INTO t1 SELECT d+2 FROM t1;
|
|
INSERT INTO t1 SELECT d+4 FROM t1;
|
|
INSERT INTO t1 SELECT d+8 FROM t1;
|
|
INSERT INTO t1 SELECT d+16 FROM t1;
|
|
INSERT INTO t1 SELECT d+32 FROM t1;
|
|
INSERT INTO t1 SELECT d+64 FROM t1;
|
|
INSERT INTO t1 SELECT d+128 FROM t1;
|
|
INSERT INTO t1 SELECT d+256 FROM t1;
|
|
INSERT INTO t1 SELECT d+512 FROM t1;
|
|
CREATE TABLE t2 (a INT, b INT, c INT, d INT,
|
|
KEY wrong_key(a),
|
|
KEY expected_key(b,c),
|
|
KEY wrong_key2(c)) ENGINE=myisam;
|
|
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d FROM t1;
|
|
connection slave;
|
|
connection slave;
|
|
ANALYZE TABLE t2;
|
|
Table Op Msg_type Msg_text
|
|
test.t2 analyze status OK
|
|
# Slave will crash if using the wrong or no index
|
|
SET GLOBAL debug_dbug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan";
|
|
connection master;
|
|
UPDATE t2 SET d=10042 WHERE d=42;
|
|
DELETE FROM t2 WHERE d=53;
|
|
connection slave;
|
|
connection slave;
|
|
SET GLOBAL debug_dbug="";
|
|
SELECT * FROM t2 WHERE d IN (10042,53);
|
|
a b c d
|
|
4 1 5 10042
|
|
connection master;
|
|
DROP TABLE t2;
|
|
CREATE TABLE t2 (a INT, b INT, c INT, d INT NOT NULL, e INT,
|
|
UNIQUE wrong_key3(a,e),
|
|
KEY wrong_key4(b,c),
|
|
UNIQUE expected_key(d)) ENGINE=myisam;
|
|
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d, NULL FROM t1;
|
|
connection slave;
|
|
connection slave;
|
|
ANALYZE TABLE t2;
|
|
Table Op Msg_type Msg_text
|
|
test.t2 analyze status OK
|
|
# Slave will crash if using the wrong or no index
|
|
SET GLOBAL debug_dbug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan";
|
|
connection master;
|
|
UPDATE t2 SET d=10042 WHERE d=42;
|
|
DELETE FROM t2 WHERE d=53;
|
|
connection slave;
|
|
connection slave;
|
|
SET GLOBAL debug_dbug="";
|
|
SELECT * FROM t2 WHERE d IN (10042,53);
|
|
a b c d e
|
|
4 1 5 10042 NULL
|
|
connection master;
|
|
DROP TABLE t2;
|
|
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, d INT NOT NULL,
|
|
KEY wrong_key5(b),
|
|
UNIQUE expected_key(d),
|
|
KEY wrong_key6(c)) ENGINE=myisam;
|
|
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d FROM t1;
|
|
connection slave;
|
|
connection slave;
|
|
# Slave will crash if using the wrong or no index
|
|
SET GLOBAL debug_dbug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan";
|
|
connection master;
|
|
UPDATE t2 SET d=10042 WHERE d=42;
|
|
DELETE FROM t2 WHERE d=53;
|
|
connection slave;
|
|
connection slave;
|
|
SET GLOBAL debug_dbug="";
|
|
SELECT * FROM t2 WHERE d IN (10042,53);
|
|
a b c d
|
|
4 1 5 10042
|
|
connection master;
|
|
DROP TABLE t2;
|
|
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, d INT NOT NULL,
|
|
KEY expected_key(b),
|
|
KEY wrong_key7(d),
|
|
KEY wrong_key8(c)) ENGINE=myisam;
|
|
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d FROM t1;
|
|
connection slave;
|
|
connection slave;
|
|
# Slave will crash if using the wrong or no index
|
|
SET GLOBAL debug_dbug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan";
|
|
connection master;
|
|
UPDATE t2 SET d=10042 WHERE d=42;
|
|
DELETE FROM t2 WHERE d=53;
|
|
connection slave;
|
|
connection slave;
|
|
SET GLOBAL debug_dbug="";
|
|
SELECT * FROM t2 WHERE d IN (10042,53);
|
|
a b c d
|
|
4 1 5 10042
|
|
connection master;
|
|
DROP TABLE t2;
|
|
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, d INT,
|
|
UNIQUE wrong_key9(d),
|
|
KEY wrong_key10(a),
|
|
PRIMARY KEY expected_key(c,b)) ENGINE=innodb;
|
|
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d FROM t1;
|
|
connection slave;
|
|
connection slave;
|
|
# Slave will crash if using the wrong or no index
|
|
SET GLOBAL debug_dbug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan,slave_crash_if_index_scan";
|
|
connection master;
|
|
UPDATE t2 SET d=10042 WHERE d=42;
|
|
DELETE FROM t2 WHERE d=53;
|
|
connection slave;
|
|
connection slave;
|
|
SET GLOBAL debug_dbug="";
|
|
SELECT * FROM t2 WHERE d IN (10042,53);
|
|
a b c d
|
|
4 1 5 10042
|
|
connection master;
|
|
DROP TABLE t2;
|
|
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, d INT, e INT,
|
|
UNIQUE wrong_key11(e),
|
|
KEY wrong_key12(a),
|
|
KEY expected_key(c,b)) ENGINE=innodb;
|
|
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d, IF(d<10, d, NULL) FROM t1;
|
|
connection slave;
|
|
connection slave;
|
|
ANALYZE TABLE t2;
|
|
Table Op Msg_type Msg_text
|
|
test.t2 analyze status OK
|
|
# Slave will crash if using the wrong or no index
|
|
SET GLOBAL debug_dbug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan";
|
|
connection master;
|
|
UPDATE t2 SET d=10042 WHERE d=42;
|
|
DELETE FROM t2 WHERE d=53;
|
|
connection slave;
|
|
connection slave;
|
|
SET GLOBAL debug_dbug="";
|
|
SELECT * FROM t2 WHERE d IN (10042,53);
|
|
a b c d e
|
|
4 1 5 10042 NULL
|
|
connection master;
|
|
DROP TABLE t2;
|
|
CREATE TABLE t2 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL, d INT, e INT,
|
|
KEY wrong_key13(a),
|
|
UNIQUE expected_key(e),
|
|
KEY wrong_key14(c,b)) ENGINE=innodb;
|
|
INSERT INTO t2 SELECT d DIV 10, d MOD 41, d MOD 37, d, IF(d<10, d, NULL) FROM t1;
|
|
connection slave;
|
|
connection slave;
|
|
# Slave will crash if using the wrong or no index
|
|
SET GLOBAL debug_dbug="+d,slave_crash_if_wrong_index,slave_crash_if_table_scan";
|
|
connection master;
|
|
UPDATE t2 SET d=10042 WHERE d=42;
|
|
DELETE FROM t2 WHERE d=53;
|
|
connection slave;
|
|
connection slave;
|
|
SET GLOBAL debug_dbug="";
|
|
SELECT * FROM t2 WHERE d IN (10042,53);
|
|
a b c d e
|
|
4 1 5 10042 NULL
|
|
connection master;
|
|
DROP TABLE t2;
|
|
CREATE TABLE t2 (a INT NOT NULL, d INT) ENGINE=innodb;
|
|
INSERT INTO t2 SELECT d DIV 10, d FROM t1;
|
|
UPDATE t2 SET d=10042 WHERE d=42;
|
|
DELETE FROM t2 WHERE d=53;
|
|
connection slave;
|
|
connection slave;
|
|
SELECT * FROM t2 WHERE d IN (10042,53);
|
|
a d
|
|
4 10042
|
|
connection master;
|
|
DROP TABLE t2;
|
|
connection master;
|
|
DROP TABLE t1;
|
|
connection slave;
|
|
connection slave;
|
|
SET GLOBAL debug_dbug="";
|
|
include/rpl_end.inc
|