~mdcallag/+junk/5.1-map

« back to all changes in this revision

Viewing changes to mysql-test/include/rpl_stmt_seq2.inc

  • Committer: msvensson at pilot
  • Date: 2007-04-24 09:11:45 UTC
  • mfrom: (2469.1.106)
  • Revision ID: sp1r-msvensson@pilot.blaudden-20070424091145-10463
Merge pilot.blaudden:/home/msvensson/mysql/my51-m-mysql_upgrade
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.1-maint

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# include/rpl_stmt_seq.inc
2
 
#
3
 
# Please be very careful when editing this routine, because the handling of 
4
 
# the $variables is extreme sensitive. 
5
 
#
6
 
 
7
 
###############################################################
8
 
# Debug options : To debug this test script
9
 
###############################################################
10
 
let $show_binlog= 0;
11
 
let $manipulate= 1;
12
 
 
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
18
 
# 3. ROLLBACK
19
 
#    check table content of master and slave
20
 
# 4. flush the logs
21
 
 
22
 
let $VERSION=`select version()`;
23
 
 
24
 
--disable_query_log
25
 
# SELECT '######## new test sequence ########' as "";
26
 
eval SELECT CONCAT('######## ','$my_stmt',' $engine_type','  ########') as "";
27
 
--enable_query_log
28
 
 
29
 
 
30
 
###############################################################
31
 
# Predict the number of the current log
32
 
###############################################################
33
 
# Disable the logging of the log number computation. 
34
 
--disable_query_log
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.
38
 
#
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";
43
 
#
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' ;
47
 
--enable_query_log
48
 
 
49
 
###############################################################
50
 
# INSERT 
51
 
###############################################################
52
 
connection master;
53
 
--disable_query_log
54
 
SELECT '-------- switch to master -------' as "";
55
 
--enable_query_log
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;
61
 
if ($show_binlog)
62
 
{
63
 
--replace_result $VERSION VERSION
64
 
--replace_column 2 # 5 #
65
 
eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s';
66
 
}
67
 
sync_slave_with_master;
68
 
 
69
 
connection slave;
70
 
--disable_query_log
71
 
SELECT '-------- switch to slave --------' as "";
72
 
--enable_query_log
73
 
# results before DDL(to be tested)
74
 
SELECT MAX(f1) FROM t1;
75
 
if ($show_binlog)
76
 
{
77
 
--replace_result $VERSION VERSION
78
 
--replace_column 2 # 5 #
79
 
eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s';
80
 
}
81
 
 
82
 
###############################################################
83
 
# command to be tested
84
 
###############################################################
85
 
connection master;
86
 
--disable_query_log
87
 
SELECT '-------- switch to master -------' as "";
88
 
--enable_query_log
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;
94
 
if ($show_binlog)
95
 
{
96
 
--replace_result $VERSION VERSION
97
 
--replace_column 2 # 5 #
98
 
eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s';
99
 
}
100
 
sync_slave_with_master;
101
 
 
102
 
connection slave;
103
 
--disable_query_log
104
 
SELECT '-------- switch to slave --------' as "";
105
 
--enable_query_log
106
 
# results after DDL(to be tested)
107
 
SELECT MAX(f1) FROM t1;
108
 
if ($show_binlog)
109
 
{
110
 
--replace_result $VERSION VERSION
111
 
--replace_column 2 # 5 #
112
 
eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s';
113
 
}
114
 
 
115
 
###############################################################
116
 
# ROLLBACK
117
 
###############################################################
118
 
connection master;
119
 
--disable_query_log
120
 
SELECT '-------- switch to master -------' as "";
121
 
--enable_query_log
122
 
ROLLBACK;
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
127
 
--disable_query_log
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,
131
 
                ' (Succeeded)',
132
 
                ' (Failed)')) AS "" 
133
 
               FROM mysqltest1.t1;
134
 
--enable_query_log
135
 
if ($show_binlog)
136
 
{
137
 
--replace_result $VERSION VERSION
138
 
--replace_column 2 # 5 #
139
 
eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s';
140
 
}
141
 
sync_slave_with_master;
142
 
 
143
 
connection slave;
144
 
--disable_query_log
145
 
SELECT '-------- switch to slave --------' as "";
146
 
--enable_query_log
147
 
# results after final ROLLBACK
148
 
SELECT MAX(f1) FROM t1;
149
 
--disable_query_log
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,
153
 
                ' (Succeeded)',
154
 
                ' (Failed)')) AS "" 
155
 
               FROM mysqltest1.t1;
156
 
--enable_query_log
157
 
if ($show_binlog)
158
 
{
159
 
--replace_result $VERSION VERSION
160
 
--replace_column 2 # 5 #
161
 
eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s';
162
 
}
163
 
 
164
 
###############################################################
165
 
# Manipulate binlog
166
 
###############################################################
167
 
if ($manipulate)
168
 
{
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
175
 
connection master;
176
 
--disable_query_log
177
 
SELECT '-------- switch to master -------' as "";
178
 
--enable_query_log
179
 
flush logs;
180
 
# sleep 1;
181
 
# eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s';
182
 
sync_slave_with_master;
183
 
 
184
 
connection slave;
185
 
--disable_query_log
186
 
SELECT '-------- switch to slave --------' as "";
187
 
--enable_query_log
188
 
# the final content of the binary log
189
 
flush logs;
190
 
# The next sleep is urgent needed.
191
 
# Without this sleep the slaves crashes often, when the SHOW BINLOG
192
 
# is executed.   :-(
193
 
# sleep 1;
194
 
# eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s';
195
 
inc $_log_num_n;
196
 
}
197
 
 
198
 
connection master;
199
 
--disable_query_log
200
 
SELECT '-------- switch to master -------' as "";
201
 
--enable_query_log