| 1 |
# Requires statement logging |
| 2 |
|
| 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). |
| 12 |
sync_slave_with_master; |
| 13 |
source include/stop_slave.inc; |
| 14 |
--source include/wait_for_slave_to_stop.inc |
| 15 |
reset master; |
| 16 |
reset slave; |
| 17 |
start slave; |
| 18 |
--source include/wait_for_slave_to_start.inc |
| 19 |
|
| 20 |
let $VERSION=`select version()`; |
| 21 |
# Lets run this test in STRICT MODE (DROP TABLE is not DROP TABLE IF EXISTS) |
| 22 |
connection slave; |
| 23 |
set @save_slave_ddl_exec_mode=@@global.slave_ddl_exec_mode; |
| 24 |
set @@global.slave_ddl_exec_mode=STRICT; |
| 25 |
connection master; |
| 26 |
|
| 27 |
eval create table t1(n int not null auto_increment primary key)ENGINE=$engine_type; |
| 28 |
insert into t1 values (NULL); |
| 29 |
drop table t1; |
| 30 |
let $LOAD_FILE= ../../std_data/words.dat; |
| 31 |
if (!`SELECT length(load_file('$LOAD_FILE'))`){ |
| 32 |
let $LOAD_FILE= ../$LOAD_FILE; |
| 33 |
} |
| 34 |
eval create table t1 (word char(20) not null)ENGINE=$engine_type; |
| 35 |
--replace_result $LOAD_FILE LOAD_FILE |
| 36 |
eval load data infile '$LOAD_FILE' into table t1 ignore 1 lines; |
| 37 |
select count(*) from t1; |
| 38 |
source include/show_binlog_events.inc; |
| 39 |
|
| 40 |
let $binlog_limit= 2; |
| 41 |
source include/show_binlog_events.inc; |
| 42 |
|
| 43 |
let $binlog_limit= 3; |
| 44 |
source include/show_binlog_events.inc; |
| 45 |
|
| 46 |
let $binlog_limit= 2,5; |
| 47 |
source include/show_binlog_events.inc; |
| 48 |
let $binlog_limit=; |
| 49 |
flush logs; |
| 50 |
--source include/wait_for_binlog_checkpoint.inc |
| 51 |
|
| 52 |
# We need an extra update before doing save_master_pos. |
| 53 |
# Otherwise, an unlikely scenario may occur: |
| 54 |
# * When the master's binlog_dump thread reads the end of master-bin.001, |
| 55 |
# it send the rotate event which is at this end, plus a fake rotate event |
| 56 |
# because it's starting to read a new binlog. |
| 57 |
# save_master_pos will record the position of the first of the two rotate |
| 58 |
# (because the fake one is not in the master's binlog anyway). |
| 59 |
# * Later the slave waits for the position of the first rotate event, |
| 60 |
# and it may quickly stop (in 'slave stop') without having received the fake |
| 61 |
# one. |
| 62 |
# So, depending on a few milliseconds, we end up with 2 rotate events in the |
| 63 |
# relay log or one, which influences the output of SHOW SLAVE STATUS, making |
| 64 |
# it not predictable and causing random test failures. |
| 65 |
# To make it predictable, we do a useless update now, but which has the |
| 66 |
# interest of making the slave catch both rotate events. |
| 67 |
|
| 68 |
let $skip_checkpoint_events=1; |
| 69 |
|
| 70 |
eval create table t3 (a int)ENGINE=$engine_type; |
| 71 |
|
| 72 |
# Sync slave and force it to start on another binary log |
| 73 |
|
| 74 |
#show rows of t1 on master |
| 75 |
connection master; |
| 76 |
select * from t1 order by 1 asc; |
| 77 |
|
| 78 |
sync_slave_with_master; |
| 79 |
|
| 80 |
#check t1 on slave to ensure whether it's identical with on master |
| 81 |
select * from t1 order by 1 asc; |
| 82 |
flush logs; |
| 83 |
source include/stop_slave.inc; |
| 84 |
source include/start_slave.inc; |
| 85 |
connection master; |
| 86 |
|
| 87 |
# Create some entries for second log |
| 88 |
|
| 89 |
eval create table t2 (n int)ENGINE=$engine_type; |
| 90 |
insert into t2 values (1); |
| 91 |
source include/show_binlog_events.inc; |
| 92 |
|
| 93 |
let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1); |
| 94 |
source include/show_binlog_events.inc; |
| 95 |
|
| 96 |
--replace_column 2 # |
| 97 |
show binary logs; |
| 98 |
sync_slave_with_master; |
| 99 |
--replace_column 2 # |
| 100 |
show binary logs; |
| 101 |
|
| 102 |
let $binlog_file=; |
| 103 |
source include/show_binlog_events.inc; |
| 104 |
|
| 105 |
let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1); |
| 106 |
source include/show_binlog_events.inc; |
| 107 |
let $binlog_file=; |
| 108 |
|
| 109 |
source include/check_slave_is_running.inc; |
| 110 |
|
| 111 |
# Need to recode the following |
| 112 |
|
| 113 |
#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=4 and master_server_id=1; |
| 114 |
#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=79 and master_server_id=1; |
| 115 |
#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=311 and master_server_id=1; |
| 116 |
#show new master for slave with master_log_file='master-bin.000002' and master_log_pos=4 and master_server_id=1; |
| 117 |
#show new master for slave with master_log_file='master-bin.000002' and master_log_pos=122 and master_server_id=1; |
| 118 |
|
| 119 |
--error 1220 |
| 120 |
show binlog events in 'slave-bin.000005' from 4; |
| 121 |
|
| 122 |
connection master; |
| 123 |
|
| 124 |
# The table drops caused Cluster Replication wrapper to fail as event ID would never be the same.# Moving drops here. |
| 125 |
|
| 126 |
DROP TABLE t1; |
| 127 |
DROP TABLE t2; |
| 128 |
DROP TABLE t3; |
| 129 |
|
| 130 |
# |
| 131 |
# Bug #6880: LAST_INSERT_ID() within a statement |
| 132 |
# |
| 133 |
|
| 134 |
# Reset binlog so that show binlog events will not show the tests |
| 135 |
# above. |
| 136 |
source include/rpl_reset.inc; |
| 137 |
connection master; |
| 138 |
|
| 139 |
create table t1(a int auto_increment primary key, b int); |
| 140 |
insert into t1 values (NULL, 1); |
| 141 |
set insert_id=5; |
| 142 |
insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id()); |
| 143 |
source include/show_binlog_events.inc; |
| 144 |
select * from t1; |
| 145 |
drop table t1; |
| 146 |
|
| 147 |
# End of 4.1 tests |
| 148 |
|
| 149 |
sync_slave_with_master; |
| 150 |
set @@global.slave_ddl_exec_mode=@save_slave_ddl_exec_mode; |
| 151 |
connection master; |