~ubuntu-branches/ubuntu/trusty/mysql-5.6/trusty

« back to all changes in this revision

Viewing changes to mysql-test/suite/innodb/t/innodb-wl5522.test

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-12 11:54:27 UTC
  • Revision ID: package-import@ubuntu.com-20140212115427-oq6tfsqxl1wuwehi
Tags: upstream-5.6.15
ImportĀ upstreamĀ versionĀ 5.6.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Not supported in embedded
 
2
--source include/not_embedded.inc
 
3
 
 
4
-- source include/have_innodb.inc
 
5
 
 
6
--disable_warnings
 
7
DROP TABLE IF EXISTS t1;
 
8
--enable_warnings
 
9
 
 
10
let $innodb_file_per_table = `SELECT @@innodb_file_per_table`;
 
11
let $innodb_file_format = `SELECT @@innodb_file_format`;
 
12
 
 
13
SET GLOBAL innodb_file_per_table = 1;
 
14
SELECT @@innodb_file_per_table;
 
15
 
 
16
SET GLOBAL innodb_file_format = `Barracuda`;
 
17
SELECT @@innodb_file_format;
 
18
 
 
19
let $MYSQLD_TMPDIR = `SELECT @@tmpdir`;
 
20
let $MYSQLD_DATADIR = `SELECT @@datadir`;
 
21
 
 
22
CREATE TABLE t1
 
23
(a INT AUTO_INCREMENT PRIMARY KEY,
 
24
 b char(22),
 
25
 c varchar(255),
 
26
 KEY (b))
 
27
ENGINE = InnoDB;
 
28
 
 
29
insert into t1 (b, c) values ('Apa', 'Filler........'),
 
30
('Banan', 'Filler........'), ('Cavalry', '..asdasdfaeraf'),
 
31
('Devotion', 'asdfuihknaskdf'), ('Evolution', 'lsjndofiabsoibeg');
 
32
 
 
33
INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a;
 
34
INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a;
 
35
INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a;
 
36
INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a;
 
37
INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a;
 
38
INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a;
 
39
INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a;
 
40
SELECT COUNT(*) FROM t1;
 
41
SELECT * FROM t1 ORDER BY b,a DESC LIMIT 3;
 
42
SELECT * FROM t1 ORDER BY a DESC LIMIT 3;
 
43
--list_files $MYSQLD_DATADIR/test
 
44
--echo # Restarting server
 
45
-- source include/restart_mysqld.inc
 
46
--echo # Done restarting server
 
47
FLUSH TABLE t1 FOR EXPORT;
 
48
--echo # List before copying files
 
49
--list_files $MYSQLD_DATADIR/test
 
50
--copy_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_TMPDIR/t1.cfg
 
51
--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_TMPDIR/t1.ibd
 
52
UNLOCK TABLES;
 
53
INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a;
 
54
SELECT COUNT(*) FROM t1;
 
55
SELECT * FROM t1 ORDER BY b,a DESC LIMIT 3;
 
56
SELECT * FROM t1 ORDER BY a DESC LIMIT 3;
 
57
--echo # Restarting server
 
58
-- source include/restart_mysqld.inc
 
59
--echo # Done restarting server
 
60
--echo # List before t1 DISCARD
 
61
--list_files $MYSQLD_DATADIR/test
 
62
ALTER TABLE t1 DISCARD TABLESPACE;
 
63
--echo # List after t1 DISCARD
 
64
--list_files $MYSQLD_DATADIR/test
 
65
--copy_file $MYSQLD_TMPDIR/t1.cfg $MYSQLD_DATADIR/test/t1.cfg
 
66
--copy_file $MYSQLD_TMPDIR/t1.ibd $MYSQLD_DATADIR/test/t1.ibd
 
67
ALTER TABLE t1 IMPORT TABLESPACE;
 
68
ALTER TABLE t1 ENGINE InnoDB;
 
69
SELECT COUNT(*) FROM t1;
 
70
SELECT * FROM t1 ORDER BY b,a DESC LIMIT 3;
 
71
SELECT * FROM t1 ORDER BY a DESC LIMIT 3;
 
72
--list_files $MYSQLD_DATADIR/test
 
