summaryrefslogtreecommitdiff
path: root/mysql-test/t
diff options
context:
space:
mode:
authorunknown <hezx@mail.hezx.com>2008-01-06 13:20:52 +0800
committerunknown <hezx@mail.hezx.com>2008-01-06 13:20:52 +0800
commit9edb5ff7247651834266aed931ee9eacc16f1a00 (patch)
treef3ba1551fb490a0861f10ec3c5ad8ca79b2e56d1 /mysql-test/t
parent0493f05846a0f11fc6d70b4cc54856b366472386 (diff)
parentec2761005a58db12b795987394c3108836001e2a (diff)
downloadmariadb-git-9edb5ff7247651834266aed931ee9eacc16f1a00.tar.gz
Merge mail.hezx.com:/media/sda3/work/mysql/bkwork/bug#32205/5.0
into mail.hezx.com:/media/sda3/work/mysql/bkwork/bug#32205/mysql-5.0-rpl
Diffstat (limited to 'mysql-test/t')
-rw-r--r--mysql-test/t/rpl_loaddata_map-master.opt1
-rw-r--r--mysql-test/t/rpl_loaddata_map-slave.opt1
-rw-r--r--mysql-test/t/rpl_loaddata_map.test52
-rw-r--r--mysql-test/t/rpl_server_id.test29
-rw-r--r--mysql-test/t/rpl_slave_skip.test169
-rw-r--r--mysql-test/t/rpl_transaction-master.opt1
-rw-r--r--mysql-test/t/rpl_transaction-slave.opt1
-rw-r--r--mysql-test/t/rpl_transaction.test106
8 files changed, 357 insertions, 3 deletions
diff --git a/mysql-test/t/rpl_loaddata_map-master.opt b/mysql-test/t/rpl_loaddata_map-master.opt
new file mode 100644
index 00000000000..f3c797b19c8
--- /dev/null
+++ b/mysql-test/t/rpl_loaddata_map-master.opt
@@ -0,0 +1 @@
+--read_buffer_size=9K --max_allowed_packet=8K
diff --git a/mysql-test/t/rpl_loaddata_map-slave.opt b/mysql-test/t/rpl_loaddata_map-slave.opt
new file mode 100644
index 00000000000..95f55bcf7d8
--- /dev/null
+++ b/mysql-test/t/rpl_loaddata_map-slave.opt
@@ -0,0 +1 @@
+--max_allowed_packet=8K
diff --git a/mysql-test/t/rpl_loaddata_map.test b/mysql-test/t/rpl_loaddata_map.test
new file mode 100644
index 00000000000..f3d14278396
--- /dev/null
+++ b/mysql-test/t/rpl_loaddata_map.test
@@ -0,0 +1,52 @@
+#
+# check replication of load data with the server parameters subjected to
+# read_buffer_size > max_allowed_packet
+#
+# BUG#30435 loading large LOAD DATA INFILE breaks slave with
+# read_buffer_size set on master
+# BUG#33413 show binlog events fails if binlog has event size of close
+# to max_allowed_packet
+
+source include/master-slave.inc;
+source include/have_innodb.inc;
+
+--disable_query_log
+let $rows= 5000;
+create table t1 (id int not null primary key auto_increment);
+
+while($rows)
+{
+ eval insert into t1 values (null);
+ dec $rows;
+}
+eval select * into outfile '$MYSQLTEST_VARDIR/tmp/bug30435_5k.txt' from t1;
+flush logs;
+--enable_query_log
+
+connection master;
+create table t2 (id int not null primary key auto_increment);
+
+select @@session.read_buffer_size - @@session.max_allowed_packet > 0 ;
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval load data infile '$MYSQLTEST_VARDIR/tmp/bug30435_5k.txt' into table t2;
+select count(*) from t2 /* 5 000 */;
+
+# the binglog will show fragmented Append_block events
+--let $binlog_start=98
+--replace_column 5 #
+--replace_regex /\/\* xid=.* \*\//\/* XID *\//
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval show binlog events in 'master-bin.000002' from $binlog_start
+
+
+sync_slave_with_master;
+#connection slave;
+select count(*) from t2 /* 5 000 */;
+
+connection master;
+drop table t1, t2;
+sync_slave_with_master;
+remove_file $MYSQLTEST_VARDIR/tmp/bug30435_5k.txt;
+
+--echo end of the tests
diff --git a/mysql-test/t/rpl_server_id.test b/mysql-test/t/rpl_server_id.test
new file mode 100644
index 00000000000..6e98ec6ee6d
--- /dev/null
+++ b/mysql-test/t/rpl_server_id.test
@@ -0,0 +1,29 @@
+# Test for BUG#28908 Replication: set global server_id is not setting the session server_id
+
+-- source include/have_log_bin.inc
+
+let $saved_server_id=`select @@server_id`;
+set global server_id=1;
+reset master;
+
+-- disable_warnings
+drop table if exists t1,t2,t3;
+-- enable_warnings
+
+create table t1 (a int);
+select @@server_id;
+source include/show_binlog_events2.inc;
+
+set global server_id=2;
+create table t2 (b int);
+select @@server_id;
+source include/show_binlog_events2.inc;
+
+set global server_id=3;
+create table t3 (c int);
+select @@server_id;
+source include/show_binlog_events2.inc;
+
+# cleanup
+eval set global server_id=$saved_server_id;
+drop table t1,t2,t3;
diff --git a/mysql-test/t/rpl_slave_skip.test b/mysql-test/t/rpl_slave_skip.test
index 04aafc51129..71e951aceea 100644
--- a/mysql-test/t/rpl_slave_skip.test
+++ b/mysql-test/t/rpl_slave_skip.test
@@ -13,8 +13,10 @@ source include/master-slave.inc;
# it back to get the non-transactional change into the table.
--echo **** On Master ****
-CREATE TABLE t1 (a INT, b SET('master','slave')) ENGINE=INNODB;
-CREATE TABLE t2 (a INT, b SET('master','slave')) ENGINE=MYISAM;
+CREATE TABLE t1 (a INT, b SET('master','slave')) ENGINE=InnoDB;
+CREATE TABLE t2 (a INT, b SET('master','slave')) ENGINE=MyISAM;
+CREATE TABLE t3 (a CHAR(20), b SET('master','slave')) ENGINE=InnoDB;
+CREATE TABLE t4 (a CHAR(20), b SET('master','slave')) ENGINE=MyISAM;
--echo ==== Skipping normal transactions ====
@@ -195,9 +197,170 @@ sync_with_master;
SELECT * FROM t1 ORDER BY a;
SELECT * FROM t2 ORDER BY a;
+--echo ==== Skipping first event of a LOAD DATA for a transactional table ====
+
+--echo **** On Slave ****
+connection slave;
+STOP SLAVE;
+source include/wait_for_slave_to_stop.inc;
+
+--echo **** On Master ****
+connection master;
+SET AUTOCOMMIT=1;
+
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t3(a) SET b = 'master';
+INSERT INTO t3 VALUES ('Go Rin No Sho', 'master,slave');
+
+save_master_pos;
+
+SELECT COUNT(*) FROM t3;
+
+# This will skip a begin event and the first INSERT of the
+# transaction, and it should keep skipping until it has reached the
+# transaction terminator.
+
+--echo **** On Slave ****
+connection slave;
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
+START SLAVE;
+source include/wait_for_slave_to_start.inc;
+sync_with_master;
+--echo -- Should only contain records marked 'master,slave'
+SELECT * FROM t3 ORDER BY a;
+
+--echo **** On Master ****
+connection master;
+DELETE FROM t3;
+sync_slave_with_master;
+
+--echo ==== Skipping first event of a LOAD DATA for a non-transactional table ====
+
+--echo **** On Slave ****
+connection slave;
+STOP SLAVE;
+source include/wait_for_slave_to_stop.inc;
+
+--echo **** On Master ****
+connection master;
+SET AUTOCOMMIT=1;
+
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t4(a) SET b = 'master';
+INSERT INTO t4 VALUES ('Go Rin No Sho', 'master,slave');
+
+save_master_pos;
+
+SELECT COUNT(*) FROM t4;
+
+# This will skip a begin event and the first INSERT of the
+# transaction, and it should keep skipping until it has reached the
+# transaction terminator.
+
+--echo **** On Slave ****
+connection slave;
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
+START SLAVE;
+source include/wait_for_slave_to_start.inc;
+sync_with_master;
+--echo -- Should only contain records marked 'master,slave'
+SELECT * FROM t4 ORDER BY a;
+
+--echo **** On Master ****
+connection master;
+DELETE FROM t4;
+sync_slave_with_master;
+
+--echo ==== Try with a big file so that we get an append_block event as well
+
+--echo **** On Slave ****
+connection slave;
+STOP SLAVE;
+source include/wait_for_slave_to_stop.inc;
+
+--echo **** On Master ****
+connection master;
+SET AUTOCOMMIT=1;
+
+# This contain about 70 words, so we double it a few times to get more than 128 KiB
+SET SQL_LOG_BIN=0;
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t4(a) SET b = 'master';
+INSERT INTO t4 SELECT * FROM t4;
+INSERT INTO t4 SELECT * FROM t4;
+INSERT INTO t4 SELECT * FROM t4;
+INSERT INTO t4 SELECT * FROM t4;
+INSERT INTO t4 SELECT * FROM t4;
+INSERT INTO t4 SELECT * FROM t4;
+INSERT INTO t4 SELECT * FROM t4;
+INSERT INTO t4 SELECT * FROM t4;
+INSERT INTO t4 SELECT * FROM t4;
+INSERT INTO t4 SELECT * FROM t4;
+INSERT INTO t4 SELECT * FROM t4;
+SELECT a FROM t4 INTO OUTFILE 'rpl_slave_skip_words.dat';
+SET SQL_LOG_BIN=1;
+
+# Start the real job
+LOAD DATA INFILE 'rpl_slave_skip_words.dat' INTO TABLE t4(a) SET b = 'master';
+INSERT INTO t4 VALUES ('Go Rin No Sho', 'master,slave');
+
+#SHOW BINLOG EVENTS;
+
+save_master_pos;
+
+SELECT COUNT(*) FROM t4;
+
+# This will skip a begin event and the first INSERT of the
+# transaction, and it should keep skipping until it has reached the
+# transaction terminator.
+
+--echo **** On Slave ****
+connection slave;
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
+START SLAVE;
+source include/wait_for_slave_to_start.inc;
+sync_with_master;
+--echo -- Should only contain records marked 'master,slave'
+SELECT * FROM t4 ORDER BY a;
+
+--echo **** On Master ****
+connection master;
+DELETE FROM t4;
+sync_slave_with_master;
+
+# Test to generate a Delete_file log event, and see that it works as well.
+--echo **** On Master ****
+connection master;
+CREATE TABLE t5 (a int, b int, c SET('master','slave'), PRIMARY KEY (a,b)) ENGINE=MyISAM;
+LOAD DATA INFILE '../std_data_ln/loaddata5.dat' INTO TABLE t5 FIELDS TERMINATED BY '' ENCLOSED BY '' (a,b) SET c='master,slave';
+
+--echo **** On Slave ****
+sync_slave_with_master;
+STOP SLAVE;
+source include/wait_for_slave_to_stop.inc;
+
+--echo **** On Master ****
+connection master;
+error ER_DUP_ENTRY;
+LOAD DATA INFILE '../std_data_ln/loaddata5.dat' INTO TABLE t5 FIELDS TERMINATED BY '' ENCLOSED BY '' (a,b) SET c='';
+INSERT INTO t5 VALUES (42, 42, 'master,slave');
+save_master_pos;
+
+#SHOW BINLOG EVENTS;
+
+SELECT * FROM t5;
+
+--echo **** On Slave ****
+connection slave;
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
+START SLAVE;
+source include/wait_for_slave_to_start.inc;
+
+sync_with_master;
+SELECT * FROM t5;
+
+connection slave;
+
--echo ==== Cleanup ====
--echo **** On Master ****
connection master;
-DROP TABLE t1, t2;
+DROP TABLE t1, t2, t3, t4, t5;
sync_slave_with_master;
diff --git a/mysql-test/t/rpl_transaction-master.opt b/mysql-test/t/rpl_transaction-master.opt
new file mode 100644
index 00000000000..5411960b4aa
--- /dev/null
+++ b/mysql-test/t/rpl_transaction-master.opt
@@ -0,0 +1 @@
+--innodb --debug=d,do_not_write_xid
diff --git a/mysql-test/t/rpl_transaction-slave.opt b/mysql-test/t/rpl_transaction-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_transaction-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_transaction.test b/mysql-test/t/rpl_transaction.test
new file mode 100644
index 00000000000..b7912ee274f
--- /dev/null
+++ b/mysql-test/t/rpl_transaction.test
@@ -0,0 +1,106 @@
+# Tests that transactions are replicated correctly, with various
+# combinations of non-transactional and transactional non-XA tables.
+# Also tests that an XA transaction where the master crashes just
+# before writing the XID log event is executed correctly. See below
+# for implementation details.
+
+# Note: this test should not exist in 5.1 or higher. It has been
+# replaced by rpl_ndb_transaction.test, which tests a superset of what
+# this test tests.
+
+source include/have_innodb.inc;
+source include/master-slave.inc;
+
+
+CREATE TABLE tmyisam (a int) ENGINE = MYISAM;
+CREATE TABLE tinnodb (a int) ENGINE = INNODB;
+
+SHOW CREATE TABLE tmyisam;
+SHOW CREATE TABLE tinnodb;
+
+
+--echo ==== Test 1: Non-XA Engines ====
+# Test that everything works fine with non-XA engines. We just try
+# all ways to do transactions involving ndb and/or myisam, with
+# rollback or commit.
+
+--echo --- on master ---
+
+SET AUTOCOMMIT = 1;
+
+INSERT INTO tmyisam VALUES (1);
+
+BEGIN;
+INSERT INTO tmyisam VALUES (2);
+INSERT INTO tmyisam VALUES (3);
+COMMIT;
+
+BEGIN;
+INSERT INTO tmyisam VALUES (5);
+INSERT INTO tmyisam VALUES (6);
+--warning 1196
+ROLLBACK;
+
+SELECT * FROM tmyisam ORDER BY a;
+
+--echo --- on slave ---
+--sync_slave_with_master
+SELECT * FROM tmyisam ORDER BY a;
+
+
+--echo ==== Test 2: Master crash before writing XID event on XA engine ====
+# We now want to test the following scenario, to verify that BUG#26395
+# has been fixed:
+
+# "master and slave have a transactional table that uses XA. Master
+# has AUTOCOMMIT on and executes a statement (in this case an
+# INSERT). Master crashes just before writing the XID event."
+
+# In this scenario, master will roll back, so slave should not execute
+# the statement, and slave should roll back later when master is
+# restarted.
+
+# However, we the master to be alive so that we are sure it replicates
+# the statement to the slave. So in the test case, we must therefore
+# not crash the master. Instead, we fake the crash by just not writing
+# the XID event to the binlog. This is done by the
+# --debug=d,do_not_write_xid flag in the .opt file.
+
+# So, unlike if the master had crashed, the master *will* execute the
+# statement. But the slave should not execute it. Hence, after the
+# first test is executed, the expected result on master is a table
+# with one row, and on slave a table with no rows.
+
+# To simulate the slave correctly, we wait until everything up to the
+# XID is replicated. We cannot sync_slave_with_master, because that
+# would wait for the transaction to end. Instead, we wait for
+# "sufficiently long time". Then we stop the slave.
+
+# Note: since this puts the master binlog in an inconsistent state,
+# this should be the last test of the file.
+
+--echo --- on master ---
+--connection master
+
+INSERT INTO tinnodb VALUES (1);
+SELECT * FROM tinnodb ORDER BY a;
+
+--echo --- on slave ---
+--connection slave
+--sleep 3
+STOP SLAVE;
+source include/wait_for_slave_to_stop.inc;
+--replace_column 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 #
+query_vertical SHOW SLAVE STATUS;
+# the following statement should show that nothing has been replicated
+SELECT * FROM tinnodb ORDER BY a;
+
+
+# clean up
+connection master;
+DROP TABLE tmyisam;
+DROP TABLE tinnodb;
+
+connection slave;
+DROP TABLE tmyisam;
+DROP TABLE tinnodb;