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.
8
drop table if exists t1;
12
# We need this for getting fixed timestamps inside of this test.
13
# I use a date in the future to keep a growing timestamp along the
14
# binlog (including the Start_log_event). This test will work
15
# unchanged everywhere, because mysql-test-run has fixed TZ, which it
16
# exports (so mysqlbinlog has same fixed TZ).
17
set @a=UNIX_TIMESTAMP("2020-01-21 15:32:22");
19
create table t1 (a int auto_increment not null primary key, b char(3));
20
insert into t1 values(null, "a");
21
insert into t1 values(null, "b");
23
insert into t1 values(null, "c");
25
insert into t1 values(null, "d");
26
insert into t1 values(null, "e");
29
set timestamp=@a+1; # this could happen on a slave
30
insert into t1 values(null, "f");
32
# delimiters are for easier debugging in future
35
select "--- Local --" as "";
39
# We should use --short-form everywhere because in other case output will
40
# be time dependent (the Start events). Better than nothing.
43
--exec $DRIZZLE_BINLOG --short-form --base64-output=never $MYSQLTEST_VARDIR/log/master-bin.000001
46
select "--- offset --" as "";
48
--exec $DRIZZLE_BINLOG --short-form --offset=2 $MYSQLTEST_VARDIR/log/master-bin.000001
50
select "--- start-position --" as "";
52
--exec $DRIZZLE_BINLOG --short-form --start-position=609 $MYSQLTEST_VARDIR/log/master-bin.000001
54
select "--- stop-position --" as "";
56
--exec $DRIZZLE_BINLOG --short-form --stop-position=609 $MYSQLTEST_VARDIR/log/master-bin.000001
58
select "--- start and stop positions ---" as "";
60
--exec $DRIZZLE_BINLOG --short-form --start-position=609 --stop-position 726 $MYSQLTEST_VARDIR/log/master-bin.000001
62
select "--- start-datetime --" as "";
64
--exec $DRIZZLE_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001
66
select "--- stop-datetime --" as "";
68
--exec $DRIZZLE_BINLOG --short-form "--stop-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001
71
select "--- Local with 2 binlogs on command line --" as "";
74
# This is to verify that some options apply only to first, or last binlog
77
--exec $DRIZZLE_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002
80
select "--- offset --" as "";
82
--exec $DRIZZLE_BINLOG --short-form --offset=2 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002
84
select "--- start-position --" as "";
86
--exec $DRIZZLE_BINLOG --short-form --start-position=609 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002
88
select "--- stop-position --" as "";
90
--exec $DRIZZLE_BINLOG --short-form --stop-position=135 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002
92
select "--- start-datetime --" as "";
94
--exec $DRIZZLE_BINLOG --short-form "--start-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002
96
select "--- stop-datetime --" as "";
98
--exec $DRIZZLE_BINLOG --short-form "--stop-datetime=2020-01-21 15:32:24" $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002
101
select "--- Remote --" as "";
104
--exec $DRIZZLE_BINLOG --short-form --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
107
select "--- offset --" as "";
109
--exec $DRIZZLE_BINLOG --short-form --offset=2 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
111
select "--- start-position --" as "";
113
--exec $DRIZZLE_BINLOG --short-form --start-position=609 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
115
select "--- stop-position --" as "";
117
--exec $DRIZZLE_BINLOG --short-form --stop-position=609 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
119
select "--- start and stop positions ---" as "";
121
--exec $DRIZZLE_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
123
select "--- start-datetime --" as "";
125
--exec $DRIZZLE_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
127
select "--- stop-datetime --" as "";
129
--exec $DRIZZLE_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
132
select "--- Remote with 2 binlogs on command line --" as "";
135
--exec $DRIZZLE_BINLOG --short-form --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
138
select "--- offset --" as "";
140
--exec $DRIZZLE_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
142
select "--- start-position --" as "";
144
--exec $DRIZZLE_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
146
select "--- stop-position --" as "";
148
--exec $DRIZZLE_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
150
select "--- start-datetime --" as "";
152
--exec $DRIZZLE_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
154
select "--- stop-datetime --" as "";
156
--exec $DRIZZLE_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
159
select "--- to-last-log --" as "";
162
--exec $DRIZZLE_BINLOG --short-form --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --to-last-log master-bin.000001
166
select "--- end of test --" as "";