73
SELECT COUNT(*) FROM t1;
 
74
SELECT * FROM t1 ORDER BY b,a DESC LIMIT 3;
 
75
SELECT * FROM t1 ORDER BY a DESC LIMIT 3;
 
76
DROP TABLE t1;
 
77
 
 
78
--remove_file $MYSQLD_TMPDIR/t1.cfg
 
79
--remove_file $MYSQLD_TMPDIR/t1.ibd
 
80
 
 
81
SET GLOBAL innodb_file_per_table = 1;
 
82
SELECT @@innodb_file_per_table;
 
83
 
 
84
SET GLOBAL innodb_file_format = `Barracuda`;
 
85
SELECT @@innodb_file_format;
 
86
 
 
87
let MYSQLD_DATADIR =`SELECT @@datadir`;
 
88
 
 
89
# Try importing when tablespace already exists
 
90
CREATE TABLE t1(
 
91
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
92
        c2 INT) ENGINE=InnoDB;
 
93
 
 
94
INSERT INTO t1(c2) VALUES(1);
 
95
--error ER_TABLESPACE_EXISTS
 
96
ALTER TABLE t1 IMPORT TABLESPACE;
 
97
SELECT * FROM t1;
 
98
DROP TABLE t1;
 
99
 
 
100
# Export/import on the same instance, with --innodb-file-per-table=1
 
101
CREATE TABLE t1(
 
102
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
103
        c2 INT) ENGINE=InnoDB;
 
104
 
 
105
INSERT INTO t1(c2) VALUES(1);
 
106
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
107
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
108
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
109
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
110
 
 
111
--list_files $MYSQLD_DATADIR/test
 
112
 
 
113
FLUSH TABLES t1 FOR EXPORT;
 
114
SELECT COUNT(*) FROM t1;
 
115
perl;
 
116
do 'include/innodb-util.inc';
 
117
ib_backup_tablespaces("test", "t1");
 
118
EOF
 
119
 
 
120
--list_files $MYSQLD_DATADIR/test
 
121
 
 
122
UNLOCK TABLES;
 
123
 
 
124
DROP TABLE t1;
 
125
 
 
126
CREATE TABLE t1(
 
127
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
128
        c2 INT) ENGINE=InnoDB;
 
129
 
 
130
ALTER TABLE t1 DISCARD TABLESPACE;
 
131
--error ER_TABLESPACE_DISCARDED
 
132
SELECT * FROM t1;
 
133
 
 
134
perl;
 
135
do 'include/innodb-util.inc';
 
136
ib_discard_tablespaces("test", "t1");
 
137
ib_restore_tablespaces("test", "t1");
 
138
EOF
 
139
 
 
140
--list_files $MYSQLD_DATADIR/test
 
141
 
 
142
ALTER TABLE t1 IMPORT TABLESPACE;
 
143
CHECK TABLE t1;
 
144
 
 
145
SELECT COUNT(*) FROM t1;
 
146
 
 
147
DROP TABLE t1;
 
148
 
 
149
# Export/import on the same instance, with --innodb-file-per-table=1
 
150
# Insert some more records to move the LSN forward and then drop the
 
151
# table and restore
 
152
CREATE TABLE t1(
 
153
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
154
        c2 INT) ENGINE=InnoDB;
 
155
 
 
156
INSERT INTO t1(c2) VALUES(1);
 
157
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
158
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
159
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
160
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
161
 
 
162
--list_files $MYSQLD_DATADIR/test
 
163
FLUSH TABLES t1 FOR EXPORT;
 
164
SELECT COUNT(*) FROM t1;
 
165
perl;
 
166
do 'include/innodb-util.inc';
 
167
ib_backup_tablespaces("test", "t1");
 
168
EOF
 
169
--list_files $MYSQLD_DATADIR/test
 
170
UNLOCK TABLES;
 
171
 
 
172
--list_files $MYSQLD_DATADIR/test
 
173
 
 
174
# Move the LSN forward
 
175
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
176
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
177
 
 
178
DROP TABLE t1;
 
179
 
 
180
CREATE TABLE t1(
 
181
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
182
        c2 INT) ENGINE=InnoDB;
 
