From 56a041cde657e5618c519a3c50e8075136d4a1ce Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Thu, 3 Nov 2016 13:37:15 +0100 Subject: [PATCH] MDEV-11065: Compressed binary log. Fix BINLOG statement. BINLOG statement output by mysqlbinlog actually has the base64 of the non-compressed event. So remove my previous incorrect review change, which allowed compressed event types for BINLOG statement. Also add a couple test cases for this, running mysqlbinlog | mysql. --- .../r/mysqlbinlog_row_compressed.result | 42 ++++++++++++++++++- .../r/mysqlbinlog_stmt_compressed.result | 27 +++++++++++- mysql-test/t/mysqlbinlog_row_compressed.test | 33 ++++++++++++++- mysql-test/t/mysqlbinlog_stmt_compressed.test | 24 ++++++++++- sql/sql_binlog.cc | 6 --- 5 files changed, 122 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/mysqlbinlog_row_compressed.result b/mysql-test/r/mysqlbinlog_row_compressed.result index c5d8c2b163b..a612433fc2f 100644 --- a/mysql-test/r/mysqlbinlog_row_compressed.result +++ b/mysql-test/r/mysqlbinlog_row_compressed.result @@ -408,6 +408,46 @@ DELIMITER ; ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; -DROP TABLE t1,t2; + +Test mysqlbinlog | mysql type point-in-time recovery with compressed events. + +FLUSH BINARY LOGS; +CREATE TABLE t3 (a INT PRIMARY KEY, b INT, c VARCHAR(100)); +INSERT INTO t3 VALUES (0, 10, "hello"); +BEGIN; +INSERT INTO t3 VALUES (1, 10, "cat"), (2, 10, "mouse"), (3, 10, "dog"); +INSERT INTO t3 VALUES (4, 10, "goodbye"); +COMMIT; +UPDATE t3 SET b=b+100 where a<>1; +DELETE FROM t3 WHERE a=2; +SET @old_image=@@binlog_row_image; +SET binlog_row_image=minimal; +INSERT INTO t3 VALUES (5, 20, "red"), (6, 30, "green"), (7, 40, "blue"); +INSERT INTO t3 VALUES (8, 20, "rigel"); +UPDATE t3 SET c = concat("colour of ", c) WHERE a > 5; +UPDATE t3 SET b=b*2 WHERE a IN (5,6,7); +DELETE FROM t3 WHERE a=6; +SET binlog_row_image=@old_image; +SELECT * FROM t3 ORDER BY a; +a b c +0 110 hello +1 10 cat +3 110 dog +4 110 goodbye +5 40 red +7 80 colour of blue +8 20 colour of rigel +FLUSH LOGS; +DROP TABLE t3; +SELECT * FROM t3 ORDER BY a; +a b c +0 110 hello +1 10 cat +3 110 dog +4 110 goodbye +5 40 red +7 80 colour of blue +8 20 colour of rigel +DROP TABLE t1,t2,t3; SET GLOBAL log_bin_compress=off; SET GLOBAL log_bin_compress_min_len=256; diff --git a/mysql-test/r/mysqlbinlog_stmt_compressed.result b/mysql-test/r/mysqlbinlog_stmt_compressed.result index 6bff2649b02..99f9c7e9914 100644 --- a/mysql-test/r/mysqlbinlog_stmt_compressed.result +++ b/mysql-test/r/mysqlbinlog_stmt_compressed.result @@ -177,6 +177,31 @@ DELIMITER ; ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; -DROP TABLE t1,t2; + +Test mysqlbinlog | mysql type point-in-time recovery with compressed events. + +FLUSH BINARY LOGS; +CREATE TABLE t3 (a INT PRIMARY KEY, b INT, c VARCHAR(100)); +INSERT INTO t3 VALUES (0, 10, "hello"); +BEGIN; +INSERT INTO t3 VALUES (1, 10, "cat"), (2, 10, "mouse"), (3, 10, "dog"); +INSERT INTO t3 VALUES (4, 10, "goodbye"); +COMMIT; +DELETE FROM t3 WHERE a=2; +SELECT * FROM t3 ORDER BY a; +a b c +0 10 hello +1 10 cat +3 10 dog +4 10 goodbye +FLUSH LOGS; +DROP TABLE t3; +SELECT * FROM t3 ORDER BY a; +a b c +0 10 hello +1 10 cat +3 10 dog +4 10 goodbye +DROP TABLE t1,t2,t3; SET GLOBAL log_bin_compress=off; SET GLOBAL log_bin_compress_min_len=256; diff --git a/mysql-test/t/mysqlbinlog_row_compressed.test b/mysql-test/t/mysqlbinlog_row_compressed.test index 3f8c31a088a..1a7ce093986 100644 --- a/mysql-test/t/mysqlbinlog_row_compressed.test +++ b/mysql-test/t/mysqlbinlog_row_compressed.test @@ -32,6 +32,37 @@ FLUSH BINARY LOGS; --replace_regex /\d{6} *\d*:\d\d:\d\d// /Start:.*at startup/Start: xxx/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /mapped to number \d*/mapped to number num/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ --exec $MYSQL_BINLOG --verbose --verbose --base64-output=DECODE-ROWS $datadir/$binlog -DROP TABLE t1,t2; +--echo +--echo Test mysqlbinlog | mysql type point-in-time recovery with compressed events. +--echo + +FLUSH BINARY LOGS; +--let $binlog_file = query_get_value(SHOW MASTER STATUS, File, 1) +CREATE TABLE t3 (a INT PRIMARY KEY, b INT, c VARCHAR(100)); +INSERT INTO t3 VALUES (0, 10, "hello"); +BEGIN; +INSERT INTO t3 VALUES (1, 10, "cat"), (2, 10, "mouse"), (3, 10, "dog"); +INSERT INTO t3 VALUES (4, 10, "goodbye"); +COMMIT; +UPDATE t3 SET b=b+100 where a<>1; +DELETE FROM t3 WHERE a=2; +SET @old_image=@@binlog_row_image; +SET binlog_row_image=minimal; +INSERT INTO t3 VALUES (5, 20, "red"), (6, 30, "green"), (7, 40, "blue"); +INSERT INTO t3 VALUES (8, 20, "rigel"); +UPDATE t3 SET c = concat("colour of ", c) WHERE a > 5; +UPDATE t3 SET b=b*2 WHERE a IN (5,6,7); +DELETE FROM t3 WHERE a=6; +SET binlog_row_image=@old_image; +SELECT * FROM t3 ORDER BY a; +FLUSH LOGS; +DROP TABLE t3; + +--let $MYSQLD_DATADIR= `select @@datadir` +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$binlog_file | $MYSQL + +SELECT * FROM t3 ORDER BY a; + +DROP TABLE t1,t2,t3; SET GLOBAL log_bin_compress=off; SET GLOBAL log_bin_compress_min_len=256; diff --git a/mysql-test/t/mysqlbinlog_stmt_compressed.test b/mysql-test/t/mysqlbinlog_stmt_compressed.test index 4b22683059b..c4331ddf229 100644 --- a/mysql-test/t/mysqlbinlog_stmt_compressed.test +++ b/mysql-test/t/mysqlbinlog_stmt_compressed.test @@ -32,6 +32,28 @@ FLUSH BINARY LOGS; --replace_regex /\d{6} *\d*:\d\d:\d\d// /Start:.*at startup/Start: xxx/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /mapped to number \d*/mapped to number num/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ --exec $MYSQL_BINLOG --verbose --verbose --base64-output=DECODE-ROWS $datadir/$binlog -DROP TABLE t1,t2; +--echo +--echo Test mysqlbinlog | mysql type point-in-time recovery with compressed events. +--echo + +FLUSH BINARY LOGS; +--let $binlog_file = query_get_value(SHOW MASTER STATUS, File, 1) +CREATE TABLE t3 (a INT PRIMARY KEY, b INT, c VARCHAR(100)); +INSERT INTO t3 VALUES (0, 10, "hello"); +BEGIN; +INSERT INTO t3 VALUES (1, 10, "cat"), (2, 10, "mouse"), (3, 10, "dog"); +INSERT INTO t3 VALUES (4, 10, "goodbye"); +COMMIT; +DELETE FROM t3 WHERE a=2; +SELECT * FROM t3 ORDER BY a; +FLUSH LOGS; +DROP TABLE t3; + +--let $MYSQLD_DATADIR= `select @@datadir` +--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$binlog_file | $MYSQL + +SELECT * FROM t3 ORDER BY a; + +DROP TABLE t1,t2,t3; SET GLOBAL log_bin_compress=off; SET GLOBAL log_bin_compress_min_len=256; diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc index 94619f14b8b..d92ac15822f 100644 --- a/sql/sql_binlog.cc +++ b/sql/sql_binlog.cc @@ -82,12 +82,6 @@ static int check_event_type(int type, Relay_log_info *rli) case PRE_GA_WRITE_ROWS_EVENT: case PRE_GA_UPDATE_ROWS_EVENT: case PRE_GA_DELETE_ROWS_EVENT: - case WRITE_ROWS_COMPRESSED_EVENT_V1: - case UPDATE_ROWS_COMPRESSED_EVENT_V1: - case DELETE_ROWS_COMPRESSED_EVENT_V1: - case WRITE_ROWS_COMPRESSED_EVENT: - case UPDATE_ROWS_COMPRESSED_EVENT: - case DELETE_ROWS_COMPRESSED_EVENT: /* Row events are only allowed if a Format_description_event has already been seen.