1
# BUG#42851: Spurious "Statement is not safe to log in statement
7
# This test aims at checking that the fix that removes spurious
8
# entries in the error log when the statement is filtered out from
14
# The test case is split into three assertions when issuing statements
15
# containing LIMIT and ORDER BY:
17
# i) issue statements in database that is not filtered => check
18
# that warnings ARE shown;
20
# ii) issue statements in database that is not filtered, but with
21
# binlog disabled => check that warnings ARE NOT shown;
23
# iii) issue statements in database that is filtered => check that
24
# warnings ARE NOT shown.
26
-- source include/have_log_bin.inc
27
-- source include/have_binlog_format_statement.inc
29
-- echo ### NOT filtered database => assertion: warnings ARE shown
32
DROP TABLE IF EXISTS t1;
35
CREATE TABLE t1 (a int, b int, primary key (a));
36
INSERT INTO t1 VALUES (1,2), (2,3);
37
UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
38
UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
41
-- echo ### NOT filtered database => assertion: binlog disabled and warnings ARE NOT shown
46
DROP TABLE IF EXISTS t1;
49
CREATE TABLE t1 (a int, b int, primary key (a));
50
INSERT INTO t1 VALUES (1,2), (2,3);
51
UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
52
UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
57
-- echo ### FILTERED database => assertion: warnings ARE NOT shown
59
let $old_db= `SELECT DATABASE()`;
61
CREATE DATABASE b42851;
65
DROP TABLE IF EXISTS t1;
68
CREATE TABLE t1 (a int, b int, primary key (a));
69
INSERT INTO t1 VALUES (1,2), (2,3);
70
UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
71
UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
80
--echo # Bug#46265: Can not disable warning about unsafe statements for binary logging
83
SET @old_log_warnings = @@log_warnings;
86
DROP TABLE IF EXISTS t1;
88
CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(10));
89
SET GLOBAL LOG_WARNINGS = 0;
90
INSERT INTO t1 VALUES(UUID(), 'Bug#46265');
91
SET GLOBAL LOG_WARNINGS = 1;
92
INSERT INTO t1 VALUES(UUID(), 'Bug#46265');
95
SET GLOBAL log_warnings = @old_log_warnings;
97
let $log_error_= `SELECT @@GLOBAL.log_error`;
98
if(!`select LENGTH('$log_error_')`)
100
# MySQL Server on windows is started with --console and thus
101
# does not know the location of its .err log, use default location
102
let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.1.err;
104
# Assign env variable LOG_ERROR
105
let LOG_ERROR=$log_error_;
107
--echo # Count the number of times the "Unsafe" message was printed
108
--echo # to the error log.
112
my $log_error= $ENV{'LOG_ERROR'} or die "LOG_ERROR not set";
113
open(FILE, "$log_error") or die("Unable to open $log_error: $!\n");
114
my $count = () = grep(/Bug#46265/g,<FILE>);
115
print "Occurrences: $count\n";