1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
########################################################
# Test mysqlbinlog command with Ndb produced Binlog
# variants
#
# WHAT
# ====
# This test aims to check that the mysqlbinlog --verbose
# command can output binlogs in 4 format variants, currently
# used by Ndb
#
# 1) Updates logged as write_row events
# Only primary key and updated columns included in the
# event
# 2) Updates logged as write_row_events
# All columns included in the event
# 3) Updates logged as update_row events
# Only primary key and updated columns included in the
# event
# 4) Updates logged as update_row events
# All columns included in the event
#
# Format variant (1) is the Ndb default.
# Bug#47323 resulted in binlogs generated in format (1)
# being incorrectly parsed by the mysqlbinlog --verbose
# option
#
# HOW
# ===
# Row-based binlog files in each format have been
# captured from an Ndb cluster
# These are output using the mysqlbinlog --verbose
# tool and the output is checked.
#
########################################################
-- source include/have_binlog_format_row.inc
--disable_query_log
--let $binlog_file=write-partial-row.binlog
--exec $MYSQL_BINLOG --verbose suite/binlog/std_data/$binlog_file > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql
create table raw_binlog_rows (txt varchar(1000));
--eval load data local infile '$MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql' into table raw_binlog_rows columns terminated by '\n';
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql
--enable_query_log
--echo Verbose statements from : $binlog_file
# Output --verbose lines, with extra Windows CR's trimmed
select replace(txt,'\r', '') as stmt from raw_binlog_rows where txt like '###%';
drop table raw_binlog_rows;
--disable_query_log
--let $binlog_file=write-full-row.binlog
--exec $MYSQL_BINLOG --verbose suite/binlog/std_data/$binlog_file > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql
create table raw_binlog_rows (txt varchar(1000));
--eval load data local infile '$MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql' into table raw_binlog_rows columns terminated by '\n';
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql
--enable_query_log
--echo Verbose statements from : $binlog_file
# Output --verbose lines, with extra Windows CR's trimmed
select replace(txt,'\r', '') as stmt from raw_binlog_rows where txt like '###%';
drop table raw_binlog_rows;
--disable_query_log
--let $binlog_file=update-partial-row.binlog
--exec $MYSQL_BINLOG --verbose suite/binlog/std_data/$binlog_file > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql
create table raw_binlog_rows (txt varchar(1000));
--eval load data local infile '$MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql' into table raw_binlog_rows columns terminated by '\n';
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql
--enable_query_log
--echo Verbose statements from : $binlog_file
# Output --verbose lines, with extra Windows CR's trimmed
select replace(txt,'\r', '') as stmt from raw_binlog_rows where txt like '###%';
drop table raw_binlog_rows;
--disable_query_log
--let $binlog_file=update-full-row.binlog
--exec $MYSQL_BINLOG --verbose suite/binlog/std_data/$binlog_file > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql
create table raw_binlog_rows (txt varchar(1000));
--eval load data local infile '$MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql' into table raw_binlog_rows columns terminated by '\n';
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql
--enable_query_log
--echo Verbose statements from : $binlog_file
# Output --verbose lines, with extra Windows CR's trimmed
select replace(txt,'\r', '') as stmt from raw_binlog_rows where txt like '###%';
drop table raw_binlog_rows;
#######################################################################
# BUG#13799555: ROWS_QUERY_LOG_EVENTS DOES NOT ESCAPE MULTI-LINE QUERIES PROPERLY
#
# Check that when mysqlbinlog is given the option --verbose --verbose,
# the multi-line original statement are properly escaped to prevent from
# being executed.
SET @@SESSION.BINLOG_ROWS_QUERY_LOG_EVENTS = 1;
CREATE TABLE t1 (a VARCHAR(50));
--let $binlog_start_position= query_get_value("SHOW MASTER STATUS", Position, 1)
--delimiter |
INSERT INTO t1 VALUES ("
GRANT ALL ON *.* TO 'batman'/*!*/;
")|
--delimiter ;
DROP TABLE t1;
--let $binlog_stop_position= query_get_value("SHOW MASTER STATUS", Position, 1)
--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
--let $datadir= `SELECT @@datadir`
--let $_prefix= `SELECT UUID()`
--let $TMP_FILE= $MYSQLTEST_VARDIR/tmp/$_prefix.tmp
--exec $MYSQL_BINLOG --force-if-open --verbose --verbose --start-position=$binlog_start_position --stop-position=$binlog_stop_position $datadir/$binlog_file > $TMP_FILE
--let TMP_FILE= $TMP_FILE
--perl END_OF_FILE
my $tmp_file= $ENV{'TMP_FILE'};
my $escaped_query = <<END;
# INSERT INTO t1 VALUES ("
# GRANT ALL ON *.* TO 'batman'/*!*/;
# ")
END
open(FILE, $tmp_file) or die("Unable to open $tmp_file: $!\n");
my $contents = do { local $/; <FILE> };
close(FILE) or die("Unable to close file.");
$match= index($contents, $escaped_query) > -1;
if (!$match)
{
print "\n====================================================\n";
print "ESCAPED STRING DID NOT MATCH:\n";
print "====================================================\n";
print "$escaped_query";
print "====================================================\n";
print "\n====================================================\n";
print "BINLOG CONTENTS\n";
print "====================================================\n";
print "$contents";
print "====================================================\n";
}
END_OF_FILE
# Clean up
--remove_file $TMP_FILE
|