183
 
 
184
ALTER TABLE t1 DISCARD TABLESPACE;
 
185
--error ER_TABLESPACE_DISCARDED
 
186
SELECT * FROM t1;
 
187
 
 
188
perl;
 
189
do 'include/innodb-util.inc';
 
190
ib_discard_tablespaces("test", "t1");
 
191
ib_restore_tablespaces("test", "t1");
 
192
EOF
 
193
 
 
194
--list_files $MYSQLD_DATADIR/test
 
195
 
 
196
ALTER TABLE t1 IMPORT TABLESPACE;
 
197
CHECK TABLE t1;
 
198
 
 
199
SELECT COUNT(*) FROM t1;
 
200
 
 
201
DROP TABLE t1;
 
202
 
 
203
# Export/import on the same instance, with --innodb-file-per-table=1
 
204
# Insert some more records to move the LSN forward and then drop the
 
205
# table and restore, this time the table has a secondary index too.
 
206
CREATE TABLE t1(
 
207
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
208
        c2 INT, INDEX(c2)) ENGINE=InnoDB;
 
209
 
 
210
INSERT INTO t1(c2) VALUES(1);
 
211
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
212
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
213
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
214
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
215
 
 
216
FLUSH TABLES t1 FOR EXPORT;
 
217
SELECT COUNT(*) FROM t1 WHERE c2 = 1;
 
218
perl;
 
219
do 'include/innodb-util.inc';
 
220
ib_backup_tablespaces("test", "t1");
 
221
EOF
 
222
--list_files $MYSQLD_DATADIR/test
 
223
UNLOCK TABLES;
 
224
 
 
225
# Move the LSN forward
 
226
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
227
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
228
 
 
229
DROP TABLE t1;
 
230
 
 
231
CREATE TABLE t1(
 
232
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
233
        c2 INT, INDEX(c2)) ENGINE=InnoDB;
 
234
 
 
235
ALTER TABLE t1 DISCARD TABLESPACE;
 
236
--error ER_TABLESPACE_DISCARDED
 
237
SELECT * FROM t1;
 
238
 
 
239
perl;
 
240
do 'include/innodb-util.inc';
 
241
ib_discard_tablespaces("test", "t1");
 
242
ib_restore_tablespaces("test", "t1");
 
243
EOF
 
244
 
 
245
ALTER TABLE t1 IMPORT TABLESPACE;
 
246
CHECK TABLE t1;
 
247
 
 
248
SELECT COUNT(*) FROM t1 WHERE c2 = 1;
 
249
 
 
250
DROP TABLE t1;
 
251
 
 
252
# Export/import on the same instance, with --innodb-file-per-table=1
 
253
# Insert some more records to move the LSN forward and then drop the
 
254
# table and restore, this time the table has a secondary index too.
 
255
# Rename the index on the create so that the IMPORT fails, drop index
 
256
# Create with proper name and then do an IMPORT.
 
257
CREATE TABLE t1(
 
258
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
259
        c2 INT, INDEX idx(c2)) ENGINE=InnoDB;
 
260
 
 
261
INSERT INTO t1(c2) VALUES(1);
 
262
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
263
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
264
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
265
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
266
 
 
267
FLUSH TABLES t1 FOR EXPORT;
 
268
SELECT COUNT(*) FROM t1 WHERE c2 = 1;
 
269
perl;
 
270
do 'include/innodb-util.inc';
 
271
ib_backup_tablespaces("test", "t1");
 
272
EOF
 
273
UNLOCK TABLES;
 
274
 
 
275
# Move the LSN forward
 
276
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
277
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
278
 
 
279
DROP TABLE t1;
 
280
 
 
281
CREATE TABLE t1(
 
282
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
283
        c2 INT, INDEX x(c2)) ENGINE=InnoDB;
 
284
 
 
285
ALTER TABLE t1 DISCARD TABLESPACE;
 
286
--error ER_TABLESPACE_DISCARDED
 
287
SELECT * FROM t1;
 
288
 
 
289
perl;
 
290
do 'include/innodb-util.inc';
 
291
ib_discard_tablespaces("test", "t1");
 
292
ib_restore_tablespaces("test", "t1");
 
293
EOF
 
