summaryrefslogtreecommitdiff
path: root/mysql-test/extra
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2011-01-10 14:53:09 +0100
committerunknown <knielsen@knielsen-hq.org>2011-01-10 14:53:09 +0100
commit32379aeba9222d255f151bdea4954932fe784021 (patch)
tree0cd3e1bcd46f1bfcfd44198f3cb01c4d631dc5da /mysql-test/extra
parentd653a80d2a62669243477b82757068a1b7874dbb (diff)
downloadmariadb-git-32379aeba9222d255f151bdea4954932fe784021.tar.gz
Merge Percona patch MWL#47 into mariadb 5.2-percona.
This patch adds options to annotate the binlog (and the mysqlbinlog output) with the original SQL query for queries that are logged using row-based replication.
Diffstat (limited to 'mysql-test/extra')
-rw-r--r--mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test9
-rw-r--r--mysql-test/extra/rpl_tests/rpl_deadlock.test4
-rw-r--r--mysql-test/extra/rpl_tests/rpl_log.test1
-rw-r--r--mysql-test/extra/rpl_tests/rpl_row_annotate.test155
4 files changed, 165 insertions, 4 deletions
diff --git a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test
index 5db79e4f848..96c85e024e9 100644
--- a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test
+++ b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test
@@ -321,14 +321,19 @@ let $MYSQLD_DATADIR= `select @@datadir`;
# we check that the error code of the "ROLLBACK" event is 0 and not
# ER_SERVER_SHUTDOWN (i.e. disconnection just rolls back transaction
# and does not make slave to stop)
+
+-- source include/binlog_start_pos.inc
+
if (`select @@binlog_format = 'ROW'`)
{
- --exec $MYSQL_BINLOG --start-position=524 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
+ let $start_pos= `select @binlog_start_pos + 418`;
+ --exec $MYSQL_BINLOG --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
}
if (`select @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`)
{
- --exec $MYSQL_BINLOG --start-position=555 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
+ let $start_pos= `select @binlog_start_pos + 449`;
+ --exec $MYSQL_BINLOG --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
}
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
diff --git a/mysql-test/extra/rpl_tests/rpl_deadlock.test b/mysql-test/extra/rpl_tests/rpl_deadlock.test
index 607348ae97b..bf7c1e05b24 100644
--- a/mysql-test/extra/rpl_tests/rpl_deadlock.test
+++ b/mysql-test/extra/rpl_tests/rpl_deadlock.test
@@ -72,7 +72,7 @@ connection slave;
--source include/stop_slave.inc
DELETE FROM t2;
# Set slave position to the BEGIN log event
---replace_result $master_pos_begin MASTER_POS_BEGIN
+--replace_result $master_pos_begin <master_pos_begin>
eval CHANGE MASTER TO MASTER_LOG_POS=$master_pos_begin;
BEGIN;
# Hold lock
@@ -103,7 +103,7 @@ SET global max_relay_log_size=0;
--source include/stop_slave.inc
DELETE FROM t2;
# Set slave position to the BEGIN log event
---replace_result $master_pos_begin MASTER_POS_BEGIN
+--replace_result $master_pos_begin <master_pos_begin>
eval CHANGE MASTER TO MASTER_LOG_POS=$master_pos_begin;
BEGIN;
# Hold lock
diff --git a/mysql-test/extra/rpl_tests/rpl_log.test b/mysql-test/extra/rpl_tests/rpl_log.test
index e714d84a51b..9effeee1292 100644
--- a/mysql-test/extra/rpl_tests/rpl_log.test
+++ b/mysql-test/extra/rpl_tests/rpl_log.test
@@ -14,6 +14,7 @@ source include/stop_slave.inc;
reset master;
reset slave;
source include/start_slave.inc;
+source include/binlog_start_pos.inc;
let $VERSION=`select version()`;
diff --git a/mysql-test/extra/rpl_tests/rpl_row_annotate.test b/mysql-test/extra/rpl_tests/rpl_row_annotate.test
new file mode 100644
index 00000000000..290d0a89b46
--- /dev/null
+++ b/mysql-test/extra/rpl_tests/rpl_row_annotate.test
@@ -0,0 +1,155 @@
+########################################################################
+# WL47: Store in binlog text of statements that caused RBR events
+# new event : ANNOTATE_ROWS_EVENT
+# new master option : --binlog-annotate-rows-events
+# new slave option : --replicate-annotate-rows-events
+########################################################################
+--source include/master-slave.inc
+connect (master2,127.0.0.1,root,,test,$MASTER_MYPORT,);
+
+connection master;
+--disable_query_log
+
+--disable_warnings
+DROP DATABASE IF EXISTS test1;
+--enable_warnings
+
+CREATE DATABASE test1;
+USE test1;
+
+CREATE TABLE t1(a int primary key, b int);
+CREATE TABLE t2(a int, b int);
+CREATE TABLE t3(a int, b int);
+CREATE TABLE t4(a int, b int);
+CREATE TABLE xt1(a int, b int);
+CREATE TABLE xt2(a int, b int);
+
+CREATE TABLE t5 (
+ a INT PRIMARY KEY AUTO_INCREMENT,
+ b VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_bin
+);
+
+SET SESSION binlog_annotate_rows_events = OFF;
+
+INSERT INTO t1 VALUES (0,0), (1,1);
+
+SET SESSION binlog_annotate_rows_events = ON;
+
+UPDATE t1 SET b = b + 1;
+REPLACE t1 VALUES (1,1), (2,2), (3,3);
+
+INSERT INTO t2 VALUES (1,1), (2,2), (3,3);
+INSERT INTO t3 VALUES (1,1), (2,2), (3,3);
+DELETE t1, t2 FROM t1 INNER JOIN t2 INNER JOIN t3 WHERE t1.a=t2.a AND t2.a=t3.a;
+
+INSERT INTO xt1 VALUES (1,1), (2,2), (3,3);
+INSERT INTO t2 VALUES (1,1), (2,2), (3,3);
+DELETE xt1, t2 FROM xt1 INNER JOIN t2 INNER JOIN t3 WHERE xt1.a=t2.a AND t2.a=t3.a;
+
+INSERT INTO xt1 VALUES (1,1), (2,2), (3,3);
+INSERT INTO xt2 VALUES (1,1), (2,2), (3,3);
+DELETE xt1, xt2 FROM xt1 INNER JOIN xt2 INNER JOIN t3 WHERE xt1.a=xt2.a AND xt2.a=t3.a;
+
+INSERT INTO t5(b) VALUES ('foo'), ('bar'), ('baz');
+SET NAMES latin1;
+INSERT INTO t5(b) VALUES ('gås');
+SET NAMES utf8;
+INSERT INTO t5(b) VALUES ('gås');
+SET NAMES latin1;
+
+FLUSH LOGS;
+
+--echo ########################################################################
+--echo # TABLES ON MASTER
+--echo ########################################################################
+--enable_query_log
+
+SELECT * FROM t1 ORDER BY a;
+SELECT * FROM t2 ORDER BY a;
+SELECT * FROM t3 ORDER BY a;
+SELECT * FROM t5 ORDER BY a;
+
+sync_slave_with_master;
+--echo ########################################################################
+--echo # TABLES ON SLAVE: should be the same as on master
+--echo ########################################################################
+--disable_query_log
+USE test1;
+--enable_query_log
+
+SELECT * FROM t1 ORDER BY a;
+SELECT * FROM t2 ORDER BY a;
+SELECT * FROM t3 ORDER BY a;
+SELECT * FROM t5 ORDER BY a;
+
+--echo ########################################################################
+--echo # EVENTS ON SLAVE
+let $annotate= `select @@global.replicate_annotate_rows_events`;
+if ($annotate)
+{
+ --echo # The following Annotate_rows events should appear below:
+ --echo # - UPDATE t1 SET b = b + 1;
+ --echo # - REPLACE t1 VALUES (1,1), (2,2), (3,3);
+ --echo # - INSERT INTO t2 VALUES (1,1), (2,2), (3,3)
+ --echo # - INSERT INTO t3 VALUES (1,1), (2,2), (3,3)
+ --echo # - DELETE t1, t2 FROM <...>
+ --echo # - INSERT INTO t2 VALUES (1,1), (2,2), (3,3)
+ --echo # - DELETE xt1, t2 FROM <...>
+ --echo # - INSERT INTO t5(b) VALUES <...> (3 instances)
+}
+if (!$annotate)
+{
+ --echo # No Annotate_rows events should appear below
+}
+--echo ########################################################################
+FLUSH LOGS;
+
+--source include/binlog_start_pos.inc
+let $start_pos= `select @binlog_start_pos`;
+--replace_column 2 # 5 #
+--replace_result $start_pos <start_pos>
+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
+--eval show binlog events in 'slave-bin.000001' from $start_pos
+
+--echo #
+--echo ########################################################################
+--echo # INSERTs DELAYED ON MASTERs
+--echo ########################################################################
+connection master;
+SET SESSION binlog_annotate_rows_events = ON;
+INSERT DELAYED INTO test1.t4 VALUES (1,1);
+FLUSH TABLES;
+SELECT * FROM test1.t4 ORDER BY a;
+
+sync_slave_with_master;
+connection master;
+sync_slave_with_master;
+
+--echo ########################################################################
+--echo # ON SLAVE
+--echo # No Annotate_rows events should appear below
+--echo ########################################################################
+FLUSH LOGS;
+
+--exec $MYSQL --host=127.0.0.1 --port=$SLAVE_MYPORT test -e "show binlog events in 'slave-bin.000002'" > $MYSQLTEST_VARDIR/tmp/annotated_events.txt
+perl;
+ open F, '<', "$ENV{MYSQLTEST_VARDIR}/tmp/annotated_events.txt" or die;
+ binmode STDOUT;
+ while (defined ($_ = <F>)) {
+ if (/Annotate_rows/) {
+ s/[0-9]+\sAnnotate_rows\s[0-9]+\s[0-9]+/# Annotate_rows # #/;
+ print($_);
+ $_ = <F>;
+ s/[0-9]+\sTable_map\s[0-9]+\s[0-9]+\stable_id:\s[0-9]+/# Table_map # # table_id: #/;
+ print($_);
+ }
+ }
+EOF
+
+# Clean-up
+connection master;
+--disable_query_log
+DROP DATABASE test1;
+sync_slave_with_master;
+--enable_query_log
+