Bug #73130 ALTER... REBUILD on subpartitions doesn\'t work with misplaced rows.
Submitted: 27 Jun 2014 6:03 Modified: 7 Jul 2014 13:45
Reporter: Horst Hunger Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Partitions Severity:S3 (Non-critical)
Version:5.7.5-m15 OS:Any
Assigned to: CPU Architecture:Any

[27 Jun 2014 6:03] Horst Hunger
Description:
CREATE TABLE tsp (a INT,
  b VARCHAR(55),
  PRIMARY KEY (a))
PARTITION BY RANGE (a)
SUBPARTITION BY HASH(a)
(PARTITION p0 VALUES LESS THAN (100)
 (SUBPARTITION sp0,
  SUBPARTITION sp1),
 PARTITION p1 VALUES LESS THAN MAXVALUE
 (SUBPARTITION sp2,
  SUBPARTITION sp3));
...
ALTER TABLE tsp EXCHANGE PARTITION sp3 WITH TABLE t WITHOUT VALIDATION;
...
--error ER_ROW_IN_WRONG_PARTITION
ALTER TABLE tsp REBUILD PARTITION p1;
ALTER TABLE tsp REBUILD PARTITION sp3;
...

The last ALTER...REBUILD must fail with  "ER_ROW_IN_WRONG_PARTITION" instead of succeeding like the REBUILD right before.

How to repeat:
./mtr partition_exchange
[27 Jun 2014 6:13] Horst Hunger
Posted by developer:
 
Please see partition_exchange.test, line 649.
[30 Jun 2014 8:00] Mattias Jonsson
Posted by developer:
 
Rebuild subpartition should be removed since the underlying code only handle partitions, resulting in rebuilding subpartitions is a no-op. That is the reason for not working with misplaced rows either.
[5 Jul 2014 21:41] Mattias Jonsson
Posted by developer:
 
Need to revert possibility to REBUILD named subpartitions from bug#14028340. Since subpartitions will not be rebuilt in fast_alter_partition_table/change_partitions, but only partition level operations will be handled there.
[7 Jul 2014 14:06] Jon Stephens
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

Documented fix as follows in the 5.7.5 changelog:

    In an ALTER TABLE statement, the server accepted REBUILD with the
    name of a subpartition as valid syntax even though the REBUILD
    keyword in this case did nothing. Now REBUILD is rejected in such
    cases, and causes the statement to fail with an error.

    Regression introduced by the fix for BUG#65184.
      

Closed.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html