Debian Codegraph @

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

raw
1 #
2 # Helper file that ensures mysqlbinlog --stop-position 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-position tests
37 --echo #
38
39 --echo # Case 1.a) With one binlog file, a --stop-position before the end of
40 --echo # the file should not result in a warning
41 --echo # MYSQL_BINLOG $PARAM_READ_FROM_REMOTE_OUT --stop-position=binlog_f1_pre_rotate binlog_f1_full --result-file=$binlog_out_relpath 2>&1
42 --exec $MYSQL_BINLOG $PARAM_READ_FROM_REMOTE --stop-position=$binlog_f1_pre_rotate $binlog_f1_full --result-file=$binlog_out 2>&1
43
44 --echo #
45 --echo # Case 1.b) With one binlog file, a --stop-position at the exact end of
46 --echo # the file should not result in a warning
47 --echo # MYSQL_BINLOG $PARAM_READ_FROM_REMOTE_OUT --stop-position=binlog_f1_end binlog_f1_full --result-file=$binlog_out_relpath 2>&1
48 --exec $MYSQL_BINLOG $PARAM_READ_FROM_REMOTE --stop-position=$binlog_f1_end $binlog_f1_full --result-file=$binlog_out 2>&1
49
50 --echo #
51 --echo # Case 1.c) With one binlog file, a --stop-position past the end of the
52 --echo # file should(!) result in a warning
53 --echo # MYSQL_BINLOG $PARAM_READ_FROM_REMOTE_OUT --short-form --stop-position=binlog_f1_over_eof binlog_f1_full --result-file=$binlog_out_relpath 2>&1
54 --replace_result $binlog_f1_over_eof <BINLOG_F1_OVER_EOF>
55 --sorted_result
56 --exec $MYSQL_BINLOG $PARAM_READ_FROM_REMOTE --short-form --stop-position=$binlog_f1_over_eof $binlog_f1_full --result-file=$binlog_out 2>&1
57
58 --echo #
59 --echo # Case 2.a) With two binlog files, a --stop-position targeting b2 which
60 --echo # exists in the size of b1 should:
61 --echo # 1) not provide any warnings
62 --echo # 2) not prevent b2 from outputting its desired events before the
63 --echo # stop position
64 --echo # MYSQL_BINLOG $PARAM_READ_FROM_REMOTE_OUT --stop-position=binlog_f2_mid binlog_f1_full binlog_f2_full --result-file=$binlog_out_relpath 2>&1
65 --exec $MYSQL_BINLOG $PARAM_READ_FROM_REMOTE --stop-position=$binlog_f2_mid $binlog_f1_full $binlog_f2_full --result-file=$binlog_out 2>&1
66
67 --let $server_id= `SELECT @@GLOBAL.server_id`
68 --let $assert_file= $binlog_out
69 --let $assert_text= Ensure all intended GTIDs are present
70 --let $assert_select= GTID $domain_id-$server_id-
71 --let $assert_count= 4
72 --source include/assert_grep.inc
73
74 --let $assert_text= Ensure the next GTID binlogged is _not_ present
75 --let $assert_select= GTID $binlog_f2_gtid_after_midpoint
76 --let $assert_count= 0
77 --source include/assert_grep.inc
78
79 --echo #
80 --echo # Case 2.b) With two binlog files, a --stop-position targeting the end
81 --echo # of binlog 2 should:
82 --echo # 1) not provide any warnings
83 --echo # 2) not prevent b2 from outputting its entire binary log
84 --echo # MYSQL_BINLOG $PARAM_READ_FROM_REMOTE_OUT --stop-position=binlog_f2_end binlog_f1_full binlog_f2_full --result-file=$binlog_out_relpath 2>&1
85 --exec $MYSQL_BINLOG $PARAM_READ_FROM_REMOTE --stop-position=$binlog_f2_end $binlog_f1_full $binlog_f2_full --result-file=$binlog_out 2>&1
86
87 --let $server_id= `SELECT @@GLOBAL.server_id`
88 --let $assert_text= Ensure a GTID exists for each transaction
89 --let $assert_select= GTID $domain_id-$server_id-
90 --let $assert_count= 8
91 --source include/assert_grep.inc
92
93 --let $assert_text= Ensure the last GTID binlogged is present
94 --let $assert_select= GTID $binlog_f2_last_gtid
95 --let $assert_count= 1
96 --source include/assert_grep.inc
97
98 --echo #
99 --echo # Case 2.c) With two binlog files, a --stop-position targeting beyond
100 --echo # the eof of binlog 2 should:
101 --echo # 1) provide a warning that the stop position was not reached
102 --echo # 2) not prevent b2 from outputting its entire binary log
103 --echo # MYSQL_BINLOG $PARAM_READ_FROM_REMOTE_OUT --stop-position=binlog_f2_over_eof binlog_f1_full binlog_f2_full --result-file=$binlog_out_relpath 2>&1
104 --replace_result $binlog_f2_over_eof <BINLOG_F2_OVER_EOF>
105 --sorted_result
106 --exec $MYSQL_BINLOG $PARAM_READ_FROM_REMOTE --stop-position=$binlog_f2_over_eof $binlog_f1_full $binlog_f2_full --result-file=$binlog_out 2>&1
107
108 --let $server_id= `SELECT @@GLOBAL.server_id`
109 --let $assert_text= Ensure a GTID exists for each transaction
110 --let $assert_select= GTID $domain_id-$server_id-
111 --let $assert_count= 8
112 --source include/assert_grep.inc