MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
binlog_mysqlbinlog_start_stop.inc
1 # ==== Purpose ====
2 #
3 # Test the --[start|stop]-[position|datetime] options to mysqlbinlog,
4 # with/without --read-from-remote-server, with one or two binary logs
5 # as input.
6 #
7 # ==== Implementation ====
8 
9 # TODO: Need to look at making row based version once new binlog client is complete.
10 
11 CREATE TABLE t1 (a INT);
12 RESET MASTER;
13 
14 # We need to set fixed timestamps in this test.
15 # Use a date in the future to keep a growing timestamp along the
16 # binlog (including the Start_log_event). This test will work
17 # unchanged everywhere, because mysql-test-run has fixed TZ, which it
18 # exports (so mysqlbinlog has same fixed TZ).
19 --let $datetime_1= 2031-01-01 12:00:00
20 eval SET TIMESTAMP= UNIX_TIMESTAMP("$datetime_1");
21 INSERT INTO t1 VALUES(1);
22 --let $pos_1= query_get_value(SHOW MASTER STATUS, Position, 1)
23 
24 --let $datetime_2= 2032-01-01 12:00:00
25 eval SET TIMESTAMP= UNIX_TIMESTAMP("$datetime_2");
26 INSERT INTO t1 VALUES(2);
27 --let $pos_2= query_get_value(SHOW MASTER STATUS, Position, 1)
28 
29 eval SET TIMESTAMP= UNIX_TIMESTAMP("2033-01-01 12:00:00");
30 INSERT INTO t1 VALUES(3);
31 
32 --let $file_1= query_get_value(SHOW MASTER STATUS, File, 1)
33 FLUSH LOGS;
34 
35 SET TIMESTAMP= UNIX_TIMESTAMP("2034-01-01 12:00:00");
36 INSERT INTO t1 VALUES(4);
37 --let $pos_3= query_get_value(SHOW MASTER STATUS, Position, 1)
38 --let $datetime_3= 2035-01-01 12:00:00
39 eval SET TIMESTAMP= UNIX_TIMESTAMP("$datetime_3");
40 INSERT INTO t1 VALUES(5);
41 
42 --let $file_2= query_get_value(SHOW MASTER STATUS, File, 1)
43 FLUSH LOGS;
44 
45 --let $MYSQLD_DATADIR= `select @@datadir`
46 
47 --echo
48 --echo ==== Local ====
49 
50 --let $start_position= $pos_1
51 --let $start_datetime= $datetime_1
52 
53 --let $stop_position= $pos_2
54 --let $stop_datetime= $datetime_2
55 --let $extra_options= $MYSQLD_DATADIR/$file_1
56 --source extra/binlog_tests/mysqlbinlog_start_stop_1.inc
57 
58 --echo
59 --echo ==== Local with 2 binlogs on command line ====
60 # This is to verify that some options apply only to first, or last binlog
61 
62 --let $stop_position= $pos_3
63 --let $stop_datetime= $datetime_3
64 --let $extra_options= $MYSQLD_DATADIR/$file_1 $MYSQLD_DATADIR/$file_2
65 --source extra/binlog_tests/mysqlbinlog_start_stop_1.inc
66 
67 --echo
68 --echo ==== Remote ====
69 
70 --let $stop_position= $pos_2
71 --let $stop_datetime= $datetime_2
72 --let $extra_options= --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $file_1
73 --source extra/binlog_tests/mysqlbinlog_start_stop_1.inc
74 
75 --echo
76 --echo ==== Remote with 2 binlogs on command line ====
77 
78 --let $stop_position= $pos_3
79 --let $stop_datetime= $datetime_3
80 --let $extra_options= --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $file_1 $file_2
81 --source extra/binlog_tests/mysqlbinlog_start_stop_1.inc
82 
83 # ==== to-last-log ====
84 
85 --let $extra_options= --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT $file_1
86 --let $option= --to-last-log
87 --source extra/binlog_tests/mysqlbinlog_start_stop_2.inc
88 
89 --echo
90 --echo ==== clean up ====
91 DROP TABLE t1;