List:Internals« Previous MessageNext Message »
From:Lu Jingdong Date:November 23 2007 10:35am
Subject:Patch for bug #32432
View as plain text  
There are some differences between the realization of "alter table with 
partition clauses" and reference manual.
The reference manual explains the "ALTER TABLE syntax" like this:
 ALTER TABLE tbl_name alter_specification [, alter_specification] ...
It will get an error result like this bug mentioned. But if you use this 
kind of statement ( no comma between engine clause and partition clause) 
it will be right. Because defination of  "alter_commands" in 
sql/sql_yacc.yy  is like this (no comma between "alter_list" and 
"opt_partitioning").
mysql> alter table t1
    ->     engine = archive
    ->  partition by range (id)
    ->     (
    ->         partition p1 values less than (1000),
    ->         partition p2 values less than (maxvalue)
    ->     );
Query OK, 0 rows affected (0.09 sec)
Records: 0  Duplicates: 0  Warnings: 0

This patch for bug #32432 ALTER TABLE does not accept the ENGINE and 
PARTITION clauses together
http://bugs.mysql.com/bug.php?id=32432

diff -Nur sql/sql_yacc.yy.orig sql/sql_yacc.yy
--- sql/sql_yacc.yy.orig        2007-11-23 18:11:39.000000000 +0800
+++ sql/sql_yacc.yy     2007-11-23 18:13:53.000000000 +0800
@@ -5501,7 +5501,8 @@
        };

 alter_list_item:
-       add_column column_def opt_place { }
+        partitioning
+       | add_column column_def opt_place { }
        | ADD key_def
          {
            Lex->alter_info.flags|= ALTER_ADD_INDEX;

Test and result:
mysql> drop table if exists t1;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> create table t1 (id int ) engine = MyISAM;
Query OK, 0 rows affected (0.08 sec)

mysql> alter table t1
    ->     engine = archive,
    ->     partition by range (id)
    ->     (
    ->         partition p1 values less than (1000),
    ->         partition p2 values less than (maxvalue)
    ->     );
Query OK, 0 rows affected (0.08 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> alter table t1 partition by range (id)
    ->    ( partition p1 values less than (1000),
    ->      partition p2 values less than (maxvalue)),
    ->  rename to t2, engine=innodb;
Query OK, 0 rows affected (0.08 sec)
Records: 0  Duplicates: 0  Warnings: 0
Thread
Patch for bug #32432Lu Jingdong23 Nov