mirror of
https://github.com/MariaDB/server.git
synced 2025-12-07 17:42:39 +03:00
merged 5.1.29-rc
This commit is contained in:
@@ -139,15 +139,6 @@ drop table t1,t2,t3;
|
||||
# table
|
||||
#
|
||||
CREATE TABLE t1(a INT) ENGINE=BLACKHOLE;
|
||||
# NOTE: After exchanging open_ltable() by open_and_lock_tables() in
|
||||
# handle_delayed_insert() to fix problems with MERGE tables (Bug#26379),
|
||||
# problems with INSERT DELAYED and BLACKHOLE popped up. open_ltable()
|
||||
# does not check if the binlogging capabilities of the statement and the
|
||||
# table match. So the below used to succeed. But since INSERT DELAYED
|
||||
# switches to row-based logging in mixed-mode and BLACKHOLE cannot do
|
||||
# row-based logging, it could not really work. Until this problem is
|
||||
# correctly fixed, we have that error here.
|
||||
--error ER_BINLOG_LOGGING_IMPOSSIBLE
|
||||
INSERT DELAYED INTO t1 VALUES(1);
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
32
mysql-test/extra/rpl_tests/rpl_blackhole.test
Normal file
32
mysql-test/extra/rpl_tests/rpl_blackhole.test
Normal file
@@ -0,0 +1,32 @@
|
||||
# Check replication of one statement assuming that the engine on the
|
||||
# slave is a blackhole engine.
|
||||
|
||||
# Input:
|
||||
# $statement Statement to evaluate, it is assumed to change t1
|
||||
|
||||
# 1. Evaluate statement on master, it is assumed to change t1
|
||||
# 2. Wait for statement to be processed on slave
|
||||
# 3. SELECT from table t1 to see what was written
|
||||
# 4. Compare position on slave before executing statement and after
|
||||
# executing statement. If difference is >0, then something was
|
||||
# written to the binary log on the slave.
|
||||
|
||||
connection slave;
|
||||
let $before = query_get_value("SHOW MASTER STATUS", Position, 1);
|
||||
|
||||
--echo [on master]
|
||||
connection master;
|
||||
eval $statement;
|
||||
|
||||
--echo [on slave]
|
||||
sync_slave_with_master;
|
||||
--echo # Expect 0
|
||||
SELECT COUNT(*) FROM t1;
|
||||
let $after = query_get_value("SHOW MASTER STATUS", Position, 1);
|
||||
let $something_written = `select $after - $before != 0`;
|
||||
if ($something_written) {
|
||||
--echo >>> Something was written to binary log <<<
|
||||
}
|
||||
if (!$something_written) {
|
||||
--echo >>> Nothing was written to binary log <<<
|
||||
}
|
||||
@@ -43,8 +43,6 @@ INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2);
|
||||
UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c;
|
||||
UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f;
|
||||
ERROR HY000: Binary logging not possible. Message: Statement cannot be written atomically since more than one engine involved and at least one engine is self-logging
|
||||
UPDATE t1n, t1b SET e = 2, b = 3 WHERE f = c;
|
||||
ERROR HY000: Binary logging not possible. Message: Statement cannot be written atomically since more than one engine involved and at least one engine is self-logging
|
||||
TRUNCATE t1m;
|
||||
TRUNCATE t1b;
|
||||
TRUNCATE t1n;
|
||||
@@ -68,20 +66,21 @@ RESET MASTER;
|
||||
SET SESSION BINLOG_FORMAT=ROW;
|
||||
INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2);
|
||||
INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2);
|
||||
ERROR HY000: Binary logging not possible. Message: Row-based format required for this statement, but not allowed by this combination of engines
|
||||
INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2);
|
||||
UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c;
|
||||
ERROR HY000: Binary logging not possible. Message: Row-based format required for this statement, but not allowed by this combination of engines
|
||||
UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f;
|
||||
ERROR HY000: Binary logging not possible. Message: Statement cannot be written atomically since more than one engine involved and at least one engine is self-logging
|
||||
UPDATE t1n, t1b SET e = 2, b = 3 WHERE f = c;
|
||||
ERROR HY000: Binary logging not possible. Message: Row-based format required for this statement, but not allowed by this combination of engines
|
||||
ERROR HY000: Binary logging not possible. Message: Statement cannot be written atomically since more than one engine involved and at least one engine is self-logging
|
||||
show binlog events from <binlog_start>;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 # Query # # use `test`; BEGIN
|
||||
master-bin.000001 # Table_map # # table_id: # (test.t1m)
|
||||
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
|
||||
master-bin.000001 # Query # # use `test`; COMMIT
|
||||
master-bin.000001 # Query # # use `test`; BEGIN
|
||||
master-bin.000001 # Table_map # # table_id: # (test.t1b)
|
||||
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
|
||||
master-bin.000001 # Query # # use `test`; COMMIT
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Table_map # # table_id: # (test.t1n)
|
||||
master-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status)
|
||||
|
||||
@@ -141,7 +141,6 @@ master-bin.000001 # Query # # use `test`; COMMIT
|
||||
drop table t1,t2,t3;
|
||||
CREATE TABLE t1(a INT) ENGINE=BLACKHOLE;
|
||||
INSERT DELAYED INTO t1 VALUES(1);
|
||||
ERROR HY000: Binary logging not possible. Message: Row-based format required for this statement, but not allowed by this combination of engines
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(a INT, b INT) ENGINE=BLACKHOLE;
|
||||
DELETE FROM t1 WHERE a=10;
|
||||
|
||||
@@ -69,9 +69,6 @@ UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f;
|
||||
|
||||
#UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f;
|
||||
|
||||
error ER_BINLOG_LOGGING_IMPOSSIBLE;
|
||||
UPDATE t1n, t1b SET e = 2, b = 3 WHERE f = c;
|
||||
|
||||
TRUNCATE t1m;
|
||||
TRUNCATE t1b;
|
||||
TRUNCATE t1n;
|
||||
@@ -83,12 +80,10 @@ RESET MASTER;
|
||||
SET SESSION BINLOG_FORMAT=ROW;
|
||||
|
||||
INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2);
|
||||
error ER_BINLOG_LOGGING_IMPOSSIBLE;
|
||||
|
||||
INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2);
|
||||
INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2);
|
||||
|
||||
error ER_BINLOG_LOGGING_IMPOSSIBLE;
|
||||
UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c;
|
||||
error ER_BINLOG_LOGGING_IMPOSSIBLE;
|
||||
UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f;
|
||||
|
||||
|
||||
100
mysql-test/suite/rpl/r/rpl_blackhole.result
Normal file
100
mysql-test/suite/rpl/r/rpl_blackhole.result
Normal file
@@ -0,0 +1,100 @@
|
||||
stop slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
reset master;
|
||||
reset slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
start slave;
|
||||
CREATE TABLE t1 (a INT, b INT, c INT);
|
||||
CREATE TABLE t2 (a INT, b INT, c INT);
|
||||
ALTER TABLE t1 ENGINE=BLACKHOLE;
|
||||
INSERT INTO t2 VALUES (1,9,1), (2,9,2), (3,9,3), (4,9,4);
|
||||
[on master]
|
||||
INSERT INTO t1 VALUES (1,1,1),(2,1,2),(3,1,3),(4,1,4);
|
||||
[on slave]
|
||||
# Expect 0
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
0
|
||||
>>> Something was written to binary log <<<
|
||||
[on master]
|
||||
UPDATE t1 SET c = 2*c WHERE a % 2 = 0 AND b = 1;
|
||||
[on slave]
|
||||
# Expect 0
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
0
|
||||
>>> Something was written to binary log <<<
|
||||
[on master]
|
||||
DELETE FROM t1 WHERE a % 2 = 0 AND b = 1;
|
||||
[on slave]
|
||||
# Expect 0
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
0
|
||||
>>> Something was written to binary log <<<
|
||||
[on master]
|
||||
INSERT INTO t1 SELECT * FROM t2;
|
||||
[on slave]
|
||||
# Expect 0
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
0
|
||||
>>> Something was written to binary log <<<
|
||||
[on master]
|
||||
INSERT INTO t2 SELECT * FROM t1;
|
||||
[on slave]
|
||||
# Expect 0
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
0
|
||||
>>> Something was written to binary log <<<
|
||||
ALTER TABLE t1 ADD PRIMARY KEY pk_t1 (a,b);
|
||||
[on master]
|
||||
INSERT INTO t1 VALUES (1,2,1),(2,2,2),(3,2,3),(4,2,4);
|
||||
[on slave]
|
||||
# Expect 0
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
0
|
||||
>>> Something was written to binary log <<<
|
||||
[on master]
|
||||
UPDATE t1 SET c = 2*c WHERE a % 2 = 0 AND b = 2;
|
||||
[on slave]
|
||||
# Expect 0
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
0
|
||||
>>> Something was written to binary log <<<
|
||||
[on master]
|
||||
DELETE FROM t1 WHERE a % 2 = 0 AND b = 2;
|
||||
[on slave]
|
||||
# Expect 0
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
0
|
||||
>>> Something was written to binary log <<<
|
||||
ALTER TABLE t1 DROP PRIMARY KEY, ADD KEY key_t1 (a);
|
||||
[on master]
|
||||
INSERT INTO t1 VALUES (1,3,1),(2,3,2),(3,3,3),(4,3,4);
|
||||
[on slave]
|
||||
# Expect 0
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
0
|
||||
>>> Something was written to binary log <<<
|
||||
[on master]
|
||||
UPDATE t1 SET c = 2*c WHERE a % 2 = 0 AND b = 3;
|
||||
[on slave]
|
||||
# Expect 0
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
0
|
||||
>>> Something was written to binary log <<<
|
||||
[on master]
|
||||
DELETE FROM t1 WHERE a % 2 = 0 AND b = 3;
|
||||
[on slave]
|
||||
# Expect 0
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
0
|
||||
>>> Something was written to binary log <<<
|
||||
79
mysql-test/suite/rpl/t/rpl_blackhole.test
Normal file
79
mysql-test/suite/rpl/t/rpl_blackhole.test
Normal file
@@ -0,0 +1,79 @@
|
||||
--source include/master-slave.inc
|
||||
|
||||
# PURPOSE. Test that blackhole works with replication in all three
|
||||
# modes: STATEMENT, MIXED, and ROW.
|
||||
#
|
||||
# METHOD. We start by creating a table on the master and then change
|
||||
# the engine to use blackhole on the slave.
|
||||
#
|
||||
# After insert/update/delete of one or more rows, the test the
|
||||
# proceeds to check that replication is running after replicating an
|
||||
# change, that the blackhole engine does not contain anything (which
|
||||
# is just a check that the correct engine is used), and that something
|
||||
# is written to the binary log.
|
||||
#
|
||||
# Whe check INSERT, UPDATE, and DELETE statement for tables with no
|
||||
# key (forcing a range search on the slave), primary keys (using a
|
||||
# primary key lookup), and index/key with multiple matches (forcing an
|
||||
# index search).
|
||||
|
||||
# We start with no primary key
|
||||
CREATE TABLE t1 (a INT, b INT, c INT);
|
||||
CREATE TABLE t2 (a INT, b INT, c INT);
|
||||
|
||||
sync_slave_with_master;
|
||||
ALTER TABLE t1 ENGINE=BLACKHOLE;
|
||||
|
||||
connection master;
|
||||
INSERT INTO t2 VALUES (1,9,1), (2,9,2), (3,9,3), (4,9,4);
|
||||
sync_slave_with_master;
|
||||
|
||||
# Test insert, no primary key
|
||||
let $statement = INSERT INTO t1 VALUES (1,1,1),(2,1,2),(3,1,3),(4,1,4);
|
||||
source extra/rpl_tests/rpl_blackhole.test;
|
||||
|
||||
# Test update, no primary key
|
||||
let $statement = UPDATE t1 SET c = 2*c WHERE a % 2 = 0 AND b = 1;
|
||||
source extra/rpl_tests/rpl_blackhole.test;
|
||||
|
||||
# Test delete, no primary key
|
||||
let $statement = DELETE FROM t1 WHERE a % 2 = 0 AND b = 1;
|
||||
source extra/rpl_tests/rpl_blackhole.test;
|
||||
|
||||
# Test INSERT-SELECT into Blackhole, no primary key
|
||||
let $statement = INSERT INTO t1 SELECT * FROM t2;
|
||||
source extra/rpl_tests/rpl_blackhole.test;
|
||||
|
||||
# Test INSERT-SELECT from Blackhole, no primary key
|
||||
let $statement = INSERT INTO t2 SELECT * FROM t1;
|
||||
source extra/rpl_tests/rpl_blackhole.test;
|
||||
|
||||
connection master;
|
||||
ALTER TABLE t1 ADD PRIMARY KEY pk_t1 (a,b);
|
||||
|
||||
# Test insert, primary key
|
||||
let $statement = INSERT INTO t1 VALUES (1,2,1),(2,2,2),(3,2,3),(4,2,4);
|
||||
source extra/rpl_tests/rpl_blackhole.test;
|
||||
|
||||
# Test update, primary key
|
||||
let $statement = UPDATE t1 SET c = 2*c WHERE a % 2 = 0 AND b = 2;
|
||||
source extra/rpl_tests/rpl_blackhole.test;
|
||||
|
||||
# Test delete, primary key
|
||||
let $statement = DELETE FROM t1 WHERE a % 2 = 0 AND b = 2;
|
||||
source extra/rpl_tests/rpl_blackhole.test;
|
||||
|
||||
connection master;
|
||||
ALTER TABLE t1 DROP PRIMARY KEY, ADD KEY key_t1 (a);
|
||||
|
||||
# Test insert, key
|
||||
let $statement = INSERT INTO t1 VALUES (1,3,1),(2,3,2),(3,3,3),(4,3,4);
|
||||
source extra/rpl_tests/rpl_blackhole.test;
|
||||
|
||||
# Test update, key
|
||||
let $statement = UPDATE t1 SET c = 2*c WHERE a % 2 = 0 AND b = 3;
|
||||
source extra/rpl_tests/rpl_blackhole.test;
|
||||
|
||||
# Test delete, key
|
||||
let $statement = DELETE FROM t1 WHERE a % 2 = 0 AND b = 3;
|
||||
source extra/rpl_tests/rpl_blackhole.test;
|
||||
Reference in New Issue
Block a user