summaryrefslogtreecommitdiff
path: root/mysql-test/suite/innodb_zip/t/wl6501_1.test
blob: dd8b5f65b31ee169fdbd15fd6a4cb31a17dba71f (plain)
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451

####################################################################
# TC to check truncate table statement atomicity for single        #
# tablespace                                                       #
# Sceanrio covered:                                                #
# 1. Debug points added for worklog                                #
# 2. Table with  differnt row types                                #
# 3. Transactional statement.                                      #
####################################################################


--source include/have_innodb.inc
--source include/have_debug.inc
--source include/big_test.inc
--source include/have_innodb_16k.inc

# Valgrind would result in a "long semaphore wait" inside InnoDB
--source include/not_valgrind.inc
# Embedded server does not support crashing
--source include/not_embedded.inc
# Avoid CrashReporter popup on Mac
--source include/not_crashrep.inc

#-----------------------------------------------------------------------
--disable_query_log
let $MYSQL_DATA_DIR= `select @@datadir`;
let $data_directory = data directory='$MYSQL_TMP_DIR/alt_dir';
let $innodb_file_per_table_orig=`select @@innodb_file_per_table`;

call mtr.add_suppression("InnoDB.*table did not exist in the InnoDB data dictionary.*");
call mtr.add_suppression("InnoDB: A page in the doublewrite buffer is not within space bounds.*");
call mtr.add_suppression("InnoDB: Cannot create file.*");
call mtr.add_suppression("InnoDB: Error number 17 means 'File exists'.*");
call mtr.add_suppression("InnoDB: A page in the doublewrite buffer is not within space bounds");
call mtr.add_suppression("InnoDB: Error: table .* does not exist in the InnoDB internal");
--enable_query_log

#-----------------------------------------------------------------------
set global innodb_file_per_table=on;
--echo # Verify that 'TRUNCATE TABLE' statement works fine and the size
--echo # of .ibd file is equal to the initial size after truncation.

