Bug #32780 Wrong error when doing ALTER TABLE OPTIMIZE PARTITION on a nonexisting partition
Submitted: 27 Nov 2007 17:46 Modified: 28 Nov 2007 13:37
Reporter: Philip Stoev Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Partitions Severity:S3 (Non-critical)
Version:5.1.23-BK OS:Any
Assigned to: CPU Architecture:Any

[27 Nov 2007 17:46] Philip Stoev
Description:
ALTER TABLE ... OPTIMIZE PARTITION outputs a wrong error message when attempting to optimize a non-existing partition.

How to repeat:
mysql> CREATE TABLE part1_range (f1 integer) PARTITION BY RANGE (f1) ( PARTITION p0 VALUES LESS THAN (MAXVALUE));
Query OK, 0 rows affected (0.01 sec)

mysql> ALTER TABLE part1_range OPTIMIZE PARTITION p1;
ERROR 1507 (HY000): Cannot remove all partitions, use DROP TABLE instead

5.1.22-RC prints this message:

ERROR 1504 (HY000): Partition management on a not partitioned table is not possible

other partition types and innodb are also affected.

Suggested fix:
Make sure the correct error message is returned. Maybe there is a deeper confusion in the code for the error message to be as it is?
[27 Nov 2007 19:49] MySQL Verification Team
Thank you for the bug report. I wasn't able to repeat with latest BK
source:

[miguel@skybr 5.1]$ bin/mysql -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.23-rc-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE TABLE part1_range (f1 integer) PARTITION BY RANGE (f1) ( PARTITION p0 VALUES
    -> LESS THAN (MAXVALUE));
Query OK, 0 rows affected (0.04 sec)

mysql> ALTER TABLE part1_range OPTIMIZE PARTITION p1;
ERROR 1507 (HY000): Error in list of partitions to OPTIMIZE

Below the BK changeset:

[miguel@skybr mysql-5.1]$ bk changes | head
ChangeSet@1.2648, 2007-11-27 11:02:00+01:00, mkindahl@dl145h.mysql.com +3 -0
  Disabling several tests that fail and reported as errors.

ChangeSet@1.2647, 2007-11-26 20:05:52+01:00, msvensson@pilot.mysql.com +1 -0
  Remove disabling of testcases

ChangeSet@1.2646, 2007-11-26 19:50:43+01:00, msvensson@pilot.mysql.com +3 -0
  Bug#25146 Some warnings/errors not shown when using --show-warnings
   - Additional patch to fix compiler warnings

[miguel@skybr mysql-5.1]$
[27 Nov 2007 20:18] Philip Stoev
I did a make distclean and a BUILD/compile-pentium-dbug-max and the problem persists:

[philips@philips mysql-5.1]$ bk pull
Pull pstoev@bk-internal.mysql.com:/home/bk/mysql-5.1
  -> file://build/mysql-5.1
pstoev@bk-internal.mysql.com's password:
Nothing to pull.

[philips@philips mysql-5.1]$ bk changes | head
ChangeSet@1.2648, 2007-11-27 11:02:00+01:00, mkindahl@dl145h.mysql.com +3 -0
  Disabling several tests that fail and reported as errors.

ChangeSet@1.2647, 2007-11-26 20:05:52+01:00, msvensson@pilot.mysql.com +1 -0
  Remove disabling of testcases

ChangeSet@1.2646, 2007-11-26 19:50:43+01:00, msvensson@pilot.mysql.com +3 -0
  Bug#25146 Some warnings/errors not shown when using --show-warnings
   - Additional patch to fix compiler warnings

[philips@philips mysql-5.1]$ uname -a
Linux philips 2.6.21-1.3194.fc7 #1 SMP Wed May 23 22:35:01 EDT 2007 i686 i686 i386 GNU/Linux

This is inside a VMWare 6
[28 Nov 2007 13:26] Hartmut Holzgraefe
Same changeset here, built with BUILD/compile-pentium-debug-max.

I'm getting the same message as with 5.1.22RC:

ERROR 1506 (HY000): Error in list of partitions to OPTIMIZE

Just the error code changed to 1504 to 1506
[28 Nov 2007 13:37] Philip Stoev
It appears that my mysqld binary has been locking to an older version or errmsg.sys. I am sorry for wasting your time, I will be more careful in the future.