Debian Codegraph @

mysql-test/suite/binlog/t/binlog_mysqlbinlog_warn_stop_datetime.inc

raw
1 #
2 # Helper file that ensures mysqlbinlog --stop-datetime behavior for local
3 # files or a remote server
4 #
5 # Parameters:
6 # read_from_remote_server (bool): A boolean that changes which source to use
7 # for mysqlbinlog. When true, reads remotely; when false, uses local files.
8 #
9
10 --connection default
11 --let $MYSQLD_DATADIR= `select @@datadir`
12
13 # PARAM_READ_FROM_REMOTE is used as a parameter to mysqlbinlog (_OUT suffix is
14 # output in echo commands). If using local files, they are blank; if reading
15 # from remote server, it is overridden to the correct values.
16 --let $PARAM_READ_FROM_REMOTE=
17 # Used in echo statements to remove potentially changing values
18 --let $PARAM_READ_FROM_REMOTE_OUT=
19
20 if ($read_from_remote_server)
21 {
22 --let $PARAM_READ_FROM_REMOTE= --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT
23 --let $PARAM_READ_FROM_REMOTE_OUT= --read-from-remote-server
24 # binlog files in --read-from-remote-server don't use file system path
25 --let $binlog_f1_full= $binlog_f1
26 --let $binlog_f2_full= $binlog_f2
27 }
28 if (!$read_from_remote_server)
29 {
30 # If using local files, file system path to the binlog files is needed
31 --let $binlog_f1_full= $MYSQLD_DATADIR/$binlog_f1
32 --let $binlog_f2_full= $MYSQLD_DATADIR/$binlog_f2
33 }
34
35 --echo #
36 --echo # --stop-datetime tests
37 --echo # Note: MDEV-35528 reported that mysqlbinlog would fail on tests cases
38 --echo # 2.a, 2.b, and 2.c.
39 --echo #
40
41 --echo # Case 1.a) With one binlog file, a --stop-datetime before the end of
42 --echo # the file should not result in a warning
43 --echo # MYSQL_BINLOG $PARAM_READ_FROM_REMOTE_OUT --stop-datetime='$b1_timestamp2' binlog_f1_full --result-file=$binlog_out_relpath 2>&1
44 --exec $MYSQL_BINLOG $PARAM_READ_FROM_REMOTE --stop-datetime='$b1_timestamp2' $binlog_f1_full --result-file=$binlog_out 2>&1
45
46 --echo #
47 --echo # Case 1.b) With one binlog file, a --stop-datetime at the end of the
48 --echo # file should not result in a warning
49 --echo # MYSQL_BINLOG $PARAM_READ_FROM_REMOTE_OUT --stop-datetime='$b1_timestamp3' binlog_f1_full --result-file=$binlog_out_relpath 2>&1
50 --exec $MYSQL_BINLOG $PARAM_READ_FROM_REMOTE --stop-datetime='$b1_timestamp3' $binlog_f1_full --result-file=$binlog_out 2>&1
51
52 --echo #
53 --echo # Case 1.c) With one binlog file, a --stop-datetime beyond the end of
54 --echo # the file should(!) result in a warning
55 --let $future_timestamp= 2035-12-06 10:20:30.123456
56 --echo # MYSQL_BINLOG $PARAM_READ_FROM_REMOTE_OUT --stop-datetime='$b2_timestamp1' binlog_f1_full --result-file=$binlog_out_relpath 2>&1
57 --exec $MYSQL_BINLOG $PARAM_READ_FROM_REMOTE --stop-datetime='$b2_timestamp1' $binlog_f1_full --result-file=$binlog_out 2>&1
58
59 --echo #
60 --echo # Case 2.a) With two binlog files, a --stop-datetime within the
61 --echo # timespan of binlog 2 should:
62 --echo # 1) not provide any warnings
63 --echo # 2) not prevent binlog 1 or 2 from outputting the desired events
64
65 --echo # MYSQL_BINLOG $PARAM_READ_FROM_REMOTE_OUT --stop-datetime='$b2_timestamp1' binlog_f1_full binlog_f2_full --result-file=$binlog_out_relpath 2>&1
66 --exec $MYSQL_BINLOG $PARAM_READ_FROM_REMOTE --stop-datetime='$b2_timestamp1' $binlog_f1_full $binlog_f2_full --result-file=$binlog_out 2>&1
67
68 --let $server_id= `SELECT @@GLOBAL.server_id`
69 --let $domain_id= `SELECT @@GLOBAL.gtid_domain_id`
70 --let $assert_file= $binlog_out
71 --let $assert_text= Ensure all intended GTIDs are present
72 --let $assert_select= GTID $domain_id-$server_id-
73 --let $assert_count= 3
74 --source include/assert_grep.inc
75
76 --let $assert_text= Ensure the next GTID binlogged is _not_ present
77 --let $assert_select= GTID $binlog_f2_gtid_after_midpoint
78 --let $assert_count= 0
79 --source include/assert_grep.inc
80
81 --echo #
82 --echo # Case 2.b) With two binlog files, a --stop-datetime at the end of
83 --echo # binlog 2 should:
84 --echo # 1) not provide any warnings
85 --echo # 2) not prevent binlog 1 or 2 from outputting all events
86 --echo # MYSQL_BINLOG $PARAM_READ_FROM_REMOTE_OUT --stop-datetime='$b2_timestamp3' binlog_f1_full binlog_f2_full --result-file=$binlog_out_relpath 2>&1
87 --exec $MYSQL_BINLOG $PARAM_READ_FROM_REMOTE --stop-datetime='$b2_timestamp3' $binlog_f1_full $binlog_f2_full --result-file=$binlog_out 2>&1
88
89 --let $assert_text= Ensure a GTID exists for each transaction
90 --let $assert_select= GTID $domain_id-$server_id-
91 --let $assert_count= 8
92 --source include/assert_grep.inc
93
94 --echo #
95 --echo # Case 2.c) With two binlog files, a --stop-datetime beyond the end of
96 --echo # binlog 2 should:
97 --echo # 1) provide a warning that the stop datetime was not reached
98 --echo # 2) not prevent binlog 1 or 2 from outputting all events
99 --echo # MYSQL_BINLOG $PARAM_READ_FROM_REMOTE_OUT --stop-datetime='$b2_timestamp_not_reached' binlog_f1_full binlog_f2_full --result-file=$binlog_out_relpath 2>&1
100 --exec $MYSQL_BINLOG $PARAM_READ_FROM_REMOTE --stop-datetime='$b2_timestamp_not_reached' $binlog_f1_full $binlog_f2_full --result-file=$binlog_out 2>&1
101
102 --let $assert_text= Ensure a GTID exists for each transaction
103 --let $assert_select= GTID $domain_id-$server_id-
104 --let $assert_count= 8
105 --source include/assert_grep.inc
106