1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
# This test tests for Spider 3.0's bug fixes
source include/have_log_bin.inc;
--disable_warnings
--disable_query_log
--disable_result_log
--source test_init.inc
--source slave_test_init.inc
--enable_result_log
--enable_query_log
--echo
--echo drop and create databases
--connection master_1
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
if ($USE_REPLICATION)
{
--connection slave1_1
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
}
if ($USE_CHILD_GROUP2)
{
--connection child2_1
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
--connection child2_2
DROP DATABASE IF EXISTS auto_test_remote2;
CREATE DATABASE auto_test_remote2;
USE auto_test_remote2;
}
--enable_warnings
--echo
--echo test select 1
--connection master_1
SELECT 1;
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
SELECT 1;
--connection child2_2
SELECT 1;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--echo
--echo 3.1
--echo auto_increment
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
if ($OUTPUT_CHILD_GROUP2)
{
--disable_query_log
echo CHILD2_1_DROP_INCREMENT_TABLES1;
echo CHILD2_1_CREATE_INCREMENT_TABLES1;
echo CHILD2_1_AUTO_INCREMENT_INCREMENT2;
echo CHILD2_1_AUTO_INCREMENT_OFFSET2;
}
--disable_warnings
eval $CHILD2_1_DROP_INCREMENT_TABLES1;
--enable_warnings
eval $CHILD2_1_CREATE_INCREMENT_TABLES1;
eval $CHILD2_1_AUTO_INCREMENT_INCREMENT2;
eval $CHILD2_1_AUTO_INCREMENT_OFFSET2;
if ($OUTPUT_CHILD_GROUP2)
{
--enable_query_log
}
if ($USE_GENERAL_LOG)
{
TRUNCATE TABLE mysql.general_log;
}
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--connection master_1
SET @original_spider_auto_increment_mode = @@SESSION.spider_auto_increment_mode;
SET SESSION spider_auto_increment_mode = -1;
if ($USE_REPLICATION)
{
save_master_pos;
--connection slave1_1
sync_with_master;
--connection master_1
--disable_query_log
SET SESSION sql_log_bin= 0;
--enable_query_log
}
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings
--disable_query_log
echo CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1;
echo CREATE TABLE t2 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_INCREMENT1_1;
echo MASTER_1_AUTO_INCREMENT_INCREMENT2;
echo MASTER_1_AUTO_INCREMENT_OFFSET2;
eval CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1;
eval CREATE TABLE t2 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1;
--disable_ps_protocol
eval $MASTER_1_AUTO_INCREMENT_INCREMENT2;
eval $MASTER_1_AUTO_INCREMENT_OFFSET2;
--enable_ps_protocol
if ($USE_REPLICATION)
{
SET SESSION sql_log_bin= 1;
--connection slave1_1
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings
echo CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1;
echo CREATE TABLE t2 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) SLAVE1_1_ENGINE SLAVE1_1_CHARSET SLAVE1_1_COMMENT_INCREMENT1_1;
eval CREATE TABLE t1 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1;
eval CREATE TABLE t2 (
id int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
) $SLAVE1_1_ENGINE $SLAVE1_1_CHARSET $SLAVE1_1_COMMENT_INCREMENT1_1;
--connection master_1
}
--enable_query_log
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
SELECT MAX(id) FROM t1;
INSERT INTO t2 () VALUES ();
SELECT LAST_INSERT_ID();
SELECT MAX(id) FROM t2;
--disable_query_log
echo MASTER_1_AUTO_INCREMENT_OFFSET3;
eval $MASTER_1_AUTO_INCREMENT_OFFSET3;
--enable_query_log
INSERT INTO t1 (id) VALUES (null);
SELECT LAST_INSERT_ID();
SELECT MAX(id) FROM t1;
--disable_query_log
echo MASTER_1_AUTO_INCREMENT_OFFSET4;
eval $MASTER_1_AUTO_INCREMENT_OFFSET4;
--enable_query_log
INSERT INTO t2 (id) VALUES (null);
SELECT LAST_INSERT_ID();
SELECT MAX(id) FROM t2;
--disable_query_log
echo MASTER_1_AUTO_INCREMENT_OFFSET3;
eval $MASTER_1_AUTO_INCREMENT_OFFSET3;
--enable_query_log
INSERT INTO t1 () VALUES (),(),(),();
SELECT LAST_INSERT_ID();
SELECT id FROM t1 ORDER BY id;
--disable_query_log
echo MASTER_1_AUTO_INCREMENT_OFFSET4;
eval $MASTER_1_AUTO_INCREMENT_OFFSET4;
--enable_query_log
INSERT INTO t2 () VALUES (),(),(),();
SELECT LAST_INSERT_ID();
SELECT id FROM t2 ORDER BY id;
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
INSERT INTO t1 () VALUES (),(),(),();
SELECT LAST_INSERT_ID();
SELECT id FROM t1 ORDER BY id;
INSERT INTO t2 () VALUES (),(),(),();
SELECT LAST_INSERT_ID();
SELECT id FROM t2 ORDER BY id;
SET INSERT_ID=5000;
--disable_query_log
echo MASTER_1_AUTO_INCREMENT_OFFSET3;
eval $MASTER_1_AUTO_INCREMENT_OFFSET3;
--enable_query_log
INSERT INTO t1 () VALUES ();
SELECT LAST_INSERT_ID();
SELECT MAX(id) FROM t1;
--disable_query_log
echo MASTER_1_AUTO_INCREMENT_OFFSET4;
eval $MASTER_1_AUTO_INCREMENT_OFFSET4;
--enable_query_log
INSERT INTO t2 () VALUES ();
SELECT LAST_INSERT_ID();
SELECT MAX(id) FROM t2;
INSERT INTO t1 (id) VALUES (10000);
SELECT LAST_INSERT_ID();
SELECT MAX(id) FROM t1;
INSERT INTO t2 (id) VALUES (1000);
SELECT LAST_INSERT_ID();
SELECT MAX(id) FROM t2;
SET SESSION spider_auto_increment_mode = @original_spider_auto_increment_mode;
if ($USE_REPLICATION)
{
save_master_pos;
--connection slave1_1
sync_with_master;
SELECT id FROM t1 ORDER BY id;
--connection master_1
--disable_query_log
SET SESSION sql_log_bin= 0;
--enable_query_log
}
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
if ($USE_GENERAL_LOG)
{
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %';
}
eval $CHILD2_1_SELECT_INCREMENT_TABLES1;
if ($OUTPUT_CHILD_GROUP2)
{
--disable_query_log
echo CHILD2_1_AUTO_INCREMENT_INCREMENT1;
echo CHILD2_1_AUTO_INCREMENT_OFFSET1;
}
eval $CHILD2_1_AUTO_INCREMENT_INCREMENT1;
eval $CHILD2_1_AUTO_INCREMENT_OFFSET1;
if ($OUTPUT_CHILD_GROUP2)
{
--enable_query_log
}
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--echo
--echo deinit
--disable_warnings
--connection master_1
DROP DATABASE IF EXISTS auto_test_local;
if ($USE_REPLICATION)
{
--connection slave1_1
DROP DATABASE IF EXISTS auto_test_local;
}
if ($USE_CHILD_GROUP2)
{
--connection child2_1
DROP DATABASE IF EXISTS auto_test_remote;
--connection child2_2
DROP DATABASE IF EXISTS auto_test_remote2;
}
--disable_query_log
--disable_result_log
--source slave_test_deinit.inc
--source test_deinit.inc
--enable_result_log
--enable_query_log
--enable_warnings
--echo
--echo end of test
|