1
# include/rpl_stmt_seq.inc
3
# Please be very careful when editing this routine, because the handling of
4
# the $variables is extreme sensitive.
7
###############################################################
8
# Debug options : To debug this test script
9
###############################################################
13
######## The typical test sequence
14
# 1. INSERT without commit
15
# check table content of master and slave
16
# 2. EXECUTE the statement
17
# check table content of master and slave
19
# check table content of master and slave
22
let $VERSION=`select version()`;
25
# SELECT '######## new test sequence ########' as "";
26
eval SELECT CONCAT('######## ','$my_stmt',' $engine_type',' ########') as "";
30
###############################################################
31
# Predict the number of the current log
32
###############################################################
33
# Disable the logging of the log number computation.
35
# $_log_num_n should contain the number of the current binlog in numeric style.
36
# If this routine is called for the first time, $_log_num will not initialized
37
# and contain the value '' instead of '1'. So we will correct it here.
39
eval set @aux= IF('$_log_num_n' = '', '1', '$_log_num_n');
40
let $_log_num_n= `SELECT @aux`;
41
eval set @aux= LPAD('$_log_num_n',6,'0');
42
# SELECT @aux AS "@aux is";
44
# $_log_num_s should contain the number of the current binlog in string style.
45
let $_log_num_s= `select @aux`;
46
# eval SELECT '$log_num' ;
49
###############################################################
51
###############################################################
54
SELECT '-------- switch to master -------' as "";
56
# Maybe it would be smarter to use a table with autoincrement column.
57
let $MAX= `SELECT MAX(f1) FROM t1` ;
58
eval INSERT INTO t1 SET f1= $MAX + 1;
59
# results before DDL(to be tested)
60
SELECT MAX(f1) FROM t1;
63
--replace_result $VERSION VERSION
64
--replace_column 2 # 5 #
65
eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s';
67
sync_slave_with_master;
71
SELECT '-------- switch to slave --------' as "";
73
# results before DDL(to be tested)
74
SELECT MAX(f1) FROM t1;
77
--replace_result $VERSION VERSION
78
--replace_column 2 # 5 #
79
eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s';
82
###############################################################
83
# command to be tested
84
###############################################################
87
SELECT '-------- switch to master -------' as "";
89
eval $my_stmt $engine_type;
90
# Devaluate $my_stmt, to detect script bugs
91
let $my_stmt= ERROR: YOU FORGOT TO FILL IN THE STATEMENT;
92
# results after DDL(to be tested)
93
SELECT MAX(f1) FROM t1;
96
--replace_result $VERSION VERSION
97
--replace_column 2 # 5 #
98
eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s';
100
sync_slave_with_master;
104
SELECT '-------- switch to slave --------' as "";
106
# results after DDL(to be tested)
107
SELECT MAX(f1) FROM t1;
110
--replace_result $VERSION VERSION
111
--replace_column 2 # 5 #
112
eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s';
115
###############################################################
117
###############################################################
120
SELECT '-------- switch to master -------' as "";
123
# results after final ROLLBACK
124
SELECT MAX(f1) FROM t1;
125
# Try to detect if the DDL command caused that the INSERT is committed
126
# $MAX holds the highest/last value just before the insert of MAX + 1
128
eval SELECT CONCAT(CONCAT('TEST-INFO: MASTER: The INSERT is ',
129
IF(MAX(f1) = $MAX + 1, 'committed', 'not committed')),
130
IF((MAX(f1) = $MAX + 1) XOR NOT $my_master_commit,
137
--replace_result $VERSION VERSION
138
--replace_column 2 # 5 #
139
eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s';
141
sync_slave_with_master;
145
SELECT '-------- switch to slave --------' as "";
147
# results after final ROLLBACK
148
SELECT MAX(f1) FROM t1;
150
eval SELECT CONCAT(CONCAT('TEST-INFO: SLAVE: The INSERT is ',
151
IF(MAX(f1) = $MAX + 1, 'committed', 'not committed')),
152
IF((MAX(f1) = $MAX + 1) XOR NOT $my_slave_commit,
159
--replace_result $VERSION VERSION
160
--replace_column 2 # 5 #
161
eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s';
164
###############################################################
166
###############################################################
169
#### Manipulate the binary logs,
170
# so that the output of SHOW BINLOG EVENTS IN <current log>
171
# contains only commands of the current test sequence.
172
# - flush the master and the slave log
173
# ---> both start to write into new logs with incremented number
174
# - increment $_log_num_n
177
SELECT '-------- switch to master -------' as "";
181
# eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s';
182
sync_slave_with_master;
186
SELECT '-------- switch to slave --------' as "";
188
# the final content of the binary log
190
# The next sleep is urgent needed.
191
# Without this sleep the slaves crashes often, when the SHOW BINLOG
194
# eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s';
200
SELECT '-------- switch to master -------' as "";