@@ -254,3 +254,198 @@ ERROR HY000: The path specified for DATAFILE is too long.
254
254
ALTER TABLESPACE ts DROP DATAFILE 'no_such_file.ibd';
255
255
ERROR HY000: Incorrect File Name 'no_such_file.ibd'.
256
256
DROP TABLESPACE ts;
257
+ #
258
+ # Validate tablespace names in the SE.
259
+ #
260
+ # 1. Tablespace DDL.
261
+ # 1.1 Create/drop predefined tablespaces.
262
+ CREATE TABLESPACE innodb_system ADD DATAFILE 'f.ibd' ENGINE InnoDB;
263
+ ERROR 42000: InnoDB: `innodb_system` is a reserved tablespace name.
264
+ CREATE TABLESPACE innodb_file_per_table ADD DATAFILE 'f.ibd' ENGINE InnoDB;
265
+ ERROR 42000: InnoDB: `innodb_file_per_table` is a reserved tablespace name.
266
+ CREATE TABLESPACE innodb_temporary ADD DATAFILE 'f.ibd' ENGINE InnoDB;
267
+ ERROR 42000: InnoDB: `innodb_temporary` is a reserved tablespace name.
268
+ CREATE TABLESPACE mysql ADD DATAFILE 'f.ibd' ENGINE InnoDB;
269
+ ERROR 42000: InnoDB: `mysql` is a reserved tablespace name.
270
+ DROP TABLESPACE innodb_system;
271
+ ERROR 42000: InnoDB: `innodb_system` is a reserved tablespace name.
272
+ DROP TABLESPACE innodb_file_per_table;
273
+ ERROR 42000: InnoDB: `innodb_file_per_table` is a reserved tablespace name.
274
+ DROP TABLESPACE innodb_temporary;
275
+ ERROR 42000: InnoDB: `innodb_temporary` is a reserved tablespace name.
276
+ DROP TABLESPACE mysql;
277
+ ERROR 42000: InnoDB: `mysql` is a reserved tablespace name.
278
+ # 1.2 Create/drop implicit tablespaces.
279
+ CREATE TABLESPACE `innodb_file_per_table.2` ADD DATAFILE 'f.ibd' ENGINE InnoDB;
280
+ ERROR 42000: InnoDB: A general tablespace name cannot start with `innodb_`.
281
+ DROP TABLESPACE `innodb_file_per_table.2`;
282
+ ERROR 42000: InnoDB: A general tablespace name cannot start with `innodb_`.
283
+ CREATE TABLESPACE innodb_file_per_table_whatever ADD DATAFILE 'f.ibd' ENGINE InnoDB;
284
+ ERROR 42000: InnoDB: A general tablespace name cannot start with `innodb_`.
285
+ DROP TABLESPACE innodb_file_per_table_whatever;
286
+ ERROR 42000: InnoDB: A general tablespace name cannot start with `innodb_`.
287
+ CREATE TABLESPACE innodb_file_per_table ADD DATAFILE 'f.ibd' ENGINE InnoDB;
288
+ ERROR 42000: InnoDB: `innodb_file_per_table` is a reserved tablespace name.
289
+ DROP TABLESPACE innodb_file_per_table;
290
+ ERROR 42000: InnoDB: `innodb_file_per_table` is a reserved tablespace name.
291
+ # 2. Non partitioned table DDL.
292
+ # 2.1 Create table.
293
+ CREATE TABLE t1 (i INTEGER) TABLESPACE innodb_file_per_table ENGINE InnoDB;
294
+ CREATE TABLE t2 (i INTEGER) TABLESPACE innodb_system ENGINE InnoDB;
295
+ SHOW CREATE TABLE t1;
296
+ Table Create Table
297
+ t1 CREATE TABLE `t1` (
298
+ `i` int(11) DEFAULT NULL
299
+ ) /*!50100 TABLESPACE `innodb_file_per_table` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
300
+ SHOW CREATE TABLE t2;
301
+ Table Create Table
302
+ t2 CREATE TABLE `t2` (
303
+ `i` int(11) DEFAULT NULL
304
+ ) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
305
+ CREATE TABLE t_bad (i INTEGER) TABLESPACE `innodb_file_per_table.2` ENGINE InnoDB;
306
+ ERROR 42000: InnoDB: A general tablespace name cannot start with `innodb_`.
307
+ # 2.2 Alter table.
308
+ ALTER TABLE t2 TABLESPACE `innodb_file_per_table.2`;
309
+ ERROR 42000: InnoDB: A general tablespace name cannot start with `innodb_`.
310
+ # This is valid since MyISAM does not care:
311
+ ALTER TABLE t2 TABLESPACE `innodb_file_per_table.2` ENGINE MyISAM;
312
+ SHOW CREATE TABLE t2;
313
+ Table Create Table
314
+ t2 CREATE TABLE `t2` (
315
+ `i` int(11) DEFAULT NULL
316
+ ) /*!50100 TABLESPACE `innodb_file_per_table.2` */ ENGINE=MyISAM DEFAULT CHARSET=latin1
317
+ # Table t1 is carried over to MyISAM using the dummy 'innodb_file_per_table':
318
+ ALTER TABLE t1 ENGINE MyISAM;
319
+ SHOW CREATE TABLE t1;
320
+ Table Create Table
321
+ t1 CREATE TABLE `t1` (
322
+ `i` int(11) DEFAULT NULL
323
+ ) /*!50100 TABLESPACE `innodb_file_per_table` */ ENGINE=MyISAM DEFAULT CHARSET=latin1
324
+ # Changing only engine back to InnoDB now will be rejected for t2:
325
+ ALTER TABLE t2 ENGINE InnoDB;
326
+ ERROR 42000: InnoDB: A general tablespace name cannot start with `innodb_`.
327
+ SHOW CREATE TABLE t2;
328
+ Table Create Table
329
+ t2 CREATE TABLE `t2` (
330
+ `i` int(11) DEFAULT NULL
331
+ ) /*!50100 TABLESPACE `innodb_file_per_table.2` */ ENGINE=MyISAM DEFAULT CHARSET=latin1
332
+ # For t1, changing engine back to InnoDB will re-establish usage of the implicit tablespace:
333
+ ALTER TABLE t1 ENGINE InnoDB;
334
+ SHOW CREATE TABLE t1;
335
+ Table Create Table
336
+ t1 CREATE TABLE `t1` (
337
+ `i` int(11) DEFAULT NULL
338
+ ) /*!50100 TABLESPACE `innodb_file_per_table` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
339
+ # Changing both engine and tablespace works:
340
+ ALTER TABLE t1 TABLESPACE innodb_system ENGINE InnoDB;
341
+ SHOW CREATE TABLE t1;
342
+ Table Create Table
343
+ t1 CREATE TABLE `t1` (
344
+ `i` int(11) DEFAULT NULL
345
+ ) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
346
+ ALTER TABLE t2 TABLESPACE innodb_file_per_table ENGINE InnoDB;
347
+ SHOW CREATE TABLE t2;
348
+ Table Create Table
349
+ t2 CREATE TABLE `t2` (
350
+ `i` int(11) DEFAULT NULL
351
+ ) /*!50100 TABLESPACE `innodb_file_per_table` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
352
+ # Keeping a valid tablespace through ALTER TABLE:
353
+ ALTER TABLE t1 ADD COLUMN (j INTEGER);
354
+ CREATE TABLESPACE ts ADD DATAFILE 'f.ibd' ENGINE InnoDB;
355
+ ALTER TABLE t1 TABLESPACE ts;
356
+ ALTER TABLE t1 ENGINE MyISAM;
357
+ SHOW CREATE TABLE t1;
358
+ Table Create Table
359
+ t1 CREATE TABLE `t1` (
360
+ `i` int(11) DEFAULT NULL,
361
+ `j` int(11) DEFAULT NULL
362
+ ) /*!50100 TABLESPACE `ts` */ ENGINE=MyISAM DEFAULT CHARSET=latin1
363
+ ALTER TABLE t1 ENGINE InnoDB;
364
+ SHOW CREATE TABLE t1;
365
+ Table Create Table
366
+ t1 CREATE TABLE `t1` (
367
+ `i` int(11) DEFAULT NULL,
368
+ `j` int(11) DEFAULT NULL
369
+ ) /*!50100 TABLESPACE `ts` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
370
+ DROP TABLE t1;
371
+ DROP TABLE t2;
372
+ DROP TABLESPACE ts;
373
+ # 3. Partitioned table DDL.
374
+ # 3.1 Create table.
375
+ CREATE TABLE t_part_bad (i INTEGER) PARTITION BY RANGE(i)
376
+ PARTITIONS 2 (
377
+ PARTITION p0 VALUES LESS THAN(100) TABLESPACE `innodb_file_per_table.2`,
378
+ PARTITION p1 VALUES LESS THAN(200));
379
+ ERROR 42000: InnoDB: A general tablespace name cannot start with `innodb_`.
380
+ CREATE TABLE t_part (i INTEGER) TABLESPACE innodb_file_per_table PARTITION BY RANGE(i)
381
+ PARTITIONS 2 (
382
+ PARTITION p0 VALUES LESS THAN(100),
383
+ PARTITION p1 VALUES LESS THAN(200));
384
+ SHOW CREATE TABLE t_part;
385
+ Table Create Table
386
+ t_part CREATE TABLE `t_part` (
387
+ `i` int(11) DEFAULT NULL
388
+ ) /*!50100 TABLESPACE `innodb_file_per_table` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
389
+ /*!50100 PARTITION BY RANGE (i)
390
+ (PARTITION p0 VALUES LESS THAN (100) ENGINE = InnoDB,
391
+ PARTITION p1 VALUES LESS THAN (200) ENGINE = InnoDB) */
392
+ CREATE TABLE t_subpart (i INTEGER) PARTITION BY RANGE(i)
393
+ PARTITIONS 2 SUBPARTITION BY HASH(i) (
394
+ PARTITION p0 VALUES LESS THAN(100) (
395
+ SUBPARTITION sp00,
396
+ SUBPARTITION sp01),
397
+ PARTITION p1 VALUES LESS THAN(200) (
398
+ SUBPARTITION sp10,
399
+ SUBPARTITION sp11));
400
+ SHOW CREATE TABLE t_subpart;
401
+ Table Create Table
402
+ t_subpart CREATE TABLE `t_subpart` (
403
+ `i` int(11) DEFAULT NULL
404
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1
405
+ /*!50100 PARTITION BY RANGE (i)
406
+ SUBPARTITION BY HASH (i)
407
+ (PARTITION p0 VALUES LESS THAN (100)
408
+ (SUBPARTITION sp00 ENGINE = InnoDB,
409
+ SUBPARTITION sp01 ENGINE = InnoDB),
410
+ PARTITION p1 VALUES LESS THAN (200)
411
+ (SUBPARTITION sp10 ENGINE = InnoDB,
412
+ SUBPARTITION sp11 ENGINE = InnoDB)) */
413
+ # 2.3 Alter table.
414
+ ALTER TABLE t_part TABLESPACE innodb_system;
415
+ SHOW CREATE TABLE t_part;
416
+ Table Create Table
417
+ t_part CREATE TABLE `t_part` (
418
+ `i` int(11) DEFAULT NULL
419
+ ) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
420
+ /*!50100 PARTITION BY RANGE (i)
421
+ (PARTITION p0 VALUES LESS THAN (100) ENGINE = InnoDB,
422
+ PARTITION p1 VALUES LESS THAN (200) ENGINE = InnoDB) */
423
+ ALTER TABLE t_subpart TABLESPACE innodb_file_per_table;
424
+ SHOW CREATE TABLE t_subpart;
425
+ Table Create Table
426
+ t_subpart CREATE TABLE `t_subpart` (
427
+ `i` int(11) DEFAULT NULL
428
+ ) /*!50100 TABLESPACE `innodb_file_per_table` */ ENGINE=InnoDB DEFAULT CHARSET=latin1
429
+ /*!50100 PARTITION BY RANGE (i)
430
+ SUBPARTITION BY HASH (i)
431
+ (PARTITION p0 VALUES LESS THAN (100)
432
+ (SUBPARTITION sp00 ENGINE = InnoDB,
433
+ SUBPARTITION sp01 ENGINE = InnoDB),
434
+ PARTITION p1 VALUES LESS THAN (200)
435
+ (SUBPARTITION sp10 ENGINE = InnoDB,
436
+ SUBPARTITION sp11 ENGINE = InnoDB)) */
437
+ ALTER TABLE t_part TABLESPACE `innodb_file_per_table.2`;
438
+ ERROR 42000: InnoDB: A general tablespace name cannot start with `innodb_`.
439
+ ALTER TABLE t_subpart TABLESPACE `innodb_file_per_table.2`;
440
+ ERROR 42000: InnoDB: A general tablespace name cannot start with `innodb_`.
441
+ ALTER TABLE t_part REORGANIZE PARTITION p1 INTO
442
+ (PARTITION p1 VALUES LESS THAN (300) TABLESPACE `innodb_file_per_table.2`);
443
+ ERROR 42000: InnoDB: A general tablespace name cannot start with `innodb_`.
444
+ ALTER TABLE t_subpart REORGANIZE PARTITION p1 INTO
445
+ (PARTITION p1 VALUES LESS THAN (300) TABLESPACE `innodb_file_per_table.2`);
446
+ ERROR 42000: InnoDB: A general tablespace name cannot start with `innodb_`.
447
+ ALTER TABLE t_subpart REORGANIZE PARTITION s11 INTO
448
+ (PARTITION s11 TABLESPACE `innodb_file_per_table.2`);
449
+ ERROR 42000: InnoDB: A general tablespace name cannot start with `innodb_`.
450
+ DROP TABLE t_part;
451
+ DROP TABLE t_subpart;
0 commit comments