1-- Copyright (c) 2008, 2011, Oracle and/or its affiliates
2--
3-- This program is free software; you can redistribute it and/or modify
4-- it under the terms of the GNU General Public License as published by
5-- the Free Software Foundation; version 2 of the License.
6--
7-- This program is distributed in the hope that it will be useful,
8-- but WITHOUT ANY WARRANTY; without even the implied warranty of
9-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10-- GNU General Public License for more details.
11--
12-- You should have received a copy of the GNU General Public License
13-- along with this program; if not, write to the Free Software Foundation,
14-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335  USA
15
16delimiter ||;
17
18use mtr||
19
20--
21-- Create table where testcases can insert patterns to
22-- be suppressed
23--
24CREATE TABLE test_suppressions (
25  pattern VARCHAR(255)
26) ENGINE=MyISAM||
27
28
29--
30-- Declare a trigger that makes sure
31-- no invalid patterns can be inserted
32-- into test_suppressions
33--
34SET @character_set_client_saved = @@character_set_client||
35SET @character_set_results_saved = @@character_set_results||
36SET @collation_connection_saved = @@collation_connection||
37SET @@character_set_client = latin1||
38SET @@character_set_results = latin1||
39SET @@collation_connection = latin1_swedish_ci||
40/*!50002
41CREATE DEFINER=root@localhost TRIGGER ts_insert
42BEFORE INSERT ON test_suppressions
43FOR EACH ROW BEGIN
44  DECLARE dummy INT;
45  SELECT "" REGEXP NEW.pattern INTO dummy;
46END
47*/||
48SET @@character_set_client = @character_set_client_saved||
49SET @@character_set_results = @character_set_results_saved||
50SET @@collation_connection = @collation_connection_saved||
51
52
53--
54-- Load table with patterns that will be suppressed globally(always)
55--
56CREATE TABLE global_suppressions (
57  pattern VARCHAR(255)
58) ENGINE=MyISAM||
59
60
61-- Declare a trigger that makes sure
62-- no invalid patterns can be inserted
63-- into global_suppressions
64--
65SET @character_set_client_saved = @@character_set_client||
66SET @character_set_results_saved = @@character_set_results||
67SET @collation_connection_saved = @@collation_connection||
68SET @@character_set_client = latin1||
69SET @@character_set_results = latin1||
70SET @@collation_connection = latin1_swedish_ci||
71/*!50002
72CREATE DEFINER=root@localhost TRIGGER gs_insert
73BEFORE INSERT ON global_suppressions
74FOR EACH ROW BEGIN
75  DECLARE dummy INT;
76  SELECT "" REGEXP NEW.pattern INTO dummy;
77END
78*/||
79SET @@character_set_client = @character_set_client_saved||
80SET @@character_set_results = @character_set_results_saved||
81SET @@collation_connection = @collation_connection_saved||
82
83
84
85--
86-- Insert patterns that should always be suppressed
87--
88INSERT INTO global_suppressions VALUES
89 (".SELECT UNIX_TIMESTAMP... failed on master"),
90 ("Aborted connection"),
91 ("Client requested master to start replication from impossible position"),
92 ("Could not find first log file name in binary log"),
93 ("Enabling keys got errno"),
94 ("Error reading master configuration"),
95 ("Error reading packet"),
96 ("Event Scheduler"),
97 ("Failed to open log"),
98 ("Failed to open the existing master info file"),
99 ("Forcing shutdown of [0-9]* plugins"),
100
101 /*
102   Due to timing issues, it might be that this warning
103   is printed when the server shuts down and the
104   computer is loaded.
105 */
106
107 ("Got error [0-9]* when reading table"),
108 ("Incorrect definition of table"),
109 ("Incorrect information in file"),
110 ("InnoDB: Warning: we did not need to do crash recovery"),
111 /*("Invalid \\(old\\?\\) table or database name"),*/
112 ("Lock wait timeout exceeded"),
113 ("Log entry on master is longer than max_allowed_packet"),
114 ("unknown option '--loose-"),
115 ("unknown variable 'loose-"),
116 ("You have forced lower_case_table_names to 0 through a command-line option"),
117 ("Setting lower_case_table_names=2"),
118 ("Neither --relay-log nor --relay-log-index were used"),
119 ("Query partially completed"),
120 ("Slave I.O thread aborted while waiting for relay log"),
121 ("Slave SQL thread is stopped because UNTIL condition"),
122 ("Slave SQL thread retried transaction"),
123 ("Slave \\(additional info\\)"),
124 ("Slave: .*Duplicate column name"),
125 ("Slave: .*master may suffer from"),
126 ("Slave: According to the master's version"),
127 ("Slave: Column [0-9]* type mismatch"),
128 ("Slave: Error .* doesn't exist"),
129 ("Slave: Error .*Unknown table"),
130 ("Slave: Error in Write_rows event: "),
131 ("Slave: Field .* of table .* has no default value"),
132 ("Slave: Field .* doesn't have a default value"),
133 ("Slave: Query caused different errors on master and slave"),
134 ("Slave: Table .* doesn't exist"),
135 ("Slave: Table width mismatch"),
136 ("Slave: The incident LOST_EVENTS occurred on the master"),
137 ("Slave: Unknown error.* 1105"),
138 ("Slave: Can't drop database.* database doesn't exist"),
139 ("Warning:\s+One can only use the --user.*root"),
140 ("Warning:\s+Table:.* on (delete|rename)"),
141 ("You have an error in your SQL syntax"),
142 ("deprecated"),
143 ("description of time zone"),
144 ("equal MySQL server ids"),
145 ("error .*connecting to master"),
146 ("error reading log entry"),
147 ("lower_case_table_names is set"),
148 ("skip-name-resolve mode"),
149 ("slave SQL thread aborted"),
150 ("Slave: .*Duplicate entry"),
151
152 ("Statement may not be safe to log in statement format"),
153
154 /* innodb foreign key tests that fail in ALTER or RENAME produce this */
155 ("InnoDB: Error: in ALTER TABLE `test`.`t[123]`"),
156 ("InnoDB: Error: in RENAME TABLE table `test`.`t1`"),
157 ("InnoDB: Error: table `test`.`t[123]` .*does not exist in the InnoDB internal"),
158 ("InnoDB: Warning: semaphore wait:"),
159
160 /*
161   BUG#32080 - Excessive warnings on Solaris: setrlimit could not
162   change the size of core files
163  */
164 ("setrlimit could not change the size of core files to 'infinity'"),
165
166 ("The slave I.O thread stops because a fatal error is encountered when it try to get the value of SERVER_ID variable from master."),
167
168 /*It will print a warning if server is run without --explicit_defaults_for_timestamp.*/
169 ("TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details)*"),
170
171 /* Added 2009-08-XX after fixing Bug #42408 */
172
173 ("Although a path was specified for the .* option, log tables are used"),
174 ("Backup: Operation aborted"),
175 ("Restore: Operation aborted"),
176 ("Restore: The grant .* was skipped because the user does not exist"),
177 ("The path specified for the variable .* is not a directory or cannot be written:"),
178 ("Master server does not support or not configured semi-sync replication, fallback to asynchronous"),
179 (": The MySQL server is running with the --secure-backup-file-priv option so it cannot execute this statement"),
180 ("Slave: Unknown table 't1' error.* 1051"),
181
182 /* Maria storage engine dependent tests */
183
184 /* maria-recovery.test has warning about missing log file */
185 ("File '.*maria_log.000.*' not found \\(Errcode: 2\\)"),
186 /* and about marked-corrupted table */
187 ("Table '..mysqltest.t_corrupted1' is crashed, skipping it. Please repair"),
188 /* maria-recover.test corrupts tables on purpose */
189 ("Checking table:   '..mysqltest.t_corrupted2'"),
190 ("Table '..mysqltest.t_corrupted2' is marked as crashed and should be"),
191 ("Incorrect key file for table '..mysqltest.t_corrupted2.MAI'"),
192
193 /* Messages from valgrind */
194 ("==[0-9]*== Memcheck,"),
195 ("==[0-9]*== Copyright"),
196 ("==[0-9]*== Using"),
197 ("==[0-9]*== For more details"),
198 /* This comes with innodb plugin tests */
199 ("==[0-9]*== Warning: set address range perms: large range"),
200 /* valgrind-3.5.0 dumps this */
201 ("==[0-9]*== Command: "),
202
203 /* valgrind warnings: invalid file descriptor -1 in syscall
204    write()/read(). Bug #50414 */
205 ("==[0-9]*== Warning: invalid file descriptor -1 in syscall write()"),
206 ("==[0-9]*== Warning: invalid file descriptor -1 in syscall read()"),
207
208 /*
209   Transient network failures that cause warnings on reconnect.
210   BUG#47743 and BUG#47983.
211 */
212 ("Slave I/O: Get master SERVER_ID failed with error:.*"),
213 ("Slave I/O: Get master clock failed with error:.*"),
214 ("Slave I/O: Get master COLLATION_SERVER failed with error:.*"),
215 ("Slave I/O: Get master TIME_ZONE failed with error:.*"),
216 ("Slave I/O: The slave I/O thread stops because a fatal error is encountered when it tried to SET @master_binlog_checksum on master.*"),
217 ("Slave I/O: Get master BINLOG_CHECKSUM failed with error.*"),
218 ("Slave I/O: Notifying master by SET @master_binlog_checksum= @@global.binlog_checksum failed with error.*"),
219 ("Slave I/O: Setting master-side filtering of @@skip_replication failed with error:.*"),
220 ("Slave I/O: Setting @mariadb_slave_capability failed with error:.*"),
221 ("Slave I/O: Get master @@GLOBAL.gtid_domain_id failed with error.*"),
222 ("Slave I/O: Setting @slave_connect_state failed with error.*"),
223 ("Slave I/O: Setting @slave_gtid_strict_mode failed with error.*"),
224 ("Slave I/O: Setting @slave_gtid_ignore_duplicates failed with error.*"),
225 ("Slave I/O: Setting @slave_until_gtid failed with error.*"),
226 ("Slave I/O: Get master GTID position failed with error.*"),
227
228 /*
229   MDEV-12501 -- set --maturity-level by default
230 */
231 ("Plugin .* is of maturity level .* while the server is .*"),
232
233 ("THE_LAST_SUPPRESSION")||
234
235
236--
237-- Procedure that uses the above created tables to check
238-- the servers error log for warnings
239--
240CREATE DEFINER=root@localhost PROCEDURE check_warnings(OUT result INT)
241BEGIN
242  DECLARE `pos` bigint unsigned;
243
244  -- Don't write these queries to binlog
245  SET SQL_LOG_BIN=0, SQL_SAFE_UPDATES=0;
246
247  --
248  -- Remove mark from lines that are suppressed by global suppressions
249  --
250  UPDATE error_log el, global_suppressions gs
251    SET suspicious=0
252      WHERE el.suspicious=1 AND el.line REGEXP gs.pattern;
253
254  --
255  -- Remove mark from lines that are suppressed by test specific suppressions
256  --
257  UPDATE error_log el, test_suppressions ts
258    SET suspicious=0
259      WHERE el.suspicious=1 AND el.line REGEXP ts.pattern;
260
261  --
262  -- Get the number of marked lines and return result
263  --
264  SELECT COUNT(*) INTO @num_warnings FROM error_log
265    WHERE suspicious=1;
266
267  IF @num_warnings > 0 THEN
268    SELECT line
269        FROM error_log WHERE suspicious=1;
270    --SELECT * FROM test_suppressions;
271    -- Return 2 -> check failed
272    SELECT 2 INTO result;
273  ELSE
274    -- Return 0 -> OK
275    SELECT 0 INTO RESULT;
276  END IF;
277
278  -- Cleanup for next test
279  TRUNCATE test_suppressions;
280  DROP TABLE error_log;
281
282END||
283
284--
285-- Declare a procedure testcases can use to insert test
286-- specific suppressions
287--
288/*!50001
289CREATE DEFINER=root@localhost
290PROCEDURE add_suppression(pattern VARCHAR(255))
291BEGIN
292  INSERT INTO test_suppressions (pattern) VALUES (pattern);
293  FLUSH NO_WRITE_TO_BINLOG TABLE test_suppressions;
294END
295*/||
296
297
298