294
 
 
295
# This is really a name mismatch error, need better error codes.
 
296
-- error ER_TABLE_SCHEMA_MISMATCH
 
297
ALTER TABLE t1 IMPORT TABLESPACE;
 
298
 
 
299
ALTER TABLE t1 DROP INDEX x;
 
300
ALTER TABLE t1 ADD INDEX idx(c2);
 
301
 
 
302
perl;
 
303
do 'include/innodb-util.inc';
 
304
ib_restore_tablespaces("test", "t1");
 
305
EOF
 
306
 
 
307
ALTER TABLE t1 IMPORT TABLESPACE;
 
308
CHECK TABLE t1;
 
309
 
 
310
SELECT * FROM t1;
 
311
 
 
312
perl;
 
313
do 'include/innodb-util.inc';
 
314
ib_cleanup("test", "t1");
 
315
EOF
 
316
 
 
317
DROP TABLE t1;
 
318
 
 
319
#
 
320
# Export/import on the same instance, with --innodb-file-per-table=0
 
321
# This should fail because it is not supported
 
322
SET GLOBAL innodb_file_per_table = 0;
 
323
 
 
324
CREATE TABLE t1(
 
325
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
326
        c2 INT) ENGINE=InnoDB;
 
327
 
 
328
INSERT INTO t1(c2) VALUES(1);
 
329
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
330
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
331
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
332
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
333
 
 
334
SELECT COUNT(*) FROM t1;
 
335
 
 
336
SHOW CREATE TABLE t1;
 
337
 
 
338
# This should fail, InnoDB should return a warning
 
339
FLUSH TABLES t1 FOR EXPORT;
 
340
 
 
341
UNLOCK TABLES;
 
342
 
 
343
DROP TABLE t1;
 
344
 
 
345
#
 
346
# Tests that check for schema mismatch during IMPORT
 
347
#
 
348
 
 
349
SET GLOBAL innodb_file_per_table = 1;
 
350
 
 
351
CREATE TABLE t1(
 
352
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
353
        c2 INT, INDEX idx(c2)) ENGINE=InnoDB;
 
354
 
 
355
INSERT INTO t1(c2) VALUES(1);
 
356
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
357
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
358
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
359
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
360
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
361
 
 
362
SHOW CREATE TABLE t1;
 
363
SELECT * FROM t1;
 
364
 
 
365
FLUSH TABLES t1 FOR EXPORT;
 
366
 
 
367
perl;
 
368
do 'include/innodb-util.inc';
 
369
ib_backup_tablespaces("test", "t1");
 
370
EOF
 
371
 
 
372
UNLOCK TABLES;
 
373
 
 
374
DROP TABLE t1;
 
375
 
 
376
# Table without the secondary index
 
377
CREATE TABLE t1(
 
378
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
379
        c2 INT) ENGINE=InnoDB;
 
380
 
 
381
ALTER TABLE t1 DISCARD TABLESPACE;
 
382
--error ER_TABLESPACE_DISCARDED
 
383
SELECT * FROM t1;
 
384
 
 
385
perl;
 
386
do 'include/innodb-util.inc';
 
387
ib_discard_tablespaces("test", "t1");
 
388
ib_restore_tablespaces("test", "t1");
 
389
EOF
 
390
 
 
391
# This should fail because of a missing secondary index
 
392
-- error ER_TABLE_SCHEMA_MISMATCH
 
393
ALTER TABLE t1 IMPORT TABLESPACE;
 
394
 
 
395
perl;
 
396
do 'include/innodb-util.inc';
 
397
ib_unlink_tablespace("test", "t1");
 
398
EOF
 
399
 
 
400
DROP TABLE t1;
 
401
 
 
402
# Table with an additional column
 
403
CREATE TABLE t1(
 
404
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
405
        c2 INT,
 
406
        c3 INT, INDEX idx(c2)) ENGINE=InnoDB;
 
407
 
 
408
ALTER TABLE t1 DISCARD TABLESPACE;
 
409
--error ER_TABLESPACE_DISCARDED
 
410
SELECT * FROM t1;
 
411
 
 
412
perl;
 
413
do 'include/innodb-util.inc';
 
414
ib_discard_tablespaces("test", "t1");
 
