Bug #36008 | Adding a partition after the maxvalue partition breaks table | ||
---|---|---|---|
Submitted: | 11 Apr 2008 22:57 | Modified: | 25 Apr 2008 14:31 |
Reporter: | Gordon Hopper | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Partitions | Severity: | S2 (Serious) |
Version: | 5.1.23-rc-community | OS: | Any |
Assigned to: | Mattias Jonsson | CPU Architecture: | Any |
[11 Apr 2008 22:57]
Gordon Hopper
[12 Apr 2008 0:09]
Todd Farmer
Verified on 5.1.23-rc: mysql> CREATE TABLE sample1 ( -> rec_id int auto_increment, -> insert_date date, -> primary key ( rec_id, insert_date ) -> ) ENGINE=MySQL -> PARTITION BY RANGE ( YEAR(insert_date) ) ( -> PARTITION p1 VALUES LESS THAN (1000), -> PARTITION p2 VALUES LESS THAN (2000), -> PARTITION p99 VALUES LESS THAN MAXVALUE -> ); Query OK, 0 rows affected, 2 warnings (0.09 sec) mysql> mysql> ALTER TABLE sample1 ADD PARTITION ( PARTITION p3 VALUES LESS THAN (3000) ); Query OK, 0 rows affected (0.89 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> mysql> SHOW CREATE TABLE sample1; ERROR 1064 (42000): MAXVALUE can only be used in last partition definition near ') ENGINE = MyISAM)' at line 1 Instead of adding a new partition, we needed to issue REORGANIZE PARTITION. But after the .frm is corrupted by the ADD PARTITION statement, this correct statement cannot restore the partitioning: The server error log states: 080412 11:59:28 [ERROR] bin\mysqld.exe: Incorrect information in file: '.\test\sample1.frm' The only workaround I identified was to manually alter the partitioning clause in the .frm file to list the MAXVALUE entry last and issue FLUSH TABLES. Obviously, that's not a viable workaround except for recovery situations. Execution of ADD PARTITION on table that has defined range-based partition VALUES LESS THAN MAXVALUE should generate an error, at minimum, to prevent corruption of .frm file.
[17 Apr 2008 17:58]
Valeriy Kravchuk
Bug #36150 was marked as a duplicate of this one.
[25 Apr 2008 14:30]
Mattias Jonsson
This bug does not exist in 5.1.24-rc. (can be verified in 5.1.23-rc, but not in 5.1.24-rc). And yes, the proper way to split one partition is REORGANIZE PARTITION.