Bug #79030 REORGANIZE PARTITION MOVES PARTITION TO TABLE-LEVEL TABLESPACE BY DEFAULT
Submitted: 30 Oct 2015 6:01 Modified: 22 Dec 2015 8:37
Reporter: Darshan M N Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.7 OS:Any
Assigned to: CPU Architecture:Any

[30 Oct 2015 6:01] Darshan M N
Description:
When REORGANIZE partition statement is used with no TABLESPACE option, the partition is moved to table level tablespace option.

This is wrong as table level tablespace option works more as default option for partitions on a partitioned table and it makes sense to use it only while adding a new partition to the table and during create table.

How to repeat:
CREATE TABLESPACE ts1 ADD DATAFILE 'ts1.ibd';
CREATE TABLESPACE ts2 ADD DATAFILE 'ts2.ibd';

CREATE TABLE t1 (a INT NOT NULL, PRIMARY KEY (a))
ENGINE=InnoDB TABLESPACE ts2
PARTITION BY RANGE(a)
PARTITIONS 4
 ( PARTITION P1 VALUES LESS THAN (2) TABLESPACE ts1,
   PARTITION P2 VALUES LESS THAN (4) TABLESPACE innodb_system,
   PARTITION P3 VALUES LESS THAN (6),
   PARTITION P4  VALUES LESS THAN (8) TABLESPACE innodb_file_per_table);

SHOW CREATE TABLE t1;

ALTER TABLE t1 REORGANIZE PARTITION p4 INTO (PARTITION p4 VALUES LESS THAN (8));
SHOW CREATE TABLE t1;

SELECT A.NAME as partition_name, A.SPACE_TYPE as space_type, B.NAME as space_name
FROM information_schema.innodb_sys_tables A
LEFT JOIN
information_schema.innodb_sys_tablespaces B
ON A.SPACE = B.SPACE
WHERE A.NAME LIKE '%t1%' ORDER BY A.NAME;

ALTER TABLE t1 REORGANIZE PARTITION p3 INTO (PARTITION p3 VALUES LESS THAN (6) TABLESPACE innodb_system);
SHOW CREATE TABLE t1;

SELECT A.NAME as partition_name, A.SPACE_TYPE as space_type, B.NAME as space_name
FROM information_schema.innodb_sys_tables A
LEFT JOIN
information_schema.innodb_sys_tablespaces B
ON A.SPACE = B.SPACE
WHERE A.NAME LIKE '%t1%' ORDER BY A.NAME;

DROP TABLE t1;
[22 Dec 2015 8:37] Erlend Dahl
Fixed in 5.7.11, 5.8.0 under the heading of

Bug#21914047 SHOW CREATE DUMPS AFTER ALTER ON INNODB TABLE WITH PARTITIONS USING TABLESPACE.