415
ib_restore_tablespaces("test", "t1");
 
416
EOF
 
417
 
 
418
# This should fail because the table has an additional column
 
419
-- error ER_TABLE_SCHEMA_MISMATCH
 
420
ALTER TABLE t1 IMPORT TABLESPACE;
 
421
 
 
422
perl;
 
423
do 'include/innodb-util.inc';
 
424
ib_unlink_tablespace("test", "t1");
 
425
EOF
 
426
 
 
427
DROP TABLE t1;
 
428
 
 
429
# Change the column type of c2
 
430
CREATE TABLE t1(
 
431
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
432
        c2 BIGINT, INDEX idx(c2)) ENGINE=InnoDB;
 
433
 
 
434
ALTER TABLE t1 DISCARD TABLESPACE;
 
435
--error ER_TABLESPACE_DISCARDED
 
436
SELECT * FROM t1;
 
437
 
 
438
perl;
 
439
do 'include/innodb-util.inc';
 
440
ib_discard_tablespaces("test", "t1");
 
441
ib_restore_tablespaces("test", "t1");
 
442
EOF
 
443
 
 
444
# This should fail because c2 is now a BIGINT and not INT
 
445
-- error ER_TABLE_SCHEMA_MISMATCH
 
446
ALTER TABLE t1 IMPORT TABLESPACE;
 
447
 
 
448
perl;
 
449
do 'include/innodb-util.inc';
 
450
ib_unlink_tablespace("test", "t1");
 
451
EOF
 
452
 
 
453
DROP TABLE t1;
 
454
 
 
455
# This should be OK.
 
456
CREATE TABLE t1(
 
457
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
458
        c2 INT, INDEX idx(c2)) ENGINE=InnoDB;
 
459
 
 
460
ALTER TABLE t1 DISCARD TABLESPACE;
 
461
--error ER_TABLESPACE_DISCARDED
 
462
SELECT * FROM t1;
 
463
 
 
464
perl;
 
465
do 'include/innodb-util.inc';
 
466
ib_discard_tablespaces("test", "t1");
 
467
ib_restore_tablespaces("test", "t1");
 
468
EOF
 
469
 
 
470
ALTER TABLE t1 IMPORT TABLESPACE;
 
471
CHECK TABLE t1;
 
472
 
 
473
perl;
 
474
do 'include/innodb-util.inc';
 
475
ib_cleanup("test", "t1");
 
476
EOF
 
477
 
 
478
SHOW CREATE TABLE t1;
 
479
SELECT * FROM t1;
 
480
 
 
481
DROP TABLE t1;
 
482
 
 
483
#
 
484
# Row format tests [EXPORT REDUNDANT - IMPORT COMPACT & DYNAMIC]
 
485
#
 
