Debian Codegraph @

mysql-test/suite/rpl/t/rpl_gtid_basic.test

raw
1 #
2 # This include file is used by more than one test suite
3 # (currently rpl and binlog_encryption).
4 # Please check all dependent tests after modifying it
5 #
6
7 --source include/have_innodb.inc
8 --let $rpl_topology=1->2->3->4
9 --source include/rpl_init.inc
10
11 # Set up a 4-deep replication topology, then test various fail-overs
12 # using GTID.
13 #
14 # A -> B -> C -> D
15
16 connection server_1;
17 --source include/wait_for_binlog_checkpoint.inc
18 --let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1)
19 --let $binlog_pos = query_get_value(SHOW MASTER STATUS,Position,1)
20 --echo *** GTID position should be empty here ***
21 --replace_result $binlog_file <BINLOG_FILE> $binlog_pos <BINLOG_POS>
22 eval SELECT BINLOG_GTID_POS('$binlog_file',$binlog_pos);
23
24 CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(10)) ENGINE=MyISAM;
25 CREATE TABLE t2 (a INT PRIMARY KEY, b VARCHAR(10)) ENGINE=InnoDB;
26 INSERT INTO t1 VALUES (1, "m1");
27 INSERT INTO t1 VALUES (2, "m2"), (3, "m3"), (4, "m4");
28 INSERT INTO t2 VALUES (1, "i1");
29 BEGIN;
30 INSERT INTO t2 VALUES (2, "i2"), (3, "i3");
31 INSERT INTO t2 VALUES (4, "i4");
32 COMMIT;
33 save_master_pos;
34 source include/wait_for_binlog_checkpoint.inc;
35 --let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1)
36 --let $binlog_pos = query_get_value(SHOW MASTER STATUS,Position,1)
37 --let $gtid_pos_server_1 = `SELECT @@gtid_binlog_pos`
38 --echo *** GTID position should be non-empty here ***
39 --replace_result $binlog_file <BINLOG_FILE> $binlog_pos <BINLOG_POS> $gtid_pos_server_1 <GTID_POS_SERVER_1>
40 eval SELECT BINLOG_GTID_POS('$binlog_file',$binlog_pos);
41
42 connection server_2;
43 sync_with_master;
44 source include/wait_for_binlog_checkpoint.inc;
45 --let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1)
46 --let $binlog_pos = query_get_value(SHOW MASTER STATUS,Position,1)
47 --echo *** GTID position should be the same as on server_1 ***
48 --replace_result $binlog_file <BINLOG_FILE> $binlog_pos <BINLOG_POS> $gtid_pos_server_1 <GTID_POS_SERVER_1>
49 eval SELECT BINLOG_GTID_POS('$binlog_file',$binlog_pos);
50 SELECT * FROM t1 ORDER BY a;
51 SELECT * FROM t2 ORDER BY a;
52 save_master_pos;
53
54 connection server_3;
55 sync_with_master;
56 SELECT * FROM t1 ORDER BY a;
57 SELECT * FROM t2 ORDER BY a;
58 save_master_pos;
59
60 connection server_4;
61 sync_with_master;
62 SELECT * FROM t1 ORDER BY a;
63 SELECT * FROM t2 ORDER BY a;
64
65
66 --echo *** Now take out D, let it fall behind a bit, and then test re-attaching it to A ***
67 connection server_4;
68 --source include/stop_slave.inc
69
70 connection server_1;
71 INSERT INTO t1 VALUES (5, "m1a");
72 INSERT INTO t2 VALUES (5, "i1a");
73 save_master_pos;
74
75 connection server_4;
76 --replace_result $MASTER_MYPORT MASTER_PORT
77 eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
78 MASTER_USE_GTID=CURRENT_POS;
79 --source include/start_slave.inc
80 sync_with_master;
81 SELECT * FROM t1 ORDER BY a;
82 SELECT * FROM t2 ORDER BY a;
83
84 --echo *** Now move B to D (C is still replicating from B) ***
85 connection server_2;
86 --source include/stop_slave.inc
87 --replace_result $SERVER_MYPORT_4 SERVER_MYPORT_4
88 eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_4,
89 MASTER_USE_GTID=CURRENT_POS;
90 --source include/start_slave.inc
91
92 connection server_4;
93 UPDATE t2 SET b="j1a" WHERE a=5;
94 save_master_pos;
95
96 connection server_2;
97 sync_with_master;
98 SELECT * FROM t1 ORDER BY a;
99 SELECT * FROM t2 ORDER BY a;
100
101 --echo *** Now move C to D, after letting it fall a little behind ***
102 connection server_3;
103 --source include/stop_slave.inc
104
105 connection server_1;
106 INSERT INTO t2 VALUES (6, "i6b");
107 INSERT INTO t2 VALUES (7, "i7b");
108 --source include/save_master_gtid.inc
109
110 connection server_3;
111 --replace_result $SERVER_MYPORT_4 SERVER_MYPORT_4
112 eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_4,
113 MASTER_USE_GTID=CURRENT_POS;
114 --source include/start_slave.inc
115 --source include/sync_with_master_gtid.inc
116 SELECT * FROM t2 ORDER BY a;
117
118 --echo *** Now change everything back to what it was, to make rpl_end.inc happy
119 # Also check that MASTER_USE_GTID=CURRENT_POS is still enabled.
120 connection server_2;
121 # We need to sync up server_2 before switching. If it happened to have reached
122 # the point 'UPDATE t2 SET b="j1a" WHERE a=5' it will fail to connect to
123 # server_1, which is (deliberately) missing that transaction.
124 --source include/sync_with_master_gtid.inc
125 --source include/stop_slave.inc
126 --replace_result $MASTER_MYPORT MASTER_MYPORT
127 eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT;
128 --source include/start_slave.inc
129 --source include/wait_for_slave_to_start.inc
130
131 connection server_3;
132 --source include/stop_slave.inc
133 --replace_result $SLAVE_MYPORT SLAVE_MYPORT
134 eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SLAVE_MYPORT;
135 --source include/start_slave.inc
136 --source include/sync_with_master_gtid.inc
137
138 connection server_4;
139 --source include/stop_slave.inc
140 --replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3
141 eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_3;
142 --source include/start_slave.inc
143
144 connection server_1;
145 DROP TABLE t1,t2;
146 --source include/save_master_gtid.inc
147
148 --echo *** A few more checks for BINLOG_GTID_POS function ***
149 --let $valid_binlog_name = query_get_value(SHOW BINARY LOGS,Log_name,1)
150 --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
151 SELECT BINLOG_GTID_POS();
152 --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
153 SELECT BINLOG_GTID_POS('a');
154 --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
155 SELECT BINLOG_GTID_POS('a',1,NULL);
156 SELECT BINLOG_GTID_POS(1,'a');
157 SELECT BINLOG_GTID_POS(NULL,NULL);
158 SELECT BINLOG_GTID_POS('',1);
159 SELECT BINLOG_GTID_POS('a',1);
160 eval SELECT BINLOG_GTID_POS('$valid_binlog_name',-1);
161 eval SELECT BINLOG_GTID_POS('$valid_binlog_name',0);
162 eval SELECT BINLOG_GTID_POS('$valid_binlog_name',18446744073709551615);
163 eval SELECT BINLOG_GTID_POS('$valid_binlog_name',18446744073709551616);
164
165 # MDEV-33045: Server crashes in Item_func_binlog_gtid_pos::val_str / Binary_string::c_ptr_safe
166 SET sql_log_bin= 0;
167 CREATE TABLE t1 AS SELECT MASTER_POS_WAIT(@binlog_file, 4, 0);
168 SELECT BINLOG_GTID_POS(@binlog_file, 4);
169 DROP TABLE t1;
170 SET sql_log_bin= 1;
171
172
173 --echo *** Some tests of @@GLOBAL.gtid_binlog_state ***
174 --connection server_2
175 --source include/sync_with_master_gtid.inc
176 --source include/stop_slave.inc
177
178 --connection server_1
179 SET @old_state= @@GLOBAL.gtid_binlog_state;
180
181 --error ER_BINLOG_MUST_BE_EMPTY
182 SET GLOBAL gtid_binlog_state = '';
183 RESET MASTER;
184 SET GLOBAL gtid_binlog_state = '';
185 FLUSH LOGS;
186 --source include/show_binary_logs.inc
187 SET GLOBAL gtid_binlog_state = '0-1-10,1-2-20,0-3-30';
188 --source include/show_binary_logs.inc
189 --let $binlog_file= master-bin.000001
190 --let $binlog_start= 4
191 --source include/show_binlog_events.inc
192 #SELECT @@GLOBAL.gtid_binlog_pos;
193 #SELECT @@GLOBAL.gtid_binlog_state;
194 --error ER_BINLOG_MUST_BE_EMPTY
195 SET GLOBAL gtid_binlog_state = @old_state;
196 RESET MASTER;
197 SET GLOBAL gtid_binlog_state = @old_state;
198
199 # Check that slave can reconnect again, despite the RESET MASTER, as we
200 # restored the state.
201
202 CREATE TABLE t1 (a INT PRIMARY KEY);
203 SET gtid_seq_no=100;
204 INSERT INTO t1 VALUES (1);
205 --source include/save_master_gtid.inc
206
207 --connection server_2
208 --source include/start_slave.inc
209 # We cannot just use sync_with_master as we've done RESET MASTER, so
210 # slave old-style position is wrong.
211 # So sync on gtid position instead.
212 --source include/sync_with_master_gtid.inc
213
214 SELECT * FROM t1;
215 # Check that the IO gtid position in SHOW SLAVE STATUS is also correct.
216 --let $status_items= Gtid_IO_Pos
217 --source include/show_slave_status.inc
218
219 --echo *** Test @@LAST_GTID and MASTER_GTID_WAIT() ***
220
221 --disable_ps2_protocol
222 --connection server_1
223 DROP TABLE t1;
224 CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
225 --save_master_pos
226
227 --connection server_2
228 --sync_with_master
229 --source include/stop_slave.inc
230
231 --connect (m1,127.0.0.1,root,,test,$SERVER_MYPORT_1,)
232 SELECT @@last_gtid;
233 SET gtid_seq_no=110;
234 SELECT @@last_gtid;
235 BEGIN;
236 SELECT @@last_gtid;
237 INSERT INTO t1 VALUES (2);
238 SELECT @@last_gtid;
239 COMMIT;
240 SELECT @@last_gtid;
241 --let $pos= `SELECT @@gtid_binlog_pos`
242
243 --connect (s1,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
244 eval SET @pos= '$pos';
245 # Check NULL argument.
246 SELECT master_gtid_wait(NULL);
247 # Check empty argument returns immediately.
248 SELECT master_gtid_wait('', NULL);
249 # Check this gets counted
250 SHOW STATUS LIKE 'Master_gtid_wait_count';
251 SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
252 SHOW STATUS LIKE 'Master_gtid_wait_time';
253 # Let's check that we get a timeout
254 SELECT master_gtid_wait(@pos, 0.5);
255 SELECT * FROM t1 ORDER BY a;
256 # Now actually wait until the slave reaches the position
257 send SELECT master_gtid_wait(@pos);
258
259 --connection server_2
260 --source include/start_slave.inc
261
262 --connection s1
263 reap;
264 SELECT * FROM t1 ORDER BY a;
265
266 # Test waiting on a domain that does not exist yet.
267 --source include/stop_slave.inc
268
269 --connection server_1
270 SET gtid_domain_id= 1;
271 INSERT INTO t1 VALUES (3);
272 --let $pos= `SELECT @@gtid_binlog_pos`
273
274 --connection s1
275 --replace_result $pos POS
276 eval SET @pos= '$pos';
277 SELECT master_gtid_wait(@pos, 0);
278 SELECT * FROM t1 WHERE a >= 3;
279 send SELECT master_gtid_wait(@pos, -1);
280
281 --connection server_2
282 --source include/start_slave.inc
283
284 --connection s1
285 reap;
286 SELECT * FROM t1 WHERE a >= 3;
287 # Waiting for only part of the position.
288 SELECT master_gtid_wait('1-1-1', 0);
289
290 # Now test a lot of parallel master_gtid_wait() calls, completing in different
291 # order, and some of which time out or get killed on the way.
292
293 --connection s1
294 send SELECT master_gtid_wait('2-1-1,1-1-4,0-1-110');
295
296 --connect (s2,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
297 # This will time out. No event 0-1-1000 exists
298 send SELECT master_gtid_wait('0-1-1000', 0.5);
299
300 --connect (s3,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
301 # This one we will kill
302 --let $kill1_id= `SELECT connection_id()`
303 send SELECT master_gtid_wait('0-1-2000');
304
305 --connect (s4,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
306 send SELECT master_gtid_wait('2-1-10');
307
308 --connect (s5,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
309 send SELECT master_gtid_wait('2-1-6', 1);
310
311 # This one we will kill also.
312 --connect (s6,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
313 --let $kill2_id= `SELECT connection_id()`
314 send SELECT master_gtid_wait('2-1-5');
315
316 --connect (s7,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
317 send SELECT master_gtid_wait('2-1-10');
318
319 --connect (s8,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
320 send SELECT master_gtid_wait('2-1-5,1-1-4,0-1-110');
321
322 --connect (s9,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
323 send SELECT master_gtid_wait('2-1-2');
324
325 --connection server_2
326 # This one completes immediately.
327 SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
328 SHOW STATUS LIKE 'Master_gtid_wait_count';
329 SELECT master_gtid_wait('1-1-1');
330 SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
331 SHOW STATUS LIKE 'Master_gtid_wait_count';
332 let $wait_time = query_get_value(SHOW STATUS LIKE 'Master_gtid_wait_time', Value, 1);
333 --replace_result $wait_time MASTER_GTID_WAIT_TIME
334 eval SET @a= $wait_time;
335 SELECT IF(@a <= 100*1000*1000, "OK", CONCAT("Error: wait time ", @a, " is larger than expected"))
336 AS Master_gtid_wait_time_as_expected;
337
338
339 --connect (s10,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
340 send SELECT master_gtid_wait('0-1-109');
341
342 --connection server_2
343 # This one should time out.
344 SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
345 SHOW STATUS LIKE 'Master_gtid_wait_count';
346 SELECT master_gtid_wait('2-1-2', 0.5);
347 SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
348 SHOW STATUS LIKE 'Master_gtid_wait_count';
349 let $wait_time = query_get_value(SHOW STATUS LIKE 'Master_gtid_wait_time', Value, 1);
350 --replace_result $wait_time MASTER_GTID_WAIT_TIME
351 eval SET @a= $wait_time;
352 # We expect a wait time of just a bit over 0.5 seconds. But thread scheduling
353 # and timer inaccuracies could introduce significant jitter. So allow a
354 # generous interval.
355 SELECT IF(@a BETWEEN 0.4*1000*1000 AND 100*1000*1000, "OK", CONCAT("Error: wait time ", @a, " not as expected")) AS Master_gtid_wait_time_as_expected;
356
357 --replace_result $kill1_id KILL_ID
358 eval KILL QUERY $kill1_id;
359 --connection s3
360 --error ER_QUERY_INTERRUPTED
361 reap;
362
363 --connection server_1
364 SET gtid_domain_id=2;
365 SET gtid_seq_no=2;
366 INSERT INTO t1 VALUES (4);
367
368 --connection s9
369 reap;
370
371 --connection server_2
372 --replace_result $kill2_id KILL_ID
373 eval KILL CONNECTION $kill2_id;
374
375 --connection s6
376 --error 2013,ER_CONNECTION_KILLED
377 reap;
378
379 --connection server_1
380 SET gtid_domain_id=1;
381 SET gtid_seq_no=4;
382 INSERT INTO t1 VALUES (5);
383 SET gtid_domain_id=2;
384 SET gtid_seq_no=5;
385 INSERT INTO t1 VALUES (6);
386
387 --connection s8
388 reap;
389 --connection s1
390 reap;
391 --connection s2
392 reap;
393 --connection s5
394 reap;
395 --connection s10
396 reap;
397
398 --connection server_1
399 SET gtid_domain_id=2;
400 SET gtid_seq_no=10;
401 INSERT INTO t1 VALUES (7);
402
403 --connection s4
404 reap;
405 --connection s7
406 reap;
407 --enable_ps2_protocol
408
409 --echo *** Test gtid_slave_pos when used with GTID ***
410
411 --connection server_2
412 --source include/stop_slave.inc
413
414 --connection server_1
415 SET gtid_domain_id=2;
416 SET gtid_seq_no=1000;
417 INSERT INTO t1 VALUES (10);
418 INSERT INTO t1 VALUES (11);
419 --save_master_pos
420
421 --connection server_2
422 SET sql_slave_skip_counter= 1;
423 --source include/start_slave.inc
424 --sync_with_master
425 SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
426 SELECT IF(LOCATE("2-1-1001", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1001 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
427
428 --source include/stop_slave.inc
429
430 --connection server_1
431 SET gtid_domain_id=2;
432 SET gtid_seq_no=1010;
433 INSERT INTO t1 VALUES (12);
434 INSERT INTO t1 VALUES (13);
435 --save_master_pos
436
437 --connection server_2
438 SET sql_slave_skip_counter= 2;
439 --source include/start_slave.inc
440 --sync_with_master
441 SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
442 SELECT IF(LOCATE("2-1-1011", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1011 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
443
444 --source include/stop_slave.inc
445
446 --connection server_1
447 SET gtid_domain_id=2;
448 SET gtid_seq_no=1020;
449 INSERT INTO t1 VALUES (14);
450 INSERT INTO t1 VALUES (15);
451 INSERT INTO t1 VALUES (16);
452 --save_master_pos
453
454 --connection server_2
455 SET sql_slave_skip_counter= 3;
456 --source include/start_slave.inc
457 --sync_with_master
458 SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
459 SELECT IF(LOCATE("2-1-1022", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1022 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
460
461 --source include/stop_slave.inc
462
463 --connection server_1
464 SET gtid_domain_id=2;
465 SET gtid_seq_no=1030;
466 # Disable logging Annotate_rows events to preserve events count.
467 let $binlog_annotate_row_events_saved= `SELECT @@binlog_annotate_row_events`;
468 SET @@binlog_annotate_row_events= 0;
469 INSERT INTO t1 VALUES (17);
470 INSERT INTO t1 VALUES (18);
471 INSERT INTO t1 VALUES (19);
472 eval SET @@binlog_annotate_row_events= $binlog_annotate_row_events_saved;
473 --save_master_pos
474
475 --connection server_2
476 SET sql_slave_skip_counter= 5;
477 --source include/start_slave.inc
478 --sync_with_master
479 SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
480 SELECT IF(LOCATE("2-1-1032", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1032 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
481
482
483 --source include/stop_slave.inc
484
485 --connection server_1
486 SET gtid_domain_id=3;
487 SET gtid_seq_no=100;
488 CREATE TABLE t2 (a INT PRIMARY KEY);
489 DROP TABLE t2;
490 SET gtid_domain_id=2;
491 SET gtid_seq_no=1040;
492 INSERT INTO t1 VALUES (20);
493 --save_master_pos
494
495 --connection server_2
496 SET @saved_mode= @@GLOBAL.slave_ddl_exec_mode;
497 SET GLOBAL slave_ddl_exec_mode=STRICT;
498 SET sql_slave_skip_counter=1;
499 START SLAVE UNTIL master_gtid_pos="3-1-100";
500 --let $master_pos=3-1-100
501 --source include/sync_with_master_gtid.inc
502 --source include/wait_for_slave_to_stop.inc
503 --error ER_NO_SUCH_TABLE
504 SELECT * FROM t2;
505 SELECT IF(LOCATE("3-1-100", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 3-1-100 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
506
507 # Start the slave again, it should fail on the DROP TABLE as the table is not there.
508 SET sql_log_bin=0;
509 CALL mtr.add_suppression("Slave: Unknown table 'test\\.t2' Error_code: 1051");
510 SET sql_log_bin=1;
511 START SLAVE;
512 --let $slave_sql_errno=1051
513 --source include/wait_for_slave_sql_error.inc
514 SELECT IF(LOCATE("3-1-100", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 3-1-100 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
515
516 STOP SLAVE IO_THREAD;
517 SET sql_slave_skip_counter=2;
518 --source include/start_slave.inc
519 --sync_with_master
520
521 SELECT * FROM t1 WHERE a >= 20 ORDER BY a;
522 SELECT IF(LOCATE("3-1-101", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 3-1-101 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
523 SELECT IF(LOCATE("2-1-1040", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1040 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
524
525 SET GLOBAL slave_ddl_exec_mode= @saved_mode;
526
527
528 --echo *** Test GTID-connecting to a master with out-of-order sequence numbers in the binlog. ***
529
530 # Create an out-of-order binlog on server 2.
531 # Let server 3 replicate to an out-of-order point, stop it, restart it,
532 # and check that it replicates correctly despite the out-of-order.
533
534 --connection server_1
535 SET gtid_domain_id= @@GLOBAL.gtid_domain_id;
536 INSERT INTO t1 VALUES (31);
537 --save_master_pos
538
539 --connection server_2
540 --sync_with_master
541 SET gtid_domain_id= @@GLOBAL.gtid_domain_id;
542 INSERT INTO t1 VALUES (32);
543
544 --connection server_1
545 INSERT INTO t1 VALUES (33);
546 --save_master_pos
547
548 --connection server_2
549 --sync_with_master
550 --save_master_pos
551
552 --connection server_3
553 --sync_with_master
554 --source include/stop_slave.inc
555
556 --connection server_1
557 INSERT INTO t1 VALUES (34);
558 --save_master_pos
559
560 --connection server_2
561 --sync_with_master
562 --save_master_pos
563
564 --connection server_3
565 --source include/start_slave.inc
566 --sync_with_master
567 SELECT * FROM t1 WHERE a >= 30 ORDER BY a;
568 --save_master_pos
569
570 --connection server_4
571 --sync_with_master
572 SELECT * FROM t1 WHERE a >= 30 ORDER BY a;
573
574
575 --echo *** MDEV-31723: Crash on SET SESSION gtid_seq_no= DEFAULT
576 --connection server_1
577
578 # Setting gtid_seq_no forces the GTID logged, but only once.
579 SET SESSION gtid_seq_no= 2000;
580 SELECT @@SESSION.gtid_seq_no;
581 INSERT INTO t1 VALUES (40);
582 SELECT @@SESSION.gtid_seq_no;
583 SELECT REGEXP_REPLACE(@@gtid_binlog_pos, ".*\\b(0-1-[0-9]+)\\b.*", "\\1") AS dom0_pos;
584 INSERT INTO t1 VALUES (41);
585 SELECT REGEXP_REPLACE(@@gtid_binlog_pos, ".*\\b(0-1-[0-9]+)\\b.*", "\\1") AS dom0_pos;
586
587 # Setting to 0 has no effect.
588 SET SESSION gtid_seq_no= 2010;
589 INSERT INTO t1 VALUES (42);
590 SELECT REGEXP_REPLACE(@@gtid_binlog_pos, ".*\\b(0-1-[0-9]+)\\b.*", "\\1") AS dom0_pos;
591 SET @old_strict= @@GLOBAL.gtid_strict_mode;
592 SET GLOBAL gtid_strict_mode= 1;
593 SET SESSION gtid_seq_no= 0;
594 INSERT INTO t1 VALUES (43);
595 SELECT REGEXP_REPLACE(@@gtid_binlog_pos, ".*\\b(0-1-[0-9]+)\\b.*", "\\1") AS dom0_pos;
596 SET GLOBAL gtid_strict_mode= @old_strict;
597 INSERT INTO t1 VALUES (44);
598 SELECT REGEXP_REPLACE(@@gtid_binlog_pos, ".*\\b(0-1-[0-9]+)\\b.*", "\\1") AS dom0_pos;
599
600 # Setting gtid_seq_no multiple times.
601 SET SESSION gtid_seq_no= 2020;
602 SET SESSION gtid_seq_no= 2030;
603 INSERT INTO t1 VALUES (45);
604 SELECT REGEXP_REPLACE(@@gtid_binlog_pos, ".*\\b(0-1-[0-9]+)\\b.*", "\\1") AS dom0_pos;
605
606 # Setting to DEFAULT or 0 disables prior setting.
607 SET SESSION gtid_seq_no= 2040;
608 SET SESSION gtid_seq_no= DEFAULT;
609 INSERT INTO t1 VALUES (46);
610 SELECT REGEXP_REPLACE(@@gtid_binlog_pos, ".*\\b(0-1-[0-9]+)\\b.*", "\\1") AS dom0_pos;
611 INSERT INTO t1 VALUES (47);
612 SELECT REGEXP_REPLACE(@@gtid_binlog_pos, ".*\\b(0-1-[0-9]+)\\b.*", "\\1") AS dom0_pos;
613 SET SESSION gtid_seq_no= 2050;
614 SET SESSION gtid_seq_no= 0;
615 INSERT INTO t1 VALUES (48);
616 SELECT REGEXP_REPLACE(@@gtid_binlog_pos, ".*\\b(0-1-[0-9]+)\\b.*", "\\1") AS dom0_pos;
617
618
619 # Clean up.
620 --connection server_1
621 DROP TABLE t1;
622
623
624 --source include/rpl_end.inc
625
626 --echo #
627 --echo # Start of 10.2 tests
628 --echo #
629
630 --echo #
631 --echo # MDEV-10134 Add full support for DEFAULT
632 --echo #
633
634 --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
635 CREATE TABLE t1 (a VARCHAR(100) DEFAULT BINLOG_GTID_POS("master-bin.000001", 600));
636
637 --echo #
638 --echo # End of 10.2 tests
639 --echo #
640
641
642 --echo #
643 --echo # Start of 10.3 tests
644 --echo #
645
646 --echo #
647 --echo # MDEV-13967 Parameter data type control for Item_long_func
648 --echo #
649
650 --error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
651 SELECT MASTER_GTID_WAIT(ROW(1,1),'str');
652
653 --error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
654 SELECT MASTER_GTID_WAIT('str',ROW(1,1));
655
656
657 --echo #
658 --echo # End of 10.3 tests
659 --echo #