Commit e1c50287 authored by vinchen's avatar vinchen Committed by Kristian Nielsen

test suite for compressed binlog event

parent d4b2c9bb
......@@ -10,19 +10,19 @@
#
# Format_description_log_event length =
# 19 /* event common header */ +
# 58 /* misc stuff in the Format description header */ +
# 57 /* misc stuff in the Format description header */ +
# number of events +
# 1 /* Checksum algorithm */ +
# 4 /* CRC32 length */
#
# With current number of events = 164,
# With current number of events = 171,
#
# binlog_start_pos = 4 + 19 + 57 + 163 + 1 + 4 = 249.
# binlog_start_pos = 4 + 19 + 57 + 171 + 1 + 4 = 256.
#
##############################################################################
let $binlog_start_pos=249;
let $binlog_start_pos=256;
--disable_query_log
SET @binlog_start_pos=249;
SET @binlog_start_pos=256;
--enable_query_log
......@@ -4,7 +4,7 @@ if ($binlog_start)
}
if (!$binlog_start)
{
--let $_binlog_start=249
--let $_binlog_start=256
}
if ($binlog_file)
{
......
......@@ -4,6 +4,8 @@ show variables like 'log_bin%';
Variable_name Value
log_bin OFF
log_bin_basename
log_bin_compress OFF
log_bin_compress_min_len 256
log_bin_index
log_bin_trust_function_creators ON
show variables like 'relay_log%';
......@@ -20,6 +22,8 @@ show variables like 'log_bin%';
Variable_name Value
log_bin OFF
log_bin_basename
log_bin_compress OFF
log_bin_compress_min_len 256
log_bin_index
log_bin_trust_function_creators ON
show variables like 'relay_log%';
......
This diff is collapsed.
This diff is collapsed.
SET GLOBAL log_bin_compress=on;
SET GLOBAL log_bin_compress_min_len=10;
CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 TINYINT, f4 MEDIUMINT, f5 BIGINT, f6 INT, f7 INT, f8 char(1));
CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 INT, f4 INT, f5 MEDIUMINT, f6 INT, f7 INT, f8 char(1));
INSERT INTO t1 VALUES (10, 1, 2, 3, 4, 5, 6, 7, "");
INSERT INTO t1 VALUES (11, 1, 2, 3, 4, 5, 6, 7, NULL);
INSERT INTO t1 VALUES (12, 1, 2, 3, NULL, 5, 6, 7, "A");
INSERT INTO t1 VALUES (13, 1, 2, 3, 0, 5, 6, 7, "A");
INSERT INTO t2 SELECT * FROM t1;
UPDATE t2 SET f4=5 WHERE f4>0 or f4 is NULL;
DELETE FROM t1;
DELETE FROM t2;
FLUSH BINARY LOGS;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#<date> server id 1 end_log_pos 256 CRC32 XXX Start: xxx
ROLLBACK/*!*/;
# at 256
#<date> server id 1 end_log_pos 285 CRC32 XXX Gtid list []
# at 285
#<date> server id 1 end_log_pos 329 CRC32 XXX Binlog checkpoint master-bin.000001
# at 329
#<date> server id 1 end_log_pos 371 CRC32 XXX GTID 0-1-1 ddl
/*!100101 SET @@session.skip_parallel_replication=0*//*!*/;
/*!100001 SET @@session.gtid_domain_id=0*//*!*/;
/*!100001 SET @@session.server_id=1*//*!*/;
/*!100001 SET @@session.gtid_seq_no=1*//*!*/;
# at 371
#<date> server id 1 end_log_pos 533 CRC32 XXX Query_compressed thread_id=4 exec_time=x error_code=0
use `test`/*!*/;
SET TIMESTAMP=X/*!*/;
SET @@session.pseudo_thread_id=4/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
SET @@session.sql_mode=1342177280/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 TINYINT, f4 MEDIUMINT, f5 BIGINT, f6 INT, f7 INT, f8 char(1))
/*!*/;
# at 533
#<date> server id 1 end_log_pos 575 CRC32 XXX GTID 0-1-2 ddl
/*!100001 SET @@session.gtid_seq_no=2*//*!*/;
# at 575
#<date> server id 1 end_log_pos 727 CRC32 XXX Query_compressed thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 INT, f4 INT, f5 MEDIUMINT, f6 INT, f7 INT, f8 char(1))
/*!*/;
# at 727
#<date> server id 1 end_log_pos 769 CRC32 XXX GTID 0-1-3
/*!100001 SET @@session.gtid_seq_no=3*//*!*/;
BEGIN
/*!*/;
# at 769
#<date> server id 1 end_log_pos 897 CRC32 XXX Query_compressed thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
INSERT INTO t1 VALUES (10, 1, 2, 3, 4, 5, 6, 7, "")
/*!*/;
# at 897
#<date> server id 1 end_log_pos 970 CRC32 XXX Query thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
# at 970
#<date> server id 1 end_log_pos 1012 CRC32 XXX GTID 0-1-4
/*!100001 SET @@session.gtid_seq_no=4*//*!*/;
BEGIN
/*!*/;
# at 1012
#<date> server id 1 end_log_pos 1140 CRC32 XXX Query_compressed thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
INSERT INTO t1 VALUES (11, 1, 2, 3, 4, 5, 6, 7, NULL)
/*!*/;
# at 1140
#<date> server id 1 end_log_pos 1213 CRC32 XXX Query thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
# at 1213
#<date> server id 1 end_log_pos 1255 CRC32 XXX GTID 0-1-5
/*!100001 SET @@session.gtid_seq_no=5*//*!*/;
BEGIN
/*!*/;
# at 1255
#<date> server id 1 end_log_pos 1385 CRC32 XXX Query_compressed thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
INSERT INTO t1 VALUES (12, 1, 2, 3, NULL, 5, 6, 7, "A")
/*!*/;
# at 1385
#<date> server id 1 end_log_pos 1458 CRC32 XXX Query thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
# at 1458
#<date> server id 1 end_log_pos 1500 CRC32 XXX GTID 0-1-6
/*!100001 SET @@session.gtid_seq_no=6*//*!*/;
BEGIN
/*!*/;
# at 1500
#<date> server id 1 end_log_pos 1627 CRC32 XXX Query_compressed thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
INSERT INTO t1 VALUES (13, 1, 2, 3, 0, 5, 6, 7, "A")
/*!*/;
# at 1627
#<date> server id 1 end_log_pos 1700 CRC32 XXX Query thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
# at 1700
#<date> server id 1 end_log_pos 1742 CRC32 XXX GTID 0-1-7
/*!100001 SET @@session.gtid_seq_no=7*//*!*/;
BEGIN
/*!*/;
# at 1742
#<date> server id 1 end_log_pos 1850 CRC32 XXX Query_compressed thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
INSERT INTO t2 SELECT * FROM t1
/*!*/;
# at 1850
#<date> server id 1 end_log_pos 1923 CRC32 XXX Query thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
# at 1923
#<date> server id 1 end_log_pos 1965 CRC32 XXX GTID 0-1-8
/*!100001 SET @@session.gtid_seq_no=8*//*!*/;
BEGIN
/*!*/;
# at 1965
#<date> server id 1 end_log_pos 2082 CRC32 XXX Query_compressed thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
UPDATE t2 SET f4=5 WHERE f4>0 or f4 is NULL
/*!*/;
# at 2082
#<date> server id 1 end_log_pos 2155 CRC32 XXX Query thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
# at 2155
#<date> server id 1 end_log_pos 2197 CRC32 XXX GTID 0-1-9
/*!100001 SET @@session.gtid_seq_no=9*//*!*/;
BEGIN
/*!*/;
# at 2197
#<date> server id 1 end_log_pos 2288 CRC32 XXX Query_compressed thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
DELETE FROM t1
/*!*/;
# at 2288
#<date> server id 1 end_log_pos 2361 CRC32 XXX Query thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
# at 2361
#<date> server id 1 end_log_pos 2403 CRC32 XXX GTID 0-1-10
/*!100001 SET @@session.gtid_seq_no=10*//*!*/;
BEGIN
/*!*/;
# at 2403
#<date> server id 1 end_log_pos 2494 CRC32 XXX Query_compressed thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
DELETE FROM t2
/*!*/;
# at 2494
#<date> server id 1 end_log_pos 2567 CRC32 XXX Query thread_id=4 exec_time=x error_code=0
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
# at 2567
#<date> server id 1 end_log_pos 2615 CRC32 XXX Rotate to master-bin.000002 pos: 4
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
DROP TABLE t1,t2;
SET GLOBAL log_bin_compress=off;
SET GLOBAL log_bin_compress_min_len=256;
......@@ -344,6 +344,10 @@ The following options may be given as the first argument:
We strongly recommend to use either --log-basename or
specify a filename to ensure that replication doesn't
stop if the real hostname of the computer changes.
--log-bin-compress Whether the binary log can be compressed
--log-bin-compress-min-len[=#]
Minimum length of sql statement(in statement mode) or
record(in row mode)that can be compressed.
--log-bin-index=name
File that holds the names for last binary log files.
--log-bin-trust-function-creators
......@@ -1264,6 +1268,8 @@ lc-time-names en_US
local-infile TRUE
lock-wait-timeout 31536000
log-bin (No default value)
log-bin-compress FALSE
log-bin-compress-min-len 256
log-bin-index (No default value)
log-bin-trust-function-creators FALSE
log-error
......
......@@ -3,6 +3,10 @@ Variable_name log_bin
Value ON
Variable_name log_bin_basename
Value MYSQLTEST_VARDIR/mysqld.1/data/other
Variable_name log_bin_compress
Value OFF
Variable_name log_bin_compress_min_len
Value 256
Variable_name log_bin_index
Value MYSQLTEST_VARDIR/mysqld.1/data/mysqld-bin.index
Variable_name log_bin_trust_function_creators
......
......@@ -3,6 +3,10 @@ Variable_name log_bin
Value ON
Variable_name log_bin_basename
Value MYSQLTEST_VARDIR/mysqld.1/data/other
Variable_name log_bin_compress
Value OFF
Variable_name log_bin_compress_min_len
Value 256
Variable_name log_bin_index
Value MYSQLTEST_VARDIR/tmp/something.index
Variable_name log_bin_trust_function_creators
......
include/master-slave.inc
[connection master]
set @old_log_bin_compress=@@log_bin_compress;
set @old_log_bin_compress_min_len=@@log_bin_compress_min_len;
set @old_binlog_format=@@binlog_format;
set @old_binlog_row_image=@@binlog_row_image;
set global log_bin_compress=on;
set global log_bin_compress_min_len=10;
drop table if exists t1;
Warnings:
Note 1051 Unknown table 'test.t1'
CREATE TABLE t1 (pr_id int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, pr_page int(11) NOT NULL, pr_type varbinary(60) NOT NULL, test int, UNIQUE KEY pr_pagetype (pr_page,pr_type)) ENGINE=myisam AUTO_INCREMENT=136;
set binlog_format=statement;
insert into t1 (pr_page, pr_type, test) values(1,"one",0),(2,"two",0);
replace into t1 (pr_page, pr_type,test) values(1,"one",2);
update t1 set test=test+1 where pr_page > 1;
delete from t1 where test=1;
select * from t1;
pr_id pr_page pr_type test
138 1 one 2
connection slave;
connection slave;
select * from t1;
pr_id pr_page pr_type test
138 1 one 2
connection master;
set binlog_format=row;
insert into t1 (pr_page, pr_type, test) values(3,"three",0),(4,"four",4),(5, "five", 0);
replace into t1 (pr_page, pr_type,test) values(3,"one",2);
update t1 set test=test+1 where pr_page > 3;
delete from t1 where test=1;
select * from t1;
pr_id pr_page pr_type test
138 1 one 2
140 4 four 5
139 3 three 0
142 3 one 2
connection slave;
connection slave;
select * from t1;
pr_id pr_page pr_type test
138 1 one 2
140 4 four 5
139 3 three 0
142 3 one 2
connection master;
set binlog_row_image=minimal;
insert into t1 (pr_page, pr_type, test) values(6,"six",0),(7,"seven",7),(8, "eight", 0);
replace into t1 (pr_page, pr_type,test) values(6,"six",2);
update t1 set test=test+1 where pr_page > 6;
delete from t1 where test=1;
select * from t1;
pr_id pr_page pr_type test
138 1 one 2
140 4 four 5
139 3 three 0
144 7 seven 8
142 3 one 2
146 6 six 2
connection slave;
connection slave;
select * from t1;
pr_id pr_page pr_type test
138 1 one 2
140 4 four 5
139 3 three 0
144 7 seven 8
142 3 one 2
146 6 six 2
connection master;
drop table t1;
set global log_bin_compress=@old_log_bin_compress;
set global log_bin_compress_min_len=@old_log_bin_compress_min_len;
set binlog_format=@old_binlog_format;
set binlog_row_image=@old_binlog_row_image;
include/rpl_end.inc
#
# Test of compressed binlog with replication
#
source include/master-slave.inc;
set @old_log_bin_compress=@@log_bin_compress;
set @old_log_bin_compress_min_len=@@log_bin_compress_min_len;
set @old_binlog_format=@@binlog_format;
set @old_binlog_row_image=@@binlog_row_image;
set global log_bin_compress=on;
set global log_bin_compress_min_len=10;
drop table if exists t1;
CREATE TABLE t1 (pr_id int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, pr_page int(11) NOT NULL, pr_type varbinary(60) NOT NULL, test int, UNIQUE KEY pr_pagetype (pr_page,pr_type)) ENGINE=myisam AUTO_INCREMENT=136;
set binlog_format=statement;
insert into t1 (pr_page, pr_type, test) values(1,"one",0),(2,"two",0);
replace into t1 (pr_page, pr_type,test) values(1,"one",2);
update t1 set test=test+1 where pr_page > 1;
delete from t1 where test=1;
select * from t1;
sync_slave_with_master;
connection slave;
select * from t1;
connection master;
set binlog_format=row;
insert into t1 (pr_page, pr_type, test) values(3,"three",0),(4,"four",4),(5, "five", 0);
replace into t1 (pr_page, pr_type,test) values(3,"one",2);
update t1 set test=test+1 where pr_page > 3;
delete from t1 where test=1;
select * from t1;
sync_slave_with_master;
connection slave;
select * from t1;
connection master;
set binlog_row_image=minimal;
insert into t1 (pr_page, pr_type, test) values(6,"six",0),(7,"seven",7),(8, "eight", 0);
replace into t1 (pr_page, pr_type,test) values(6,"six",2);
update t1 set test=test+1 where pr_page > 6;
delete from t1 where test=1;
select * from t1;
sync_slave_with_master;
connection slave;
select * from t1;
connection master;
drop table t1;
set global log_bin_compress=@old_log_bin_compress;
set global log_bin_compress_min_len=@old_log_bin_compress_min_len;
set binlog_format=@old_binlog_format;
set binlog_row_image=@old_binlog_row_image;
--source include/rpl_end.inc
......@@ -1759,6 +1759,34 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
READ_ONLY YES
COMMAND_LINE_ARGUMENT NULL
VARIABLE_NAME LOG_BIN_COMPRESS
SESSION_VALUE NULL
GLOBAL_VALUE OFF
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE OFF
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN
VARIABLE_COMMENT Whether the binary log can be compressed
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME LOG_BIN_COMPRESS_MIN_LEN
SESSION_VALUE NULL
GLOBAL_VALUE 256
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 256
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT Minimum length of sql statement(in statement mode) or record(in row mode)that can be compressed.
NUMERIC_MIN_VALUE 10
NUMERIC_MAX_VALUE 1024
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME LOG_BIN_INDEX
SESSION_VALUE NULL
GLOBAL_VALUE
......
#
# Test for compressed row event
#
--source include/have_log_bin.inc
--source include/have_binlog_format_row.inc
#
#
# mysqlbinlog: comprssed row event
#
#
SET GLOBAL log_bin_compress=on;
SET GLOBAL log_bin_compress_min_len=10;
CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 TINYINT, f4 MEDIUMINT, f5 BIGINT, f6 INT, f7 INT, f8 char(1));
CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 INT, f4 INT, f5 MEDIUMINT, f6 INT, f7 INT, f8 char(1));
INSERT INTO t1 VALUES (10, 1, 2, 3, 4, 5, 6, 7, "");
INSERT INTO t1 VALUES (11, 1, 2, 3, 4, 5, 6, 7, NULL);
INSERT INTO t1 VALUES (12, 1, 2, 3, NULL, 5, 6, 7, "A");
INSERT INTO t1 VALUES (13, 1, 2, 3, 0, 5, 6, 7, "A");
INSERT INTO t2 SELECT * FROM t1;
UPDATE t2 SET f4=5 WHERE f4>0 or f4 is NULL;
DELETE FROM t1;
DELETE FROM t2;
--let $binlog = query_get_value(SHOW MASTER STATUS, File, 1)
--let $datadir = `SELECT @@datadir`
FLUSH BINARY LOGS;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_regex /\d{6} *\d*:\d\d:\d\d/<date>/ /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;
SET GLOBAL log_bin_compress=off;
SET GLOBAL log_bin_compress_min_len=256;
#
# Test for compressed query event
#
--source include/have_log_bin.inc
--source include/have_binlog_format_statement.inc
#
#
# mysqlbinlog: comprssed query event
#
#
SET GLOBAL log_bin_compress=on;
SET GLOBAL log_bin_compress_min_len=10;
CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 TINYINT, f4 MEDIUMINT, f5 BIGINT, f6 INT, f7 INT, f8 char(1));
CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 INT, f4 INT, f5 MEDIUMINT, f6 INT, f7 INT, f8 char(1));
INSERT INTO t1 VALUES (10, 1, 2, 3, 4, 5, 6, 7, "");
INSERT INTO t1 VALUES (11, 1, 2, 3, 4, 5, 6, 7, NULL);
INSERT INTO t1 VALUES (12, 1, 2, 3, NULL, 5, 6, 7, "A");
INSERT INTO t1 VALUES (13, 1, 2, 3, 0, 5, 6, 7, "A");
INSERT INTO t2 SELECT * FROM t1;
UPDATE t2 SET f4=5 WHERE f4>0 or f4 is NULL;
DELETE FROM t1;
DELETE FROM t2;
--let $binlog = query_get_value(SHOW MASTER STATUS, File, 1)
--let $datadir = `SELECT @@datadir`
FLUSH BINARY LOGS;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_regex /\d{6} *\d*:\d\d:\d\d/<date>/ /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;
SET GLOBAL log_bin_compress=off;
SET GLOBAL log_bin_compress_min_len=256;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment