| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# This test evaluates the behavior of mysqlbinlog when using the |
| 4 |
# --require_row_format. |
| 5 |
# This test evaluates mysqlbinlog when using a local file and with a |
| 6 |
# connection to a remote server. |
| 7 |
# |
| 8 |
# ==== Requirements ==== |
| 9 |
# |
| 10 |
# When using --require_row_format mysqlbinlog shall error out when |
| 11 |
# |
| 12 |
# T1. It faces a DML transaction not logged with row based logging |
| 13 |
# T2. It encounters a LOAD DATA, INTVAR, RAND or USER_VAR event |
| 14 |
# T3. It encounters a CREATE/DROP TEMPORARY TABLE statement |
| 15 |
# |
| 16 |
# ==== Implementation ==== |
| 17 |
# |
| 18 |
# 0. Execute a RESET MASTER to clean old binary logs |
| 19 |
# Add suppressions for the test. |
| 20 |
# Create a test include. |
| 21 |
# 1. Log a DML transaction using statement based logging (T1) |
| 22 |
# 1.1 Check mysqlbinlog errors out |
| 23 |
# 2. Log a transaction with a LOAD DATA event (T2) |
| 24 |
# 2.1 Check mysqlbinlog errors out |
| 25 |
# 3. Log a transaction with a USER_VAR event (T2) |
| 26 |
# 3.1 Check mysqlbinlog errors out |
| 27 |
# 4. Log a transaction with a RAND event (T2) |
| 28 |
# 4.1 Check mysqlbinlog errors out |
| 29 |
# 5. Log a transaction with a INTVAR event (T2) |
| 30 |
# 5.1 Check mysqlbinlog errors out |
| 31 |
# 6. Log a transaction with a CREATE TEMPORARY TABLE query (T3) |
| 32 |
# 6.1 Check mysqlbinlog errors out |
| 33 |
# 7. Log a transaction with a DROP TEMPORARY TABLE query (T3) |
| 34 |
# 7.1 Check mysqlbinlog errors out |
| 35 |
# 8. Cleanup |
| 36 |
# |
| 37 |
# ==== Related Worklog ==== |
| 38 |
# |
| 39 |
# WL #12968 : Configure replication applier to require row-based replication |
| 40 |
|
| 41 |
--source include/have_binlog_format_statement.inc |
| 42 |
|
| 43 |
--echo # |
| 44 |
--echo # 0. Execute a RESET MASTER to clean old binary logs |
| 45 |
--echo # Add suppressions for the test. |
| 46 |
--echo # Create a test include. |
| 47 |
|
| 48 |
# Clean any old binlogs |
| 49 |
RESET MASTER; |
| 50 |
|
| 51 |
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); |
| 52 |
|
| 53 |
--let $MYSQLD_DATADIR= `select @@datadir` |
| 54 |
|
| 55 |
--write_file $MYSQL_TMP_DIR/check_mysqlbinlog_row_format_error.inc END_OF_PROCEDURE |
| 56 |
|
| 57 |
--let $mysqlbinlog_allow_error=1 |
| 58 |
--let $mysqlbinlog_parameters= --require_row_format $MYSQLD_DATADIR/$binlog_file |
| 59 |
--let $mysqlbinlog_pipe= > $MYSQL_TMP_DIR/mysqlbinlog.out 2>&1 |
| 60 |
--source include/mysqlbinlog.inc |
| 61 |
|
| 62 |
--let $assert_text = There was an error when executing mysqlbinlog |
| 63 |
--let $assert_file = $MYSQL_TMP_DIR/mysqlbinlog.out |
| 64 |
--let $assert_select = Event being written violates the --require-row-format parameter constraints |
| 65 |
--let $assert_count = 1 |
| 66 |
--source include/assert_grep.inc |
| 67 |
|
| 68 |
--let $assert_text = $assert_text_event_not_present_mysqlbinlog |
| 69 |
--let $assert_file = $MYSQL_TMP_DIR/mysqlbinlog.out |
| 70 |
--let $assert_select = $assert_select_event_present_mysqlbinlog |
| 71 |
--let $assert_count = 0 |
| 72 |
--source include/assert_grep.inc |
| 73 |
|
| 74 |
--let $mysqlbinlog_allow_error=1 |
| 75 |
--let $mysqlbinlog_parameters= -R --host=127.0.0.1 -P $MASTER_MYPORT -u root --require_row_format $binlog_file |
| 76 |
--let $mysqlbinlog_pipe= > $MYSQL_TMP_DIR/mysqlbinlog_remote.out 2>&1 |
| 77 |
--source include/mysqlbinlog.inc |
| 78 |
|
| 79 |
--let $assert_text = There was an error when executing mysqlbinlog remotely |
| 80 |
--let $assert_file = $MYSQL_TMP_DIR/mysqlbinlog_remote.out |
| 81 |
--let $assert_select = Event being written violates the --require-row-format parameter constraints |
| 82 |
--let $assert_count = 1 |
| 83 |
--source include/assert_grep.inc |
| 84 |
|
| 85 |
--let $assert_text = $assert_text_event_not_present_mysqlbinlog |
| 86 |
--let $assert_file = $MYSQL_TMP_DIR/mysqlbinlog_remote.out |
| 87 |
--let $assert_select = $assert_select_event_present_mysqlbinlog |
| 88 |
--let $assert_count = 0 |
| 89 |
--source include/assert_grep.inc |
| 90 |
|
| 91 |
--remove_file $MYSQL_TMP_DIR/mysqlbinlog.out |
| 92 |
--remove_file $MYSQL_TMP_DIR/mysqlbinlog_remote.out |
| 93 |
|
| 94 |
--let $mysqlbinlog_allow_error=0 |
| 95 |
--let $mysqlbinlog_parameters= $MYSQLD_DATADIR/$binlog_file |
| 96 |
--let $mysqlbinlog_pipe= > $MYSQL_TMP_DIR/mysqlbinlog.out 2>&1 |
| 97 |
--source include/mysqlbinlog.inc |
| 98 |
|
| 99 |
--let $assert_text = $assert_text_event_present_mysqlbinlog |
| 100 |
--let $assert_file = $MYSQL_TMP_DIR/mysqlbinlog.out |
| 101 |
--let $assert_select = $assert_select_event_present_mysqlbinlog |
| 102 |
--let $assert_count = 1 |
| 103 |
--source include/assert_grep.inc |
| 104 |
|
| 105 |
RESET MASTER; |
| 106 |
|
| 107 |
--remove_file $MYSQL_TMP_DIR/mysqlbinlog.out |
| 108 |
|
| 109 |
END_OF_PROCEDURE |
| 110 |
|
| 111 |
--echo # |
| 112 |
--echo # 1. Log a DML transaction using statement based logging (T1) |
| 113 |
|
| 114 |
CREATE TABLE t1 (c01 BIT); |
| 115 |
|
| 116 |
INSERT INTO t1 VALUES (0); |
| 117 |
|
| 118 |
DROP TABLE t1; |
| 119 |
|
| 120 |
--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 121 |
|
| 122 |
FLUSH LOGS; |
| 123 |
|
| 124 |
--echo # |
| 125 |
--echo # 1.1 Check mysqlbinlog errors out (T1) |
| 126 |
|
| 127 |
--let $assert_text_event_not_present_mysqlbinlog= The INSERT query is not written with --require_row_format |
| 128 |
--let $assert_text_event_present_mysqlbinlog= The INSERT query is written without --require_row_format |
| 129 |
--let $assert_select_event_present_mysqlbinlog= INSERT INTO t1 |
| 130 |
--source $MYSQL_TMP_DIR/check_mysqlbinlog_row_format_error.inc |
| 131 |
|
| 132 |
|
| 133 |
--echo # |
| 134 |
--echo # 2. Log a transaction with a LOAD DATA event (T2) |
| 135 |
|
| 136 |
CREATE TABLE tload (c1 TEXT); |
| 137 |
|
| 138 |
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE tload; |
| 139 |
|
| 140 |
--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 141 |
|
| 142 |
DROP TABLE tload; |
| 143 |
|
| 144 |
FLUSH LOGS; |
| 145 |
|
| 146 |
--echo # |
| 147 |
--echo # 2.1 Check mysqlbinlog errors out (T2) |
| 148 |
|
| 149 |
--let $assert_text_event_not_present_mysqlbinlog= The LOAD DATA event is not written with --require_row_format |
| 150 |
--let $assert_text_event_present_mysqlbinlog= The LOAD DATA event is written without --require_row_format |
| 151 |
--let $assert_select_event_present_mysqlbinlog= LOAD DATA LOCAL |
| 152 |
--source $MYSQL_TMP_DIR/check_mysqlbinlog_row_format_error.inc |
| 153 |
|
| 154 |
|
| 155 |
--echo # |
| 156 |
--echo # 3. Log a transaction with a USER_VAR event (T2) |
| 157 |
|
| 158 |
CREATE TABLE t1(i INT) ENGINE=InnoDB; |
| 159 |
|
| 160 |
--eval SET @v= 10 |
| 161 |
--eval INSERT INTO t1 VALUES (@v) |
| 162 |
|
| 163 |
--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 164 |
|
| 165 |
FLUSH LOGS; |
| 166 |
|
| 167 |
--echo # |
| 168 |
--echo # 3.1 Check mysqlbinlog errors out (T2) |
| 169 |
|
| 170 |
--let $assert_text_event_not_present_mysqlbinlog= The USER_VAR event is not written with --require_row_format |
| 171 |
--let $assert_text_event_present_mysqlbinlog= The USER_VAR event is written without --require_row_format |
| 172 |
--let $assert_select_event_present_mysqlbinlog= User_var |
| 173 |
--source $MYSQL_TMP_DIR/check_mysqlbinlog_row_format_error.inc |
| 174 |
|
| 175 |
|
| 176 |
--echo # |
| 177 |
--echo # 4. Log a transaction with a RAND event (T2) |
| 178 |
|
| 179 |
INSERT INTO t1 VALUES (Rand()); |
| 180 |
|
| 181 |
DROP TABLE t1; |
| 182 |
|
| 183 |
--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 184 |
|
| 185 |
FLUSH LOGS; |
| 186 |
|
| 187 |
--echo # |
| 188 |
--echo # 4.1 Check mysqlbinlog errors out (T2) |
| 189 |
|
| 190 |
--let $assert_text_event_not_present_mysqlbinlog= The RAND event is not written with --require_row_format |
| 191 |
--let $assert_text_event_present_mysqlbinlog= The RAND event is written without --require_row_format |
| 192 |
--let $assert_select_event_present_mysqlbinlog= SET @@RAND_ |
| 193 |
--source $MYSQL_TMP_DIR/check_mysqlbinlog_row_format_error.inc |
| 194 |
|
| 195 |
--echo # |
| 196 |
--echo # 5. Log a transaction with a INTVAR event (T2) |
| 197 |
|
| 198 |
CREATE TABLE t2 (j INT PRIMARY KEY AUTO_INCREMENT); |
| 199 |
|
| 200 |
INSERT INTO t2 VALUES(); |
| 201 |
|
| 202 |
DROP TABLE t2; |
| 203 |
|
| 204 |
--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 205 |
|
| 206 |
FLUSH LOGS; |
| 207 |
|
| 208 |
--echo # |
| 209 |
--echo # 5.1 Check mysqlbinlog errors out (T2) |
| 210 |
|
| 211 |
--let $assert_text_event_not_present_mysqlbinlog= The INTVAR event is not written with --require_row_format |
| 212 |
--let $assert_text_event_present_mysqlbinlog= The INTVAR event is written without --require_row_format |
| 213 |
--let $assert_select_event_present_mysqlbinlog= Intvar |
| 214 |
--source $MYSQL_TMP_DIR/check_mysqlbinlog_row_format_error.inc |
| 215 |
|
| 216 |
--echo # |
| 217 |
--echo # 6. Log a transaction with a CREATE TEMPORARY TABLE query (T3) |
| 218 |
|
| 219 |
CREATE TEMPORARY TABLE t1 (k INT PRIMARY KEY); |
| 220 |
|
| 221 |
--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 222 |
|
| 223 |
FLUSH LOGS; |
| 224 |
|
| 225 |
--echo # |
| 226 |
--echo # 6.1 Check mysqlbinlog errors out (T3) |
| 227 |
|
| 228 |
--let $assert_text_event_not_present_mysqlbinlog= The CREATE TEMPORARY TABLE is not written with --require_row_format |
| 229 |
--let $assert_text_event_present_mysqlbinlog= The CREATE TEMPORARY TABLE is written without --require_row_format |
| 230 |
--let $assert_select_event_present_mysqlbinlog= CREATE TEMPORARY TABLE |
| 231 |
--source $MYSQL_TMP_DIR/check_mysqlbinlog_row_format_error.inc |
| 232 |
|
| 233 |
|
| 234 |
--echo # |
| 235 |
--echo # 7. Log a transaction with a DROP TEMPORARY TABLE query (T3) |
| 236 |
|
| 237 |
DROP TEMPORARY TABLE t1; |
| 238 |
|
| 239 |
--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 240 |
|
| 241 |
FLUSH LOGS; |
| 242 |
|
| 243 |
--echo # |
| 244 |
--echo # 7.1 Check mysqlbinlog errors out (T3) |
| 245 |
|
| 246 |
--let $assert_text_event_not_present_mysqlbinlog= The DROP TEMPORARY TABLE is not written with --require_row_format |
| 247 |
--let $assert_text_event_present_mysqlbinlog= The DROP TEMPORARY TABLE is written without --require_row_format |
| 248 |
--let $assert_select_event_present_mysqlbinlog= DROP TEMPORARY TABLE |
| 249 |
--source $MYSQL_TMP_DIR/check_mysqlbinlog_row_format_error.inc |
| 250 |
|
| 251 |
--echo # |
| 252 |
--echo # 8. Cleanup |
| 253 |
|
| 254 |
--remove_file $MYSQL_TMP_DIR/check_mysqlbinlog_row_format_error.inc |
| 255 |
|
| 256 |
--remove_files_wildcard $MYSQL_TMP_DIR/ SQL_LOAD_MB* |