486
CREATE TABLE t1(
 
487
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
488
        c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
 
489
 
 
490
INSERT INTO t1(c2) VALUES(1);
 
491
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
492
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
493
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
494
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
495
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
496
 
 
497
SHOW CREATE TABLE t1;
 
498
SELECT * FROM t1;
 
499
 
 
500
FLUSH TABLES t1 FOR EXPORT;
 
501
 
 
502
perl;
 
503
do 'include/innodb-util.inc';
 
504
ib_backup_tablespaces("test", "t1");
 
505
EOF
 
506
 
 
507
UNLOCK TABLES;
 
508
 
 
509
DROP TABLE t1;
 
510
 
 
511
CREATE TABLE t1(
 
512
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
513
        c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
 
514
 
 
515
ALTER TABLE t1 DISCARD TABLESPACE;
 
516
--error ER_TABLESPACE_DISCARDED
 
517
SELECT * FROM t1;
 
518
 
 
519
perl;
 
520
do 'include/innodb-util.inc';
 
521
ib_discard_tablespaces("test", "t1");
 
522
ib_restore_tablespaces("test", "t1");
 
523
EOF
 
524
 
 
525
ALTER TABLE t1 IMPORT TABLESPACE;
 
526
CHECK TABLE t1;
 
527
 
 
528
perl;
 
529
do 'include/innodb-util.inc';
 
530
ib_cleanup("test", "t1");
 
531
EOF
 
532
 
 
533
SHOW CREATE TABLE t1;
 
534
SELECT * FROM t1;
 
535
 
 
536
DROP TABLE t1;
 
537
 
 
538
CREATE TABLE t1(
 
539
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
540
        c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPACT;
 
541
 
 
542
ALTER TABLE t1 DISCARD TABLESPACE;
 
543
--error ER_TABLESPACE_DISCARDED
 
544
SELECT * FROM t1;
 
545
 
 
546
perl;
 
547
do 'include/innodb-util.inc';
 
548
ib_discard_tablespaces("test", "t1");
 
549
ib_restore_tablespaces("test", "t1");
 
550
EOF
 
551
 
 
552
--error ER_TABLE_SCHEMA_MISMATCH
 
553
ALTER TABLE t1 IMPORT TABLESPACE;
 
554
 
 
555
perl;
 
556
do 'include/innodb-util.inc';
 
557
ib_unlink_tablespace("test", "t1");
 
558
EOF
 
559
 
 
560
DROP TABLE t1;
 
561
 
 
562
CREATE TABLE t1(
 
563
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
564
        c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
 
565
 
 
566
ALTER TABLE t1 DISCARD TABLESPACE;
 
567
--error ER_TABLESPACE_DISCARDED
 
568
SELECT * FROM t1;
 
569
 
 
570
perl;
 
571
do 'include/innodb-util.inc';
 
572
ib_discard_tablespaces("test", "t1");
 
573
ib_restore_tablespaces("test", "t1");
 
574
EOF
 
575
 
 
576
--error ER_TABLE_SCHEMA_MISMATCH
 
577
ALTER TABLE t1 IMPORT TABLESPACE;
 
578
 
 
579
perl;
 
580
do 'include/innodb-util.inc';
 
581
ib_unlink_tablespace("test", "t1");
 
582
EOF
 
583
 
 
584
DROP TABLE t1;
 
585
 
 
586
# This should be OK.
 
587
CREATE TABLE t1(
 
588
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
589
        c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
 
590
 
 
591
ALTER TABLE t1 DISCARD TABLESPACE;
 
592
--error ER_TABLESPACE_DISCARDED
 
593
SELECT * FROM t1;
 
594
 
 
595
perl;
 
596
do 'include/innodb-util.inc';
 
597
ib_discard_tablespaces("test", "t1");
 
598
ib_restore_tablespaces("test", "t1");
 
599
EOF
 
600
 
 
601
ALTER TABLE t1 IMPORT TABLESPACE;
 
602
 
 
603
perl;
 
604
do 'include/innodb-util.inc';
 
605
ib_cleanup("test", "t1");
 
606
EOF
 
607
 
 
608
SHOW CREATE TABLE t1;
 
609
SELECT * FROM t1;
 
610
 
 
611
DROP TABLE t1;
 
612
 
 
613
#
 
614
# Row format tests [EXPORT COMPACT - IMPORT REDUNDANT & DYNAMIC]
 
615
#
 
616
CREATE TABLE t1(
 
617
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
618
        c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPACT;
 
619
 
 
620
INSERT INTO t1(c2) VALUES(1);
 
621
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
622
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
623
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
624
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
625
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
626
 
 
627
SHOW CREATE TABLE t1;
 
628
SELECT * FROM t1;
 
629
 
 
630
FLUSH TABLES t1 FOR EXPORT;
 
631
 
 
632
perl;
 
633
do 'include/innodb-util.inc';
 
634
ib_backup_tablespaces("test", "t1");
 
635
EOF
 
636
 
 
637
UNLOCK TABLES;
 
638
 
 
639
DROP TABLE t1;
 
640
 
 
641
CREATE TABLE t1(
 
642
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
643
        c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPACT;
 
644
 
 
645
ALTER TABLE t1 DISCARD TABLESPACE;
 
646
--error ER_TABLESPACE_DISCARDED
 
647
SELECT * FROM t1;
 
648
 
 
649
perl;
 
650
do 'include/innodb-util.inc';
 
651
ib_discard_tablespaces("test", "t1");
 
652
ib_restore_tablespaces("test", "t1");
 
653
EOF
 
654
 
 
655
ALTER TABLE t1 IMPORT TABLESPACE;
 
656
CHECK TABLE t1;
 
657
 
 
658
perl;
 
659
do 'include/innodb-util.inc';
 
660
ib_cleanup("test", "t1");
 
661
EOF
 
662
 
 
663
SHOW CREATE TABLE t1;
 
664
SELECT * FROM t1;
 
665
 
 
666
DROP TABLE t1;
 
667
 
 
668
CREATE TABLE t1(
 
669
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
670
        c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
 
671
 
 
672
ALTER TABLE t1 DISCARD TABLESPACE;
 
673
--error ER_TABLESPACE_DISCARDED
 
674
SELECT * FROM t1;
 
675
 
 
676
perl;
 
677
do 'include/innodb-util.inc';
 
678
ib_discard_tablespaces("test", "t1");
 
679
ib_restore_tablespaces("test", "t1");
 
680
EOF
 
681
 
 
682
--error ER_TABLE_SCHEMA_MISMATCH
 
683
ALTER TABLE t1 IMPORT TABLESPACE;
 
684
 
 
685
perl;
 
686
do 'include/innodb-util.inc';
 
687
ib_unlink_tablespace("test", "t1");
 
688
EOF
 
689
 
 
690
DROP TABLE t1;
 
691
 
 
692
CREATE TABLE t1(
 
693
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
694
        c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
 
695
 
 
696
ALTER TABLE t1 DISCARD TABLESPACE;
 
697
--error ER_TABLESPACE_DISCARDED
 
698
SELECT * FROM t1;
 
699
 
 
700
perl;
 
701
do 'include/innodb-util.inc';
 
702
ib_discard_tablespaces("test", "t1");
 
703
ib_restore_tablespaces("test", "t1");
 
704
EOF
 
705
 
 
706
--error ER_TABLE_SCHEMA_MISMATCH
 
707
ALTER TABLE t1 IMPORT TABLESPACE;
 
708
 
 
709
perl;
 
710
do 'include/innodb-util.inc';
 
711
ib_unlink_tablespace("test", "t1");
 
712
EOF
 
713
 
 
714
DROP TABLE t1;
 
715
 
 
716
# This should be OK.
 
717
CREATE TABLE t1(
 
718
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
719
        c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPACT;
 
720
 
 
721
ALTER TABLE t1 DISCARD TABLESPACE;
 
722
--error ER_TABLESPACE_DISCARDED
 
723
SELECT * FROM t1;
 
724
 
 
725
perl;
 
726
do 'include/innodb-util.inc';
 
727
ib_discard_tablespaces("test", "t1");
 
728
ib_restore_tablespaces("test", "t1");
 
729
EOF
 
730
 
 
731
ALTER TABLE t1 IMPORT TABLESPACE;
 
732
CHECK TABLE t1;
 
733
 
 
734
perl;
 
735
do 'include/innodb-util.inc';
 
736
ib_cleanup("test", "t1");
 
737
EOF
 
738
 
 
739
SHOW CREATE TABLE t1;
 
740
SELECT * FROM t1;
 
741
 
 
742
DROP TABLE t1;
 
743
 
 
744
#
 
745
# Row format tests [EXPORT DYNAMIC- IMPORT REDUNDANT & DYNAMIC]
 
746
#
 
747
CREATE TABLE t1(
 
748
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
749
        c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
 
750
 
 
751
INSERT INTO t1(c2) VALUES(1);
 
752
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
753
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
754
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
755
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
756
INSERT INTO t1(c2) SELECT c2 FROM t1;
 
757
 
 
758
SHOW CREATE TABLE t1;
 
759
SELECT * FROM t1;
 
760
 
 
761
FLUSH TABLES t1 FOR EXPORT;
 
762
 
 
763
perl;
 
764
do 'include/innodb-util.inc';
 
765
ib_backup_tablespaces("test", "t1");
 
766
EOF
 
767
 
 
768
UNLOCK TABLES;
 
769
 
 
770
DROP TABLE t1;
 
771
 
 
772
CREATE TABLE t1(
 
773
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
774
        c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
 
775
 
 
776
ALTER TABLE t1 DISCARD TABLESPACE;
 
777
--error ER_TABLESPACE_DISCARDED
 
778
SELECT * FROM t1;
 
779
 
 
780
perl;
 
781
do 'include/innodb-util.inc';
 
782
ib_discard_tablespaces("test", "t1");
 
783
ib_restore_tablespaces("test", "t1");
 
784
EOF
 
785
 
 
786
ALTER TABLE t1 IMPORT TABLESPACE;
 
787
CHECK TABLE t1;
 
788
 
 
789
perl;
 
790
do 'include/innodb-util.inc';
 
791
ib_cleanup("test", "t1");
 
792
EOF
 
793
 
 
794
SHOW CREATE TABLE t1;
 
795
SELECT * FROM t1;
 
796
 
 
797
DROP TABLE t1;
 
798
 
 
799
CREATE TABLE t1(
 
800
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
801
        c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPACT;
 
802
 
 
803
ALTER TABLE t1 DISCARD TABLESPACE;
 
804
--error ER_TABLESPACE_DISCARDED
 
805
SELECT * FROM t1;
 
806
 
 
807
perl;
 
808
do 'include/innodb-util.inc';
 
809
ib_discard_tablespaces("test", "t1");
 
810
ib_restore_tablespaces("test", "t1");
 
811
EOF
 
812
 
 
813
--error ER_TABLE_SCHEMA_MISMATCH
 
814
ALTER TABLE t1 IMPORT TABLESPACE;
 
815
 
 
816
perl;
 
817
do 'include/innodb-util.inc';
 
818
ib_unlink_tablespace("test", "t1");
 
819
EOF
 
820
 
 
821
DROP TABLE t1;
 
822
 
 
823
CREATE TABLE t1(
 
824
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
825
        c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
 
826
 
 
827
ALTER TABLE t1 DISCARD TABLESPACE;
 
828
--error ER_TABLESPACE_DISCARDED
 
829
SELECT * FROM t1;
 
830
 
 
831
perl;
 
832
do 'include/innodb-util.inc';
 
833
ib_discard_tablespaces("test", "t1");
 
834
ib_restore_tablespaces("test", "t1");
 
835
EOF
 
836
 
 
837
--error ER_TABLE_SCHEMA_MISMATCH
 
838
ALTER TABLE t1 IMPORT TABLESPACE;
 
839
 
 
840
perl;
 
841
do 'include/innodb-util.inc';
 
842
ib_unlink_tablespace("test", "t1");
 
843
EOF
 
844
 
 
845
DROP TABLE t1;
 
846
 
 
847
# This should be OK.
 
848
CREATE TABLE t1(
 
849
        c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
850
        c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
 
851
 
 
852
ALTER TABLE t1 DISCARD TABLESPACE;
 
853
--error ER_TABLESPACE_DISCARDED
 
854
SELECT * FROM t1;
 
855
 
 
856
perl;
 
857
do 'include/innodb-util.inc';
 
858
ib_discard_tablespaces("test", "t1");
 
859
ib_restore_tablespaces("test", "t1");
 
860
EOF
 
861
 
 
862
ALTER TABLE t1 IMPORT TABLESPACE;
 
863
CHECK TABLE t1;
 
864
 
 
865
perl;
 
866
do 'include/innodb-util.inc';
 
867
ib_cleanup("test", "t1");
 
868
EOF
 
869
 
 
870
SHOW CREATE TABLE t1;
 
871
SELECT * FROM t1;
 
872
 
 
873
DROP TABLE t1;
 
874
 
 
875
call mtr.add_suppression("Got error -1 when reading table '.*'");
 
876
call mtr.add_suppression("InnoDB: Error: tablespace id and flags in file '.*'.*");
 
877
call mtr.add_suppression("InnoDB: The table .* doesn't have a corresponding tablespace, it was discarded");
 
878
 
 
879
# cleanup
 
880
--remove_file $MYSQLTEST_VARDIR/tmp/t1.cfg
 
881
--remove_file $MYSQLTEST_VARDIR/tmp/t1.ibd
 
882
 
 
883
eval SET GLOBAL INNODB_FILE_FORMAT=$innodb_file_format;
 
884
eval SET GLOBAL INNODB_FILE_PER_TABLE=$innodb_file_per_table;