]>
Commit | Line | Data |
---|---|---|
8c0fcd57 ER |
1 | # name : suppress_log_warning_1592.patch |
2 | # introduced : 11 or before | |
74952c29 | 3 | # maintainer : Oleg |
8c0fcd57 ER |
4 | # |
5 | #!!! notice !!! | |
6 | # Any small change to this file in the main branch | |
7 | # should be done or reviewed by the maintainer! | |
4eec3829 AM |
8 | --- a/sql/mysql_priv.h |
9 | +++ b/sql/mysql_priv.h | |
3700c2a6 | 10 | @@ -2110,6 +2110,7 @@ |
8c0fcd57 ER |
11 | extern my_bool opt_readonly, lower_case_file_system; |
12 | extern my_bool opt_userstat_running, opt_thread_statistics; | |
13 | extern my_bool opt_optimizer_fix; | |
14 | +extern my_bool opt_suppress_log_warning_1592; | |
15 | extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs; | |
16 | extern my_bool opt_secure_auth; | |
17 | extern char* opt_secure_file_priv; | |
4eec3829 AM |
18 | --- a/sql/mysqld.cc |
19 | +++ b/sql/mysqld.cc | |
3700c2a6 | 20 | @@ -543,6 +543,7 @@ |
8c0fcd57 ER |
21 | my_bool opt_old_style_user_limits= 0, trust_function_creators= 0; |
22 | my_bool opt_userstat_running= 0, opt_thread_statistics= 0; | |
23 | my_bool opt_optimizer_fix= 0; | |
24 | +my_bool opt_suppress_log_warning_1592= 0; | |
25 | /* | |
26 | True if there is at least one per-hour limit for some user, so we should | |
27 | check them before each query (and possibly reset counters when hour is | |
3700c2a6 | 28 | @@ -5868,6 +5869,7 @@ |
8c0fcd57 ER |
29 | OPT_USERSTAT_RUNNING, |
30 | OPT_THREAD_STATISTICS, | |
31 | OPT_OPTIMIZER_FIX, | |
32 | + OPT_SUPPRESS_LOG_WARNING_1592, | |
33 | OPT_USE_GLOBAL_LONG_QUERY_TIME, | |
34 | OPT_USE_GLOBAL_LOG_SLOW_CONTROL, | |
35 | OPT_SLOW_QUERY_LOG_MICROSECONDS_TIMESTAMP, | |
3700c2a6 | 36 | @@ -7388,6 +7390,10 @@ |
8c0fcd57 ER |
37 | "Enable unofficial optimizer fixes.", |
38 | (uchar**) &opt_optimizer_fix, (uchar**) &opt_optimizer_fix, | |
39 | 0, GET_BOOL, NO_ARG, 1, 0, 1, 0, 1, 0}, | |
40 | + {"suppress_log_warning_1592", OPT_SUPPRESS_LOG_WARNING_1592, | |
41 | + "suppress warning about unsafe statements for binary logging", | |
42 | + (uchar**) &opt_suppress_log_warning_1592, (uchar**) &opt_suppress_log_warning_1592, | |
43 | + 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0}, | |
44 | {"binlog-direct-non-transactional-updates", OPT_BINLOG_DIRECT_NON_TRANS_UPDATE, | |
45 | "Causes updates to non-transactional engines using statement format to be " | |
46 | "written directly to binary log. Before using this option, make sure that " | |
4eec3829 AM |
47 | --- a/sql/set_var.cc |
48 | +++ b/sql/set_var.cc | |
3700c2a6 | 49 | @@ -575,6 +575,8 @@ |
8c0fcd57 ER |
50 | &opt_thread_statistics); |
51 | static sys_var_bool_ptr sys_optimizer_fix(&vars, "optimizer_fix", | |
52 | &opt_optimizer_fix); | |
53 | +static sys_var_bool_ptr sys_suppress_log_warning_1592(&vars, "suppress_log_warning_1592", | |
54 | + &opt_suppress_log_warning_1592); | |
55 | static sys_var_thd_ulong sys_read_rnd_buff_size(&vars, "read_rnd_buffer_size", | |
56 | &SV::read_rnd_buff_size); | |
57 | static sys_var_thd_ulong sys_div_precincrement(&vars, "div_precision_increment", | |
4eec3829 AM |
58 | --- a/sql/sql_class.cc |
59 | +++ b/sql/sql_class.cc | |
3700c2a6 | 60 | @@ -4141,6 +4141,7 @@ |
8c0fcd57 ER |
61 | ER_BINLOG_UNSAFE_STATEMENT, |
62 | ER(ER_BINLOG_UNSAFE_STATEMENT)); | |
63 | if (global_system_variables.log_warnings && | |
64 | + !opt_suppress_log_warning_1592 && | |
65 | !(binlog_flags & BINLOG_FLAG_UNSAFE_STMT_PRINTED)) | |
66 | { | |
67 | sql_print_warning("%s Statement: %.*s", | |
4eec3829 AM |
68 | --- /dev/null |
69 | +++ b/mysql-test/r/percona_suppress_log_warning_1592.result | |
70 | @@ -0,0 +1,28 @@ | |
71 | +SET @old_log_warnings = @@log_warnings; | |
72 | +SET @old_suppress_log_warning_1592 = @@suppress_log_warning_1592; | |
73 | +DROP TABLE IF EXISTS t1; | |
74 | +CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(20)); | |
75 | +SET GLOBAL SUPPRESS_LOG_WARNING_1592 = 0; | |
76 | +SET GLOBAL LOG_WARNINGS = 0; | |
77 | +INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); | |
78 | +Warnings: | |
79 | +Note 1592 Statement may not be safe to log in statement format. | |
80 | +SET GLOBAL LOG_WARNINGS = 1; | |
81 | +INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); | |
82 | +Warnings: | |
83 | +Note 1592 Statement may not be safe to log in statement format. | |
84 | +SET GLOBAL SUPPRESS_LOG_WARNING_1592 = 1; | |
85 | +SET GLOBAL LOG_WARNINGS = 0; | |
86 | +INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); | |
87 | +Warnings: | |
88 | +Note 1592 Statement may not be safe to log in statement format. | |
89 | +SET GLOBAL LOG_WARNINGS = 1; | |
90 | +INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); | |
91 | +Warnings: | |
92 | +Note 1592 Statement may not be safe to log in statement format. | |
93 | +DROP TABLE t1; | |
94 | +SET GLOBAL log_warnings = @old_log_warnings; | |
95 | +SET GLOBAL suppress_log_warning_1592 = @old_suppress_log_warning_1592; | |
96 | +# Count the number of times the "Unsafe" message was printed | |
97 | +# to the error log. | |
98 | +Occurrences: 1 | |
99 | --- /dev/null | |
100 | +++ b/mysql-test/t/percona_suppress_log_warning_1592-master.opt | |
101 | @@ -0,0 +1 @@ | |
102 | +--log-error | |
103 | --- /dev/null | |
104 | +++ b/mysql-test/t/percona_suppress_log_warning_1592.test | |
105 | @@ -0,0 +1,49 @@ | |
106 | +-- source include/have_log_bin.inc | |
107 | +-- source include/have_binlog_format_statement.inc | |
108 | + | |
109 | +SET @old_log_warnings = @@log_warnings; | |
110 | +SET @old_suppress_log_warning_1592 = @@suppress_log_warning_1592; | |
111 | + | |
112 | +--disable_warnings | |
113 | +DROP TABLE IF EXISTS t1; | |
114 | +--enable_warnings | |
115 | +CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(20)); | |
116 | +SET GLOBAL SUPPRESS_LOG_WARNING_1592 = 0; | |
117 | +SET GLOBAL LOG_WARNINGS = 0; | |
118 | +INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); | |
119 | +SET GLOBAL LOG_WARNINGS = 1; | |
120 | +INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); | |
121 | +SET GLOBAL SUPPRESS_LOG_WARNING_1592 = 1; | |
122 | +SET GLOBAL LOG_WARNINGS = 0; | |
123 | +INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); | |
124 | +SET GLOBAL LOG_WARNINGS = 1; | |
125 | +INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); | |
126 | +DROP TABLE t1; | |
127 | + | |
128 | +SET GLOBAL log_warnings = @old_log_warnings; | |
129 | +SET GLOBAL suppress_log_warning_1592 = @old_suppress_log_warning_1592; | |
130 | + | |
131 | +let $log_error_= `SELECT @@GLOBAL.log_error`; | |
132 | +if(!`select LENGTH('$log_error_')`) | |
133 | +{ | |
134 | + # MySQL Server on windows is started with --console and thus | |
135 | + # does not know the location of its .err log, use default location | |
136 | + let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.1.err; | |
137 | +} | |
138 | +# Assign env variable LOG_ERROR | |
139 | +let LOG_ERROR=$log_error_; | |
140 | + | |
141 | +--echo # Count the number of times the "Unsafe" message was printed | |
142 | +--echo # to the error log. | |
143 | + | |
144 | +perl; | |
145 | + use strict; | |
146 | + my $log_error= $ENV{'LOG_ERROR'} or die "LOG_ERROR not set"; | |
147 | + open(FILE, "$log_error") or die("Unable to open $log_error: $!\n"); | |
148 | + my $count = () = grep(/suppress_1592/g,<FILE>); | |
149 | + print "Occurrences: $count\n"; | |
150 | + close(FILE); | |
151 | + # Clean error log file | |
152 | + open(FILE, '>', "$log_error"); | |
153 | + close(FILE); | |
154 | +EOF |