1
# Requires statement logging
3
# Clean up old slave's binlogs.
4
# The slave is started with --log-slave-updates
5
# and this test does SHOW BINLOG EVENTS on the slave's
6
# binlog. But previous tests can influence the current test's
7
# binlog (e.g. a temporary table in the previous test has not
8
# been explicitly deleted, and at the beginning of the current
9
# test the slave immediately writes DROP TEMPORARY TABLE this_old_table).
10
# We wait for the slave to have written all he wants to the binlog
11
# (otherwise RESET MASTER may come too early).
18
# We are going to read the slave's binlog which contains file_id (for some LOAD
19
# DATA INFILE); to make it repeatable (not influenced by other tests), we need
20
# to stop and start the slave, to be sure file_id will start from 1.
21
# This can be done with 'server_stop slave', but
22
# this would require the manager, so most of the time the test will be skipped
24
# To workaround this, I (Guilhem) add a (empty) rpl_log-slave.opt (because when
25
# mysql-test-run finds such a file it restarts the slave before doing the
26
# test). That's not very elegant but I could find no better way, sorry.
28
let $VERSION=`select version()`;
32
eval create table t1(n int not null auto_increment primary key)ENGINE=$engine_type;
33
insert into t1 values (NULL);
35
eval create table t1 (word char(20) not null)ENGINE=$engine_type;
36
load data infile '../std_data_ln/words.dat' into table t1 ignore 1 lines;
37
select count(*) from t1;
38
--replace_result $VERSION VERSION
39
--replace_column 2 # 5 #
40
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
42
--replace_column 2 # 5 #
43
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
44
show binlog events from 107 limit 1;
45
--replace_column 2 # 5 #
46
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
47
show binlog events from 107 limit 2;
48
--replace_column 2 # 5 #
49
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
50
show binlog events from 107 limit 2,1;
53
# We need an extra update before doing save_master_pos.
54
# Otherwise, an unlikely scenario may occur:
55
# * When the master's binlog_dump thread reads the end of master-bin.001,
56
# it send the rotate event which is at this end, plus a fake rotate event
57
# because it's starting to read a new binlog.
58
# save_master_pos will record the position of the first of the two rotate
59
# (because the fake one is not in the master's binlog anyway).
60
# * Later the slave waits for the position of the first rotate event,
61
# and it may quickly stop (in 'slave stop') without having received the fake
63
# So, depending on a few milliseconds, we end up with 2 rotate events in the
64
# relay log or one, which influences the output of SHOW SLAVE STATUS, making
65
# it not predictable and causing random test failures.
66
# To make it predictable, we do a useless update now, but which has the
67
# interest of making the slave catch both rotate events.
69
eval create table t3 (a int)ENGINE=$engine_type;
71
# Sync slave and force it to start on another binary log
73
#show rows of t1 on master
75
select * from t1 order by 1 asc;
79
# Note that the above 'slave start' will cause a 3rd rotate event (a fake one)
80
# to go into the relay log (the master always sends a fake one when replication
83
let $result_pattern= '%127.0.0.1%root%master-bin.000002%slave-relay-bin.000005%Yes%Yes%0%0%None%';
84
--source include/wait_slave_status.inc
86
#check t1 on slave to ensure whether it's identical with on master
87
select * from t1 order by 1 asc;
92
# Create some entries for second log
94
eval create table t2 (n int)ENGINE=$engine_type;
95
insert into t2 values (1);
96
source include/show_binlog_events.inc;
97
--replace_result $VERSION VERSION
98
--replace_column 2 # 5 #
99
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
100
show binlog events in 'master-bin.000002';
107
--replace_result $MASTER_MYPORT MASTER_PORT $VERSION VERSION
108
--replace_column 2 # 5 #
109
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
110
show binlog events in 'slave-bin.000001' from 4;
111
--replace_result $MASTER_MYPORT MASTER_PORT $VERSION VERSION
112
--replace_column 2 # 5 #
113
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
114
show binlog events in 'slave-bin.000002' from 4;
115
source include/show_slave_status.inc;
117
# Need to recode the following
119
#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=4 and master_server_id=1;
120
#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=79 and master_server_id=1;
121
#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=311 and master_server_id=1;
122
#show new master for slave with master_log_file='master-bin.000002' and master_log_pos=4 and master_server_id=1;
123
#show new master for slave with master_log_file='master-bin.000002' and master_log_pos=122 and master_server_id=1;
126
show binlog events in 'slave-bin.000005' from 4;
130
# The table drops caused Cluster Replication wrapper to fail as event ID would never be the same.# Moving drops here.
137
# Bug #6880: LAST_INSERT_ID() within a statement
140
create table t1(a int auto_increment primary key, b int);
141
insert into t1 values (NULL, 1);
144
insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id());
145
source include/show_binlog_events.inc;
151
sync_slave_with_master;