1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
|
# ==== Purpose ====
#
# This test check if DDL statements are correctly binlogged when the
# thread is killed
#
# ==== Method ====
#
# Start a DDL query and kill it, check if the error code of the binlog
# event is correct.
#
# DDL statements tested:
# CREATE/ALTER/RENAME/DROP DATABASE
# CREATE/ALTER/DROP EVENT
# CREATE/ALTER/DROP FUNCTION
# CREATE/ALTER/DROP PROCEDURE
# CREATE/ALTER/DROP SERVER
# CREATE/ALTER/RENAME/DROP TABLE
# CREATE/DROP TRIGGER
# CREATE/ALTER/DROP VIEW
#
# ==== Bugs =====
#
# BUG#37145
#
# ==== TODO ====
#
# There are some part of the test are temporarily disabled because of
# the following bugs, please enable then once they get fixed:
# - BUG#22473427
# - Bug#22587377
# Temporarily disabled on Windows due to bug #47638
--source include/not_windows.inc
source include/have_debug.inc;
source include/master-slave.inc;
# Use the DBUG_SYNC_POINT to make sure the thread running the DDL is
# waiting before creating the query log event
let $debug_lock= "debug_lock.before_query_log_event";
######## INITIALIZATION ########
disable_warnings;
DROP DATABASE IF EXISTS d1;
DROP DATABASE IF EXISTS d2;
DROP DATABASE IF EXISTS d3;
DROP DATABASE IF EXISTS d4;
DROP EVENT IF EXISTS e1;
DROP EVENT IF EXISTS e2;
DROP EVENT IF EXISTS e3;
DROP EVENT IF EXISTS e4;
DROP FUNCTION IF EXISTS f1;
DROP FUNCTION IF EXISTS f2;
DROP FUNCTION IF EXISTS f3;
DROP FUNCTION IF EXISTS f4;
DROP SERVER IF EXISTS s1;
DROP SERVER IF EXISTS s2;
DROP SERVER IF EXISTS s3;
DROP SERVER IF EXISTS s4;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t3;
DROP TABLE IF EXISTS t4;
DROP PROCEDURE IF EXISTS p1;
DROP PROCEDURE IF EXISTS p2;
DROP PROCEDURE IF EXISTS p3;
DROP PROCEDURE IF EXISTS p4;
DROP TRIGGER IF EXISTS tr1;
DROP TRIGGER IF EXISTS tr2;
DROP TRIGGER IF EXISTS tr3;
DROP TRIGGER IF EXISTS tr4;
enable_warnings;
CREATE DATABASE d1;
CREATE EVENT e1
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY
DO INSERT INTO test.t1 VALUES (1);
CREATE FUNCTION f1 () RETURNS INT DETERMINISTIC
RETURN 1;
DELIMITER //;
CREATE PROCEDURE p1 (OUT rows_cnt INT)
BEGIN
SELECT COUNT(*) INTO rows_cnt FROM t1;
END;
//
DELIMITER ;//
CREATE SERVER s1
FOREIGN DATA WRAPPER mysql
OPTIONS (USER 'user1', HOST '192.168.1.106', DATABASE 'test');
CREATE TABLE t1 (a int);
CREATE TABLE t3 (a int);
DELIMITER //;
CREATE TRIGGER tr1 BEFORE INSERT ON t1
FOR EACH ROW BEGIN
DELETE FROM t4 WHERE a=NEW.a;
END;
//
DELIMITER ;//
CREATE INDEX i1 ON t1 (a);
CREATE VIEW v1 AS SELECT a FROM t1 WHERE a < 100;
sync_slave_with_master;
connection master1;
let $connection_name= master1;
let $connection_id= `SELECT CONNECTION_ID()`;
connection master;
# This will block the execution of a statement at the DBUG_SYNC_POINT
# with given lock name
if ($debug_lock)
{
disable_query_log;
disable_result_log;
eval SELECT IS_FREE_LOCK($debug_lock);
eval SELECT GET_LOCK($debug_lock, 10);
eval SELECT IS_FREE_LOCK($debug_lock);
enable_query_log;
enable_result_log;
}
######## START TEST ########
connection master1;
disable_warnings;
######## DATABASE ########
let $rpl_diff_statement= SELECT schema_name FROM information_schema.schemata
WHERE schema_name LIKE \'d%\' ORDER BY schema_name;
send CREATE DATABASE d2;
source include/kill_query_and_diff_master_slave.inc;
send ALTER DATABASE d1
DEFAULT CHARACTER SET = 'utf8';
source include/kill_query_and_diff_master_slave.inc;
send DROP DATABASE d1;
source include/kill_query_and_diff_master_slave.inc;
send DROP DATABASE IF EXISTS d2;
source include/kill_query_and_diff_master_slave.inc;
######## EVENT ########
let $rpl_diff_statement= SELECT event_name, event_body, execute_at
FROM information_schema.events where event_name like \'e%\'
ORDER BY event_name;
send CREATE EVENT e2
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY
DO INSERT INTO test.t1 VALUES (2);
source include/kill_query_and_diff_master_slave.inc;
# Temporarily disabled,see Bug#22587377-RPL.RPL_KILLED_DDL
# FAILS SPORADICALLY ON PB2 IN 5.5 AND 5.6
#send ALTER EVENT e1
# ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 2 DAY;
#source include/kill_query_and_diff_master_slave.inc;
send DROP EVENT e1;
source include/kill_query_and_diff_master_slave.inc;
send DROP EVENT IF EXISTS e2;
source include/kill_query_and_diff_master_slave.inc;
######## FUNCTION ########
--let $rpl_diff_statement= SHOW FUNCTION STATUS LIKE \'f%\'
send CREATE FUNCTION f2 () RETURNS INT DETERMINISTIC
RETURN 1;
source include/kill_query_and_diff_master_slave.inc;
send ALTER FUNCTION f1 SQL SECURITY INVOKER;
source include/kill_query_and_diff_master_slave.inc;
# function f1 probably does not exist because the ALTER query was
# killed
send DROP FUNCTION f1;
source include/kill_query_and_diff_master_slave.inc;
# function f2 probably does not exist because the CREATE query was
# killed
send DROP FUNCTION IF EXISTS f2;
source include/kill_query_and_diff_master_slave.inc;
######## PROCEDURE ########
--let $rpl_diff_statement= SHOW PROCEDURE STATUS LIKE \'p%\'
DELIMITER //;
send CREATE PROCEDURE p2 (OUT rows_cnt INT)
BEGIN
SELECT COUNT(*) INTO rows_cnt FROM t2;
END;
//
DELIMITER ;//
source include/kill_query_and_diff_master_slave.inc;
send ALTER PROCEDURE p1 SQL SECURITY INVOKER COMMENT 'return rows_cnt of table t1';
source include/kill_query_and_diff_master_slave.inc;
send DROP PROCEDURE p1;
source include/kill_query_and_diff_master_slave.inc;
send DROP PROCEDURE IF EXISTS p2;
source include/kill_query_and_diff_master_slave.inc;
######## TABLE ########
--let $rpl_diff_statement= SHOW TABLES LIKE \'t%\'
send CREATE TABLE t2 (b int);
source include/kill_query_and_diff_master_slave.inc;
send ALTER TABLE t1 ADD (d int);
source include/kill_query_and_diff_master_slave.inc;
send RENAME TABLE t3 TO t4;
source include/kill_query_and_diff_master_slave.inc;
######## INDEX ########
--let $rpl_diff_statement= SHOW INDEX FROM t1
send CREATE INDEX i2 on t1 (a);
source include/kill_query_and_diff_master_slave.inc;
send DROP INDEX i1 on t1;
source include/kill_query_and_diff_master_slave.inc;
######## SERVER ########
# Temporarily disabled, see Bug #22473427 - DROP SERVER FAILS
# AFTER ALTER SERVER+KILL QUERY
# --let $rpl_diff_statement= SELECT * FROM mysql.servers WHERE Server_name like \'s%\'
# send CREATE SERVER s2
# FOREIGN DATA WRAPPER mysql
# OPTIONS (USER 'user2', HOST '192.168.1.108', DATABASE 'test');
# source include/kill_query_and_diff_master_slave.inc;
# send ALTER SERVER s1
# OPTIONS (DATABASE 'test1');
# source include/kill_query_and_diff_master_slave.inc;
# send DROP SERVER s1;
# source include/kill_query_and_diff_master_slave.inc;
# send DROP SERVER IF EXIST s1;
# source include/kill_query_and_diff_master_slave.inc;
######## TRIGGER ########
# Make sure table t4 exists
connection master;
CREATE TABLE IF NOT EXISTS t4 (a int);
connection master1;
--let $rpl_diff_statement= SHOW TRIGGERS LIKE \'v%\'
DELIMITER //;
send CREATE TRIGGER tr2 BEFORE INSERT ON t4
FOR EACH ROW BEGIN
DELETE FROM t1 WHERE a=NEW.a;
END;
//
DELIMITER ;//
source include/kill_query_and_diff_master_slave.inc;
send DROP TRIGGER tr1;
source include/kill_query_and_diff_master_slave.inc;
send DROP TRIGGER IF EXISTS tr2;
source include/kill_query_and_diff_master_slave.inc;
######## VIEW ########
--let $rpl_diff_statement= SHOW TABLES LIKE \'v%\'
send CREATE VIEW v2 AS SELECT a FROM t1 WHERE a > 100;
source include/kill_query_and_diff_master_slave.inc;
send DROP VIEW v1;
source include/kill_query_and_diff_master_slave.inc;
send DROP VIEW IF EXISTS v2;
source include/kill_query_and_diff_master_slave.inc;
######## DROP TABLE ########
--let $rpl_diff_statement= SHOW TABLES LIKE \'t%\'
send DROP TABLE t1;
source include/kill_query_and_diff_master_slave.inc;
send DROP TABLE IF EXISTS t2;
source include/kill_query_and_diff_master_slave.inc;
######## CLEAN UP ########
connection master;
# The DROP statements above are killed during the process, so they
# does not make sure the objects are dropped.
disable_warnings;
DROP DATABASE IF EXISTS d1;
DROP DATABASE IF EXISTS d2;
DROP DATABASE IF EXISTS d3;
DROP DATABASE IF EXISTS d4;
DROP EVENT IF EXISTS e1;
DROP EVENT IF EXISTS e2;
DROP EVENT IF EXISTS e3;
DROP EVENT IF EXISTS e4;
DROP FUNCTION IF EXISTS f1;
DROP FUNCTION IF EXISTS f2;
DROP FUNCTION IF EXISTS f3;
DROP FUNCTION IF EXISTS f4;
DROP SERVER IF EXISTS s1;
DROP SERVER IF EXISTS s2;
DROP SERVER IF EXISTS s3;
DROP SERVER IF EXISTS s4;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t3;
DROP TABLE IF EXISTS t4;
DROP PROCEDURE IF EXISTS p1;
DROP PROCEDURE IF EXISTS p2;
DROP PROCEDURE IF EXISTS p3;
DROP PROCEDURE IF EXISTS p4;
enable_warnings;
--source include/rpl_end.inc
|