Debian Codegraph @

mysql-test/suite/binlog/t/binlog_variables_log_statements_unsafe_for_binlog.test

raw
1 # ==== Purpose ====
2 #
3 # Verify that the log_statements_unsafe_for_binlog system variable works
4 #
5 # ==== Method ====
6 #
7 # 1. Turn on log_statements_unsafe_for_binlog
8 # 2. Run unsafe statement
9 # 3. Verify error log contains warning
10 # 4. Turn off log_statements_unsafe_for_binlog
11 # 5. Run unsafe statement
12 # 6. Verify error log still contains only one warning
13 #
14 # ==== References ====
15 #
16 # WL#8993: Option to not log in the error log when unsafe statements are executed whilst using STATEMENT based binary logging
17
18 --source include/have_log_bin.inc
19 --source include/have_binlog_format_statement.inc
20
21 # As this test file will check for information on the error log, we will
22 # restart the server to make sure that the log contains an "startup" log
23 # message to be used as starting point for the grep.
24 --source include/restart_mysqld.inc
25
26 CALL mtr.add_suppression("Unsafe statement written to the binary log");
27
28 # Setup
29 --let $saved_lsufb= `SELECT @@GLOBAL.log_statements_unsafe_for_binlog`
30
31 CREATE TABLE test.unsafe (i int auto_increment primary key, j int) engine = innodb;
32
33 INSERT INTO test.unsafe (j) VALUES (1), (2), (3);
34
35 #
36 # SCENARIO 1:
37 #
38 # Assert that unsafe statements are written when the option is ON (default)
39 #
40 --echo SCENARIO 1
41 SET GLOBAL log_statements_unsafe_for_binlog= ON;
42
43 UPDATE test.unsafe SET j = 4 LIMIT 1;
44
45 # File to GREP
46 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.1.err
47 # Show entries only after the last occurrence of the following pattern
48 --let $assert_only_after=.* \[System\] \[[^]]*\] \[[^]]*\] .* ready for connections
49 --let $assert_select=.* \[Warning\] \[[^]]*\] \[[^]]*\] Unsafe statement written to the binary log
50 --let $assert_text= Exactly one row should be written to the error log.
51 --let $assert_count= 1
52 --source include/assert_grep.inc
53
54 #
55 # SCENARIO 2:
56 # Assert that unsafe statements are NOT written when the option is OFF
57 #
58 --echo SCENARIO 2
59 SET GLOBAL log_statements_unsafe_for_binlog= OFF;
60
61 connect (conn1,localhost,root,,);
62
63 connection conn1;
64
65 UPDATE test.unsafe SET j = 4 LIMIT 1;
66
67 let $assert_text= Still only one row should be present in the error log.
68 --let $assert_count= 1
69 --source include/assert_grep.inc
70
71 # Clean up
72 disconnect conn1;
73 DROP TABLE test.unsafe;
74 --eval SET GLOBAL log_statements_unsafe_for_binlog= $saved_lsufb