Debian Codegraph @

mysql-test/suite/ndb_rpl/t/ndb_rpl_rep_error.test

raw
1 #
2 # Some negative tests of the ndb_replication table
3 #
4 #
5 --source include/have_multi_ndb.inc
6 --source include/have_binlog_format_mixed_or_row.inc
7 --source suite/ndb_rpl/ndb_master-slave.inc
8
9 # Need suppressions on all servers where warnings/errors can be seen.
10 --disable_query_log
11 --connection server1
12 call mtr.add_suppression(".*Bad schema for mysql.ndb_replication table.*");
13 call mtr.add_suppression("Replica: .* unknown conflict resolution function .*");
14 call mtr.add_suppression("Replica: .* missing function argument .*");
15 call mtr.add_suppression("Replica: .* missing \'\\)\' .*");
16 --connection server2
17 call mtr.add_suppression(".*Bad schema for mysql.ndb_replication table.*");
18 call mtr.add_suppression("Replica: .* unknown conflict resolution function .*");
19 call mtr.add_suppression("Replica: .* missing function argument .*");
20 call mtr.add_suppression("Replica: .* missing \'\\)\' .*");
21 --connection default
22 --enable_query_log
23
24 #
25 --echo Wrong schema for the table, too few pks
26 #
27 --disable_warnings
28 --disable_query_log
29 drop table if exists mysql.ndb_replication;
30 CREATE TABLE mysql.ndb_replication
31 (db VARBINARY(63),
32 table_name VARBINARY(63),
33 server_id INT UNSIGNED,
34 binlog_type INT UNSIGNED,
35 conflict_fn VARBINARY(128),
36 PRIMARY KEY USING HASH (db,table_name))
37 ENGINE=NDB PARTITION BY KEY(db,table_name);
38 --enable_warnings
39 --enable_query_log
40
41 # gives warning when trying to create table as logging
42 # may not be as intended
43 create table t1 (a int key, X int) engine ndb;
44 drop table t1;
45
46
47 #
48 --echo Wrong schema for the table, incorrect pk
49 #
50 --disable_warnings
51 --disable_query_log
52 drop table if exists mysql.ndb_replication;
53 CREATE TABLE mysql.ndb_replication
54 (db VARBINARY(63),
55 table_name VARBINARY(63),
56 server_id INT UNSIGNED,
57 binlog_type INT UNSIGNED,
58 conflict_fn VARBINARY(128),
59 PRIMARY KEY USING HASH (db,table_name,binlog_type))
60 ENGINE=NDB PARTITION BY KEY(db,table_name);
61 --enable_warnings
62 --enable_query_log
63
64 # gives warning when trying to create table as logging
65 # may not be as intended
66 create table t1 (a int key, X int) engine ndb;
67 drop table t1;
68
69 #
70 --echo Wrong schema for the table, binlog_type is signed
71 #
72
73 --disable_warnings
74 --disable_query_log
75 drop table if exists mysql.ndb_replication;
76 CREATE TABLE mysql.ndb_replication
77 (db VARBINARY(63),
78 table_name VARBINARY(63),
79 server_id INT UNSIGNED,
80 binlog_type INT,
81 conflict_fn VARBINARY(128),
82 PRIMARY KEY USING HASH (db,table_name,server_id))
83 ENGINE=NDB PARTITION BY KEY(db,table_name);
84 --enable_warnings
85 --enable_query_log
86
87 # gives warning when trying to create table as logging
88 # may not be as intended
89 create table t1 (a int key, X int) engine ndb;
90 drop table t1;
91
92 #
93 --echo Wrong schema for the table, conflict_fn is too long
94 #
95 --disable_warnings
96 --disable_query_log
97 drop table mysql.ndb_replication;
98 CREATE TABLE mysql.ndb_replication
99 (db VARBINARY(63),
100 table_name VARBINARY(63),
101 server_id INT UNSIGNED,
102 binlog_type INT UNSIGNED,
103 conflict_fn VARBINARY(257),
104 PRIMARY KEY USING HASH (db,table_name,server_id))
105 ENGINE=NDB PARTITION BY KEY(db,table_name);
106 --enable_warnings
107 --enable_query_log
108
109 # gives warning when trying to create table as logging
110 # may not be as intended
111 create table t1 (a int key, X int) engine ndb;
112 drop table t1;
113
114 #
115 --echo Correct schema for the table but no conflict fn
116 #
117 --disable_warnings
118 --disable_query_log
119 drop table mysql.ndb_replication;
120 CREATE TABLE mysql.ndb_replication
121 (db VARBINARY(63),
122 table_name VARBINARY(63),
123 server_id INT UNSIGNED,
124 binlog_type INT UNSIGNED,
125 PRIMARY KEY USING HASH (db,table_name,server_id))
126 ENGINE=NDB PARTITION BY KEY(db,table_name);
127 --enable_warnings
128 --enable_query_log
129
130 insert into mysql.ndb_replication values ("test", "t1", 0, 7);
131 create table test.t1 (a int primary key) engine=ndb;
132 show warnings;
133 drop table test.t1;
134
135 --let server_num=1.1
136 --let $pattern=%Binlog: logging%
137 --let $limit=1
138 --source suite/ndb_rpl/t/show_mysqld_warnings.inc
139
140 delete from mysql.ndb_replication;
141
142 --echo Check that NULL uses server defaults
143 show variables like 'ndb_log_update_as_write';
144 show variables like 'ndb_log_updated_only';
145 insert into mysql.ndb_replication values ("test", "t1", 0, NULL);
146
147 create table test.t1 (a int primary key) engine=ndb;
148 show warnings;
149 drop table test.t1;
150
151 --source suite/ndb_rpl/t/show_mysqld_warnings.inc
152
153
154 #
155 --echo Correct schema for the table but other errors
156 #
157 --disable_warnings
158 --disable_query_log
159 drop table mysql.ndb_replication;
160 CREATE TABLE mysql.ndb_replication
161 (db VARBINARY(63),
162 table_name VARBINARY(63),
163 server_id INT UNSIGNED,
164 binlog_type INT UNSIGNED,
165 conflict_fn VARBINARY(128),
166 PRIMARY KEY USING HASH (db,table_name,server_id))
167 ENGINE=NDB PARTITION BY KEY(db,table_name);
168 --enable_warnings
169 --enable_query_log
170
171 # Non existant conflict_fn
172 # gives error when creating table
173 #call mtr.add_suppression("Replica: .* unknown conflict resolution function .*");
174
175 insert into mysql.ndb_replication values ("test", "t1", 0, NULL, "NDB$X(X)");
176 --error ER_CONFLICT_FN_PARSE_ERROR
177 create table t1 (a int key, X int) engine ndb;
178 show warnings;
179 delete from mysql.ndb_replication;
180
181 # Column type cannot be used for this function
182 --disable_query_log
183 call mtr.add_suppression("Replica: .* has wrong datatype.*");
184 --enable_query_log
185
186 insert into mysql.ndb_replication values ("test", "t1", 0, NULL, "NDB$MAX(X)");
187 --error ER_CANT_CREATE_TABLE
188 create table t1 (a int key, X int) engine ndb;
189 show warnings;
190 delete from mysql.ndb_replication;
191
192 # Too few arguments
193 # gives error when creating table
194 #call mtr.add_suppression("Replica: .* missing function argument .*");
195
196 insert into mysql.ndb_replication values ("test", "t1", 0, NULL, "NDB$MAX()");
197 --error ER_CONFLICT_FN_PARSE_ERROR
198 create table t1 (a int key, X int) engine ndb;
199 show warnings;
200 delete from mysql.ndb_replication;
201
202 # Too many arguments
203 # gives error when creating table
204 #call mtr.add_suppression("Replica: .* missing \')\' .*");
205 insert into mysql.ndb_replication values ("test", "t1", 0, NULL, "NDB$MAX(X Y)");
206 --error ER_CONFLICT_FN_PARSE_ERROR
207 create table t1 (a int key, X int) engine ndb;
208 show warnings;
209 delete from mysql.ndb_replication;
210
211 show variables like 'server_id';
212
213 create database europenorth;
214 create database europesouth;
215 create database usnorth;
216 create database ussouth;
217
218 --echo Basic wildcard tests
219 --echo Note that we put in bad conflict fn names so that the warnings generated
220 --echo when the table create fails give an indication of which ndb_replication
221 --echo table row was chosen.
222 --echo
223 --echo Wild serverid
224 insert into mysql.ndb_replication values ("europenorth", "france", 1, NULL, "NDB$A()");
225 insert into mysql.ndb_replication values ("europenorth", "france", 0, NULL, "NDB$B()");
226
227 --echo Should match specific entry (1) with algorithm A.
228 --error ER_CONFLICT_FN_PARSE_ERROR
229 create table europenorth.france (a int primary key) engine=ndb;
230 show warnings;
231
232 delete from mysql.ndb_replication where server_id=1;
233
234 --echo Should match generic entry (0) with algorthin B.
235 --error ER_CONFLICT_FN_PARSE_ERROR
236 create table europenorth.france (a int primary key) engine=ndb;
237 show warnings;
238
239 delete from mysql.ndb_replication;
240
241 --echo Wild table_name
242 insert into mysql.ndb_replication values ("europenorth", "fr_nce", 1, NULL, "NDB$A()");
243 insert into mysql.ndb_replication values ("europenorth", "%any", 1, NULL, "NDB$B()");
244
245 --echo Should match specific entry (fr_nce) with algorithm A.
246 --error ER_CONFLICT_FN_PARSE_ERROR
247 create table europenorth.france (a int primary key) engine=ndb;
248 show warnings;
249
250 --echo Should match specific entry (%any) with algorithm B.
251 --error ER_CONFLICT_FN_PARSE_ERROR
252 create table europenorth.germany (a int primary key) engine=ndb;
253 show warnings;
254
255 --echo Should match specific entry (%any) with algorithm B.
256 --error ER_CONFLICT_FN_PARSE_ERROR
257 create table europenorth.romany (a int primary key) engine=ndb;
258 show warnings;
259
260 --echo No match, should be fine
261 create table europenorth.uk (a int primary key) engine=ndb;
262 show warnings;
263 drop table europenorth.uk;
264
265 delete from mysql.ndb_replication;
266
267 --echo Wild db
268 insert into mysql.ndb_replication values ("%north", "countries", 1, NULL, "NDB$A()");
269 insert into mysql.ndb_replication values ("%south", "countries", 1, NULL, "NDB$B()");
270
271 --echo Should match north with A
272 --error ER_CONFLICT_FN_PARSE_ERROR
273 create table europenorth.countries (a int primary key) engine=ndb;
274 show warnings;
275
276 --echo Should match north with A
277 --error ER_CONFLICT_FN_PARSE_ERROR
278 create table usnorth.countries (a int primary key) engine=ndb;
279 show warnings;
280
281 --echo Should match south with B
282 --error ER_CONFLICT_FN_PARSE_ERROR
283 create table europesouth.countries (a int primary key) engine=ndb;
284 show warnings;
285
286 --echo Should match south with B
287 --error ER_CONFLICT_FN_PARSE_ERROR
288 create table ussouth.countries (a int primary key) engine=ndb;
289 show warnings;
290
291 delete from mysql.ndb_replication;
292
293 --echo Now test wildcard matching precedence
294 --echo Wildcards match in the following precedence (highest->lowest)
295 --echo Exact match
296 --echo Wild serverid
297 --echo Wild table_name
298 --echo Wild serverid + wild table_name
299 --echo Wild db
300 --echo Wild db + wild serverid
301 --echo Wild db + wild table_name
302 --echo All wild
303 --echo
304 --echo The 'wild serverid' is 0
305 --echo
306 --echo Multiple matches at the same precedence are ambiguous and result
307 --echo in an error.
308 --echo
309
310 --echo Start with full set of potential matches, and chip away
311 # Put in duplicate matches at every precedence
312 # Delete rows to get one then no matches at each precedence.
313
314 # Unique
315 insert into mysql.ndb_replication values ("europenorth", "netherlands", 1, NULL, "NDB$A()");
316
317 # Wild serverid
318 insert into mysql.ndb_replication values ("europenorth", "netherlands", 0, NULL, "NDB$B()");
319
320 # Wild table_name (two)
321 insert into mysql.ndb_replication values ("europenorth", "%lands", 1, NULL, "NDB$C()");
322 insert into mysql.ndb_replication values ("europenorth", "nether%s", 1, NULL, "NDB$D()");
323
324 # Wild server_id and table_name
325 insert into mysql.ndb_replication values ("europenorth", "%lands", 0, NULL, "NDB$E()");
326 insert into mysql.ndb_replication values ("europenorth", "nether%s", 0, NULL, "NDB$F()");
327
328 # Wild db
329 insert into mysql.ndb_replication values ("Europe%", "netherlands", 1, NULL, "NDB$G()");
330 insert into mysql.ndb_replication values ("%North", "netherlands", 1, NULL, "NDB$H()");
331
332 # Wild db + Wild server_id
333
334 insert into mysql.ndb_replication values ("Europe%", "netherlands", 0, NULL, "NDB$I()");
335 insert into mysql.ndb_replication values ("%North", "netherlands", 0, NULL, "NDB$J()");
336
337 # Wild db + Wild table_name
338
339 insert into mysql.ndb_replication values ("Europe%", "%lands", 1, NULL, "NDB$K()");
340 insert into mysql.ndb_replication values ("%North", "nether%s", 1, NULL, "NDB$L()");
341
342 # All wild
343
344 insert into mysql.ndb_replication values ("Europe%", "%lands", 0, NULL, "NDB$M()");
345 insert into mysql.ndb_replication values ("%North", "nether%s", 0, NULL, "NDB$N()");
346
347
348 --echo Unique match (A)
349 --error ER_CONFLICT_FN_PARSE_ERROR
350 create table europenorth.netherlands (a int primary key) engine=ndb;
351 show warnings;
352
353 delete from mysql.ndb_replication where db="europenorth" and table_name="netherlands" and server_id=1;
354
355 --echo Unique match with wild serverid (B)
356 --error ER_CONFLICT_FN_PARSE_ERROR
357 create table europenorth.netherlands (a int primary key) engine=ndb;
358 show warnings;
359
360 delete from mysql.ndb_replication where db="europenorth" and table_name="netherlands" and server_id=0;
361
362 --echo Ambiguous wild table name
363 create table europenorth.netherlands (a int primary key) engine=ndb;
364 show warnings;
365 drop table europenorth.netherlands;
366
367 delete from mysql.ndb_replication where db="europenorth" and table_name="%lands" and server_id=1;
368
369 --echo Wild table name (D)
370 --error ER_CONFLICT_FN_PARSE_ERROR
371 create table europenorth.netherlands (a int primary key) engine=ndb;
372 show warnings;
373
374 delete from mysql.ndb_replication where db="europenorth" and table_name="nether%s" and server_id=1;
375
376 --echo Ambiguous wild server id and table name
377 create table europenorth.netherlands (a int primary key) engine=ndb;
378 show warnings;
379 drop table europenorth.netherlands;
380
381 delete from mysql.ndb_replication where db="europenorth" and table_name="nether%s" and server_id=0;
382
383 --echo Wild server id and table name (E)
384 --error ER_CONFLICT_FN_PARSE_ERROR
385 create table europenorth.netherlands (a int primary key) engine=ndb;
386 show warnings;
387
388 delete from mysql.ndb_replication where db="europenorth" and table_name="%lands" and server_id=0;
389
390 --echo Amiguous wild db
391 create table europenorth.netherlands (a int primary key) engine=ndb;
392 show warnings;
393 drop table europenorth.netherlands;
394
395 delete from mysql.ndb_replication where db="Europe%" and table_name="netherlands" and server_id=1;
396
397 --echo Wild db (H)
398 --error ER_CONFLICT_FN_PARSE_ERROR
399 create table europenorth.netherlands (a int primary key) engine=ndb;
400 show warnings;
401
402 delete from mysql.ndb_replication where db="%North" and table_name="netherlands" and server_id=1;
403
404 --echo Ambiguous wild db + server_id
405 create table europenorth.netherlands (a int primary key) engine=ndb;
406 show warnings;
407 drop table europenorth.netherlands;
408
409 delete from mysql.ndb_replication where db="Europe%" and table_name="netherlands" and server_id=0;
410
411 --echo Wild db + server id (J)
412 --error ER_CONFLICT_FN_PARSE_ERROR
413 create table europenorth.netherlands (a int primary key) engine=ndb;
414 show warnings;
415
416 delete from mysql.ndb_replication where db="%North" and table_name="netherlands" and server_id=0;
417
418 --echo Ambiguous wild db + table_name
419 create table europenorth.netherlands (a int primary key) engine=ndb;
420 show warnings;
421 drop table europenorth.netherlands;
422
423 delete from mysql.ndb_replication where db="Europe%" and table_name="%lands" and server_id=1;
424
425 --echo Wild db + table_name (L)
426 --error ER_CONFLICT_FN_PARSE_ERROR
427 create table europenorth.netherlands (a int primary key) engine=ndb;
428 show warnings;
429
430 delete from mysql.ndb_replication where db="%North" and table_name="nether%s" and server_id=1;
431
432 --echo Ambiguous all wild
433 create table europenorth.netherlands (a int primary key) engine=ndb;
434 show warnings;
435 drop table europenorth.netherlands;
436
437 delete from mysql.ndb_replication where db="Europe%" and table_name="%lands" and server_id=0;
438
439 --echo All wild (N)
440 --error ER_CONFLICT_FN_PARSE_ERROR
441 create table europenorth.netherlands (a int primary key) engine=ndb;
442 show warnings;
443
444 delete from mysql.ndb_replication;
445
446 drop database europenorth;
447 drop database europesouth;
448 drop database usnorth;
449 drop database ussouth;
450
451 # cleanup
452 --disable_query_log
453 drop table mysql.ndb_replication;
454 --source include/rpl_end.inc
455 --enable_query_log