~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# BUG#42851: Spurious "Statement is not safe to log in statement
 
2
#            format." warnings
 
3
#
 
4
# WHY
 
5
# ===
 
6
#   
 
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
 
9
#   binlog, is working.
 
10
#
 
11
# HOW
 
12
# ===
 
13
#
 
14
#   The test case is split into three assertions when issuing statements
 
15
#   containing LIMIT and ORDER BY:
 
16
#
 
17
#     i) issue statements in database that is not filtered => check
 
18
#        that warnings ARE shown;
 
19
#
 
20
#    ii) issue statements in database that is not filtered, but with
 
21
#        binlog disabled => check that warnings ARE NOT shown;
 
22
#
 
23
#   iii) issue statements in database that is filtered => check that
 
24
#        warnings ARE NOT shown.
 
25
 
 
26
-- source include/have_log_bin.inc
 
27
-- source include/have_binlog_format_statement.inc
 
28
 
 
29
-- echo ### NOT filtered database => assertion: warnings ARE shown
 
30
 
 
31
-- disable_warnings
 
32
DROP TABLE IF EXISTS t1;
 
33
-- enable_warnings
 
34
 
 
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;
 
39
DROP TABLE t1;
 
40
 
 
41
-- echo ### NOT filtered database => assertion: binlog disabled and warnings ARE NOT shown
 
42
 
 
43
SET SQL_LOG_BIN= 0;
 
44
 
 
45
-- disable_warnings
 
46
DROP TABLE IF EXISTS t1;
 
47
-- enable_warnings
 
48
 
 
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;
 
53
DROP TABLE t1;
 
54
 
 
55
SET SQL_LOG_BIN= 1;
 
56
 
 
57
-- echo ### FILTERED database => assertion: warnings ARE NOT shown
 
58
 
 
59
let $old_db= `SELECT DATABASE()`;
 
60
 
 
61
CREATE DATABASE b42851;
 
62
USE b42851;
 
63
 
 
64
-- disable_warnings
 
65
DROP TABLE IF EXISTS t1;
 
66
-- enable_warnings
 
67
 
 
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;
 
72
DROP TABLE t1;
 
73
 
 
74
# clean up
 
75
DROP DATABASE b42851;
 
76
 
 
77
eval USE $old_db;
 
78
 
 
79
--echo #
 
80
--echo # Bug#46265: Can not disable warning about unsafe statements for binary logging
 
81
--echo #
 
82
 
 
83
SET @old_log_warnings = @@log_warnings;
 
84
 
 
85
--disable_warnings
 
86
DROP TABLE IF EXISTS t1;
 
87
--enable_warnings
 
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');
 
93
DROP TABLE t1;
 
94
 
 
95
SET GLOBAL log_warnings = @old_log_warnings;
 
96
 
 
97
let $log_error_= `SELECT @@GLOBAL.log_error`;
 
98
if(!`select LENGTH('$log_error_')`)
 
99
{
 
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;
 
103
}
 
104
# Assign env variable LOG_ERROR
 
105
let LOG_ERROR=$log_error_;
 
106
 
 
107
--echo # Count the number of times the "Unsafe" message was printed
 
108
--echo # to the error log.
 
109
 
 
110
perl;
 
111
  use strict;
 
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";
 
116
  close(FILE);
 
117
EOF