#-----------------------------------------------------------------------
drop table if exists t1,t2,t3,t4,t6;
let $cnt = 6;
while ($cnt) {

	# table with basic data type + primary ,secondary,composite,prefix index
	create table t1(c1 int not null,
			c2 int not null,
			c3 char(255) not null,
			c4 text(500) not null,
			c5 blob(500) not null,
			c6 varchar(500) not null,
			c7 varchar(500) not null,
			c8 datetime,
			c9 decimal(5,3),
			primary key (c1),
			index (c3,c4(50),c5(50)),
			index (c2))
		engine=innodb row_format=redundant;


	create table t2(c1 int not null,
			c2 int not null,
			c3 char(255) not null,
			c4 text(500) not null,
			c5 blob(500) not null,
			c6 varchar(500) not null,
			c7 varchar(500) not null,
			c8 datetime,
			c9 decimal(5,3),
			primary key (c1),
			index (c3,c4(50),c5(50)),
			index (c2))
		engine=innodb row_format=compact;


	# with row type , key block size = 4K
	create table t3(c1 int not null,
			c2 int not null,
			c3 char(255) not null,
			c4 text(500) not null,
			c5 blob(500) not null,
			c6 varchar(500) not null,
			c7 varchar(500) not null,
			c8 datetime,
			c9 decimal(5,3),
			primary key (c1),
			index (c3,c4(50),c5(50)),
			index (c2))
		engine=innodb row_format=compressed key_block_size=4;


	create table t4(c1 int not null,
			c2 int not null,
			c3 char(255) not null,
			c4 text(500) not null,
			c5 blob(500) not null,
			c6 varchar(500) not null,
			c7 varchar(500) not null,
			c8 datetime,
			c9 decimal(5,3),
			primary key (c1),
			index (c3,c4(50),c5(50)),
			index (c2))
		engine=innodb row_format=dynamic;


	create temporary table t5(c1 int not null,
				  c2 int not null,
				  c3 char(255) not null,
				  c4 text(500) not null,
				  c5 blob(500) not null,
				  c6 varchar(500) not null,
				  c7 varchar(500) not null,
				  c8 datetime,
				  c9 decimal(5,3),
				  primary key (c1),
				  index (c3,c4(50),c5(50)),
				  index (c2))
		engine=innodb;

	create table t6 ( a int ) engine = innodb;
	insert into t6 values (50),(100),(150);

	--disable_query_log
	--disable_result_log
	let $n=5;

	# load created tables.
	while ($n)
	{
		start transaction;

		eval insert ignore into t1 values(
			$n, $n,
			repeat(concat(' tc3_',$n), 42),
			repeat(concat(' tc4_',$n), 300),
			repeat(concat(' tc5_',$n), 300),
			repeat(concat(' tc6_',$n), 300),
			repeat(concat(' tc7_',$n), 300),
			now(), (100.55+$n));

		eval insert ignore into t2 values(
			$n, $n,
			repeat(concat(' tc3_',$n), 42),
			repeat(concat(' tc4_',$n), 300),
			repeat(concat(' tc5_',$n), 300),
			repeat(concat(' tc6_',$n), 300),
			repeat(concat(' tc7_',$n), 300),
			now(), (100.55+$n));

		eval insert ignore into t3 values(
			$n, $n,
			repeat(concat(' tc3_',$n), 42),
			repeat(concat(' tc4_',$n), 300),
			repeat(concat(' tc5_',$n), 300),
			repeat(concat(' tc6_',$n), 300),
			repeat(concat(' tc7_',$n), 300),
			now(), (100.55+$n));

		eval insert ignore into t4 values(
			$n, $n,
			repeat(concat(' tc3_',$n), 42),
			repeat(concat(' tc4_',$n), 300),
			repeat(concat(' tc5_',$n), 300),
			repeat(concat(' tc6_',$n), 300),
			repeat(concat(' tc7_',$n), 300),
			now(), (100.55+$n));

		eval insert ignore into t5 values(
			$n, $n,
			repeat(concat(' tc3_',$n), 42),
			repeat(concat(' tc4_',$n), 300),
			repeat(concat(' tc5_',$n), 300),
			repeat(concat(' tc6_',$n), 300),
			repeat(concat(' tc7_',$n), 300),
			now(), (100.55+$n));

		if ($n <= 3)
		{
			commit;
		}

		if ($n > 3)
		{
			rollback;
		}

		dec $n;
	}

	# validate loading of the tables.
	--enable_result_log
	--enable_query_log
	select count(*) from t1;
	select count(*) from t2;
	select count(*) from t3;
	select count(*) from t4;
	select count(*) from t5;
	select count(*) from t6;

	# set the debug crash point and exercise them.
	if ($cnt == 6)
	{
		set session debug="+d,ib_trunc_crash_during_drop_index_temp_table";
		--echo "---debug ib_trunc_crash_during_drop_index_temp_table point---"
	}
	if ($cnt == 5)
	{
		set session debug="+d,ib_trunc_crash_drop_reinit_done_create_to_start";
		--echo "---debug ib_trunc_crash_drop_reinit_done_create_to_start---"
	}

	if ($cnt >= 5) {
		--echo # Write file to make mysql-test-run.pl expect crash and restart
		--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
		--echo # Run the crashing query
		--error 2013
		truncate table t5;
		--source include/wait_until_disconnected.inc
		--enable_reconnect
		--echo # Restart the MySQL server
		--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
		--source include/wait_until_connected_again.inc
		--disable_reconnect
		select count(*) from t1;
		select count(*) from t2;
		select count(*) from t3;
		select count(*) from t4;
		--error ER_NO_SUCH_TABLE
		select count(*) from t5;
		select count(*) from t6;
	}

	# set the debug crash point and exercise them.
	if ($cnt == 6)
	{
		set session debug="+d,ib_trunc_crash_on_drop_of_sec_index";
		--echo "---debug ib_trunc_crash_on_drop_of_sec_index point---"
	}
	if ($cnt == 5)
	{
		set session debug="+d,ib_trunc_crash_on_create_of_sec_index";
		--echo "---debug ib_trunc_crash_on_create_of_sec_index---"
	}
	if ($cnt == 4)
	{
		set session debug="+d,ib_trunc_crash_before_log_removal";
		--echo "---debug ib_trunc_crash_before_log_removal point---"
	}
	if ($cnt == 3)
	{
		set session debug="+d,ib_trunc_crash_after_truncate_done";
		--echo "---debug ib_trunc_crash_after_truncate_done point---"
	}
	if ($cnt == 2)
	{
		set session debug="+d,ib_trunc_crash_after_truncate_done";
		--echo "---debug ib_trunc_crash_after_truncate_done point---"
	}
	if ($cnt == 1)
	{
		set session debug="+d,ib_trunc_crash_after_redo_log_write_complete";
		--echo "---debug ib_trunc_crash_after_redo_log_write_complete point---"
	}

	--echo # Write file to make mysql-test-run.pl expect crash and restart
	--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
	--echo # Run the crashing query
	--error 2013
	truncate table t1;
	--source include/wait_until_disconnected.inc
	--enable_reconnect
	--echo # Restart the MySQL server
	--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
	--source include/wait_until_connected_again.inc
	--disable_reconnect
	select count(*) from t1;
	select count(*) from t2;
	select count(*) from t3;
	select count(*) from t4;
	--error ER_NO_SUCH_TABLE
	select count(*) from t5;
	select count(*) from t6;

	if ($cnt == 6)
	{
		set session debug="+d,ib_trunc_crash_on_drop_of_sec_index";
		--echo "---debug ib_trunc_crash_on_drop_of_sec_index point---"
	}
	if ($cnt == 5)
	{
		set session debug="+d,ib_trunc_crash_on_create_of_sec_index";
		--echo "---debug ib_trunc_crash_on_create_of_sec_index---"
	}
	if ($cnt == 4)
	{
		set session debug="+d,ib_trunc_crash_before_log_removal";
		--echo "---debug ib_trunc_crash_before_log_removal point---"
	}
	if ($cnt == 3)
	{
		set session debug="+d,ib_trunc_crash_after_truncate_done";
		--echo "---debug ib_trunc_crash_after_truncate_done point---"
	}
	if ($cnt == 2)
	{
		set session debug="+d,ib_trunc_crash_after_truncate_done";
		--echo "---debug ib_trunc_crash_after_truncate_done point---"
	}
	if ($cnt == 1)
	{
		set session debug="+d,ib_trunc_crash_after_redo_log_write_complete";
		--echo "---debug ib_trunc_crash_after_redo_log_write_complete point---"
	}


	--echo # Write file to make mysql-test-run.pl expect crash and restart
	--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
	--echo # Run the crashing query
	--error 2013
	truncate table t2;
	--source include/wait_until_disconnected.inc
	--enable_reconnect
	--echo # Restart the MySQL server
	--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
	--source include/wait_until_connected_again.inc
	--disable_reconnect
	select count(*) from t1;
	select count(*) from t2;
	select count(*) from t3;
	select count(*) from t4;
	--error ER_NO_SUCH_TABLE
	select count(*) from t5;
	select count(*) from t6;

	if ($cnt == 6)
	{
		set session debug="+d,ib_trunc_crash_on_drop_of_sec_index";
		--echo "---debug ib_trunc_crash_on_drop_of_sec_index point---"
	}
	if ($cnt == 5)
	{
		set session debug="+d,ib_trunc_crash_on_create_of_sec_index";
		--echo "---debug ib_trunc_crash_on_create_of_sec_index---"
	}
	if ($cnt == 4)
	{
		set session debug="+d,ib_trunc_crash_before_log_removal";
		--echo "---debug ib_trunc_crash_before_log_removal point---"
	}
	if ($cnt == 3)
	{
		set session debug="+d,ib_trunc_crash_after_truncate_done";
		--echo "---debug ib_trunc_crash_after_truncate_done point---"
	}
	if ($cnt == 2)
	{
		set session debug="+d,ib_trunc_crash_after_truncate_done";
		--echo "---debug ib_trunc_crash_after_truncate_done point---"
	}
	if ($cnt == 1)
	{
		set session debug="+d,ib_trunc_crash_after_redo_log_write_complete";
		--echo "---debug ib_trunc_crash_after_redo_log_write_complete point---"
	}


	--echo # Write file to make mysql-test-run.pl expect crash and restart
	--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
	--echo # Run the crashing query
	--error 2013
	truncate table t3;
	--source include/wait_until_disconnected.inc
	--enable_reconnect
	--echo # Restart the MySQL server
	--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
	--source include/wait_until_connected_again.inc
	--disable_reconnect
	select count(*) from t1;
	select count(*) from t2;
	select count(*) from t3;
	select count(*) from t4;
	--error ER_NO_SUCH_TABLE
	select count(*) from t5;
	select count(*) from t6;


	if ($cnt == 6)
	{
		set session debug="+d,ib_trunc_crash_on_drop_of_sec_index";
		--echo "---debug ib_trunc_crash_on_drop_of_sec_index point---"
	}
	if ($cnt == 5)
	{
		set session debug="+d,ib_trunc_crash_on_create_of_sec_index";
		--echo "---debug ib_trunc_crash_on_create_of_sec_index---"
	}
	if ($cnt == 4)
	{
		set session debug="+d,ib_trunc_crash_before_log_removal";
		--echo "---debug ib_trunc_crash_before_log_removal point---"
	}
	if ($cnt == 3)
	{
		set session debug="+d,ib_trunc_crash_after_truncate_done";
		--echo "---debug ib_trunc_crash_after_truncate_done point---"
	}
	if ($cnt == 2)
	{
		set session debug="+d,ib_trunc_crash_after_truncate_done";
		--echo "---debug ib_trunc_crash_after_truncate_done point---"
	}
	if ($cnt == 1)
	{
		set session debug="+d,ib_trunc_crash_after_redo_log_write_complete";
		--echo "---debug ib_trunc_crash_after_redo_log_write_complete point---"
	}

	--echo # Write file to make mysql-test-run.pl expect crash and restart
	--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
	--echo # Run the crashing query
	--error 2013
	truncate table t4;
	--source include/wait_until_disconnected.inc
	--enable_reconnect
	--echo # Restart the MySQL server
	--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
	--source include/wait_until_connected_again.inc
	--disable_reconnect
	select count(*) from t1;
	select count(*) from t2;
	select count(*) from t3;
	select count(*) from t4;
	--error ER_NO_SUCH_TABLE
	select count(*) from t5;
	select count(*) from t6;

	drop table t1, t2, t3, t4, t6;

	dec $cnt;

	--disable_query_log
	eval set global innodb_file_per_table=$innodb_file_per_table_orig;
	--enable_query_log
}