1
################### include/rpl_stmt_seq.inc ###########################
3
# Check if a given SQL statement (->$my_stmt) / AUTOCOMMIT mode / #
4
# storage engine somehow involved causes COMMIT or ROLLBACK. #
7
# The typical test sequence #
8
# ------------------------- #
9
# 1. master connection: INSERT without commit #
10
# check table content of master and slave #
11
# 2. master connection: EXECUTE the statement #
12
# check table content of master and slave #
13
# 3. master connection: ROLLBACK #
14
# check table content of master and slave #
18
# $show_binlog -- print binlog entries #
19
# 0 - default + fits to the file with #
21
# 1 - useful for debugging #
22
# This variable is used within #
23
# include/rpl_stmt_seq.inc. #
24
# $manipulate -- Manipulation of the binary logs #
26
# 1 - so that the output of SHOW BINLOG #
27
# EVENTS IN <current log> contains only #
28
# commands of the current test sequence #
29
# This is especially useful, if the #
30
# $show_binlog is set to 1 and many #
31
# subtest are executed. #
32
# This variable is used within #
33
# include/rpl_stmt_seq.inc. #
34
# have to be set before sourcing this script. #
36
# Please be very careful when editing this routine, because the #
37
# handling of the $variables is extreme sensitive. #
39
########################################################################
42
# 2007-02-12 ML Replace comments via SQL by "--echo ..."
45
let $VERSION=`select version()`;
48
--echo ######## $my_stmt ########
51
###############################################################
52
# Predict the number of the current log
53
###############################################################
54
# Disable the logging of the log number computation.
56
# $_log_num_n should contain the number of the current binlog in numeric style.
57
# If this routine is called for the first time, $_log_num will not initialized
58
# and contain the value '' instead of '1'. So we will correct it here.
60
eval set @aux= IF('$_log_num_n' = '', '1', '$_log_num_n');
61
let $_log_num_n= `SELECT @aux`;
62
eval set @aux= LPAD('$_log_num_n',6,'0');
63
# SELECT @aux AS "@aux is";
65
# $_log_num_s should contain the number of the current binlog in string style.
66
let $_log_num_s= `select @aux`;
67
# eval SELECT '$log_num' ;
70
###############################################################
72
###############################################################
74
--echo -------- switch to master -------
76
# Maybe it would be smarter to use a table with an autoincrement column.
77
let $MAX= `SELECT MAX(f1) FROM t1` ;
78
eval INSERT INTO t1 SET f1= $MAX + 1;
79
# results before DDL(to be tested)
80
SELECT MAX(f1) FROM t1;
83
--replace_result $VERSION VERSION
84
--replace_column 2 # 5 #
85
eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s';
87
sync_slave_with_master;
90
--echo -------- switch to slave --------
92
# results before 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 'slave-bin.$_log_num_s';
101
###############################################################
102
# command to be tested
103
###############################################################
105
--echo -------- switch to master -------
108
# Devaluate $my_stmt, to detect script bugs
109
let $my_stmt= ERROR: YOU FORGOT TO FILL IN THE STATEMENT;
110
# results after DDL(to be tested)
111
SELECT MAX(f1) FROM t1;
114
--replace_result $VERSION VERSION
115
--replace_column 2 # 5 #
116
eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s';
118
sync_slave_with_master;
121
--echo -------- switch to slave --------
123
# results after DDL(to be tested)
124
SELECT MAX(f1) FROM t1;
127
--replace_result $VERSION VERSION
128
--replace_column 2 # 5 #
129
eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s';
132
###############################################################
134
###############################################################
136
--echo -------- switch to master -------
139
# results after final ROLLBACK
140
SELECT MAX(f1) FROM t1;
141
# Try to detect if the DDL command caused that the INSERT is committed
142
# $MAX holds the highest/last value just before the insert of MAX + 1
144
eval SELECT CONCAT(CONCAT('TEST-INFO: MASTER: The INSERT is ',
145
IF(MAX(f1) = $MAX + 1, 'committed', 'not committed')),
146
IF((MAX(f1) = $MAX + 1) XOR NOT $my_master_commit,
153
--replace_result $VERSION VERSION
154
--replace_column 2 # 5 #
155
eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s';
157
sync_slave_with_master;
160
--echo -------- switch to slave --------
162
# results after final ROLLBACK
163
SELECT MAX(f1) FROM t1;
165
eval SELECT CONCAT(CONCAT('TEST-INFO: SLAVE: The INSERT is ',
166
IF(MAX(f1) = $MAX + 1, 'committed', 'not committed')),
167
IF((MAX(f1) = $MAX + 1) XOR NOT $my_slave_commit,
174
--replace_result $VERSION VERSION
175
--replace_column 2 # 5 #
176
eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s';
179
###############################################################
181
###############################################################
184
#### Manipulate the binary logs,
185
# so that the output of SHOW BINLOG EVENTS IN <current log>
186
# contains only commands of the current test sequence.
187
# - flush the master and the slave log
188
# ---> both start to write into new logs with incremented number
189
# - increment $_log_num_n
191
--echo -------- switch to master -------
195
# eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s';
196
sync_slave_with_master;
199
--echo -------- switch to slave --------
201
# the final content of the binary log
203
# The next sleep is urgent needed.
204
# Without this sleep the slaves crashes often, when the SHOW BINLOG
207
# eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s';
212
--echo -------- switch to master -------