1
# Test for the new options --start-datetime, stop-datetime,
4
# TODO: Need to look at making row based version once new binlog client is complete.
5
-- source include/have_binlog_format_mixed_or_statement.inc
9
drop table if exists t1;
13
# We need this for getting fixed timestamps inside of this test.
14
# I use a date in the future to keep a growing timestamp along the
15
# binlog (including the Start_log_event). This test will work
16
# unchanged everywhere, because mysql-test-run has fixed TZ, which it
17
# exports (so mysqlbinlog has same fixed TZ).
18
set @a=UNIX_TIMESTAMP("2020-01-21 15:32:22");
20
create table t1 (a int auto_increment not null primary key, b char(3));
21
insert into t1 values(null, "a");
22
insert into t1 values(null, "b");
24
insert into t1 values(null, "c");
26
insert into t1 values(null, "d");
27
insert into t1 values(null, "e");
30
set timestamp=@a+1; # this could happen on a slave
31
insert into t1 values(null, "f");
33
# delimiters are for easier debugging in future
36
select "--- Local --" as "";
40
# We should use --short-form everywhere because in other case output will
41
# be time dependent (the Start events). Better than nothing.
44
--exec $MYSQL_BINLOG --short-form --base64-output=never $MYSQLTEST_VARDIR/log/master-bin.000001
47
select "--- offset --" as "";
49
--exec $MYSQL_BINLOG --short-form --offset=2 $MYSQLTEST_VARDIR/log/master-bin.000001
51
select "--- start-position --" as "";
53
--exec $MYSQL_BINLOG --short-form --start-position=609 $MYSQLTEST_VARDIR/log/master-bin.000001
55
select "--- stop-position --" as "";
57
--exec $MYSQL_BINLOG --short-form --stop-position=609 $MYSQLTEST_VARDIR/log/master-bin.000001
59
select "--- start and stop positions ---" as "";
61
--exec $MYSQL_BINLOG --short-form --start-position=609 --stop-position 726 $MYSQLTEST_VARDIR/log/master-bin.000001
63
select "--- start-datetime --" as "";
65
--exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001
67
select "--- stop-datetime --" as "";
69
--exec $MYSQL_BINLOG --short-form "--stop-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001
72
select "--- Local with 2 binlogs on command line --" as "";
75
# This is to verify that some options apply only to first, or last binlog
78
--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002
81
select "--- offset --" as "";
83
--exec $MYSQL_BINLOG --short-form --offset=2 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002
85
select "--- start-position --" as "";
87
--exec $MYSQL_BINLOG --short-form --start-position=609 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002
89
select "--- stop-position --" as "";
91
--exec $MYSQL_BINLOG --short-form --stop-position=135 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002
93
select "--- start-datetime --" as "";
95
--exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002
97
select "--- stop-datetime --" as "";
99
--exec $MYSQL_BINLOG --short-form "--stop-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002
102
select "--- Remote --" as "";
105
--exec $MYSQL_BINLOG --short-form --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
108
select "--- offset --" as "";
110
--exec $MYSQL_BINLOG --short-form --offset=2 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
112
select "--- start-position --" as "";
114
--exec $MYSQL_BINLOG --short-form --start-position=609 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
116
select "--- stop-position --" as "";
118
--exec $MYSQL_BINLOG --short-form --stop-position=609 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
120
select "--- start and stop positions ---" as "";
122
--exec $MYSQL_BINLOG --short-form --start-position=609 --stop-position 726 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
124
select "--- start-datetime --" as "";
126
--exec $MYSQL_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
128
select "--- stop-datetime --" as "";
130
--exec $MYSQL_BINLOG --short-form "--stop-datetime=2020-01-21 15:32:24" --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
133
select "--- Remote with 2 binlogs on command line --" as "";
136
--exec $MYSQL_BINLOG --short-form --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
139
select "--- offset --" as "";
141
--exec $MYSQL_BINLOG --short-form --offset=2 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
143
select "--- start-position --" as "";
145
--exec $MYSQL_BINLOG --short-form --start-position=609 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
147
select "--- stop-position --" as "";
149
--exec $MYSQL_BINLOG --short-form --stop-position=135 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
151
select "--- start-datetime --" as "";
153
--exec $MYSQL_BINLOG --short-form "--start-datetime=20200121153224" --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
155
select "--- stop-datetime --" as "";
157
--exec $MYSQL_BINLOG --short-form "--stop-datetime=2020/01/21 15@32@24" --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
160
select "--- to-last-log --" as "";
163
--exec $MYSQL_BINLOG --short-form --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --to-last-log master-bin.000001
167
select "--- end of test --" as "";