MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Chad MILLER Date:November 29 2007 10:22pm
Subject:bk commit into 5.1 tree (cmiller:1.2610) BUG#32432
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of cmiller. When cmiller does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-11-29 17:22:13-05:00, cmiller@stripped +3 -0
  Bug#32432: ALTER TABLE does not accept the ENGINE and PARTITION \
  	clauses together
  
  The manual is wrong, but does suggest a good idea.  A 
  partitioning operation must come at the end of an ALTER TABLE 
  statement, but it should be allowed to be preceeded by commas
  if there are other alterations to be performed.
  
  Now, make commas optional.
  
  Thanks to Mikael for defining the specialness of partitioning 
  for me.

  mysql-test/r/partition.result@stripped, 2007-11-29 17:22:09-05:00, cmiller@stripped +42 -0
    Show that commas work and that out-of-order alterations do not.
    
    The docs are currently wrong in this respect.

  mysql-test/t/partition.test@stripped, 2007-11-29 17:22:09-05:00, cmiller@stripped +38 -0
    Show that commas work and that out-of-order alterations do not.
    
    The docs are currently wrong in this respect.

  sql/sql_yacc.yy@stripped, 2007-11-29 17:22:09-05:00, cmiller@stripped +4 -4
    Make commas optional between column alterations and partition 
    alterations.

diff -Nrup a/mysql-test/r/partition.result b/mysql-test/r/partition.result
--- a/mysql-test/r/partition.result	2007-10-29 07:56:40 -04:00
+++ b/mysql-test/r/partition.result	2007-11-29 17:22:09 -05:00
@@ -1257,4 +1257,46 @@ t1	CREATE TABLE `t1` (
   `b` int(11) DEFAULT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (b) (PARTITION p1 VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION p2 VALUES LESS THAN (20) ENGINE = MyISAM) */
 drop table t1, t2;
+create table t1 (id int);
+alter table t1 
+engine = archive,
+partition by range (id) ( 
+partition p1 values less than (1000), 
+partition p2 values less than (maxvalue)
+);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `id` int(11) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (id) (PARTITION p1 VALUES LESS THAN (1000) ENGINE = ARCHIVE, PARTITION p2 VALUES LESS THAN MAXVALUE ENGINE = ARCHIVE) */
+alter table t1 
+partition by range (id) ( 
+partition p1 values less than (1001), 
+partition p2 values less than (maxvalue)
+),
+engine = memory;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
+engine = memory' at line 5
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `id` int(11) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (id) (PARTITION p1 VALUES LESS THAN (1000) ENGINE = ARCHIVE, PARTITION p2 VALUES LESS THAN MAXVALUE ENGINE = ARCHIVE) */
+alter table t1 
+add column third int first,
+partition by range (id) ( 
+partition p1 values less than (1002), 
+partition p2 values less than (maxvalue)
+),
+add column fourth int first,
+engine = myisam;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
+add column fourth int first,
+engine = myisam' at line 6
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `id` int(11) DEFAULT NULL
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (id) (PARTITION p1 VALUES LESS THAN (1000) ENGINE = ARCHIVE, PARTITION p2 VALUES LESS THAN MAXVALUE ENGINE = ARCHIVE) */
+drop table t1;
 End of 5.1 tests
diff -Nrup a/mysql-test/t/partition.test b/mysql-test/t/partition.test
--- a/mysql-test/t/partition.test	2007-10-29 07:56:40 -04:00
+++ b/mysql-test/t/partition.test	2007-11-29 17:22:09 -05:00
@@ -1466,4 +1466,42 @@ PARTITION BY RANGE (b) (
 show create table t1;
 drop table t1, t2;
 
+#
+# Bug#32432: ALTER TABLE does not accept the ENGINE and PARTITION clauses together
+#
+create table t1 (id int);
+
+# a comma should be allowed between alter statement and partition modification.
+alter table t1 
+  engine = archive,
+  partition by range (id) ( 
+    partition p1 values less than (1000), 
+    partition p2 values less than (maxvalue)
+  );
+show create table t1;
+
+# alter statements not allowed after partition modifications.
+--error ER_PARSE_ERROR
+alter table t1 
+  partition by range (id) ( 
+    partition p1 values less than (1001), 
+    partition p2 values less than (maxvalue)
+  ),
+  engine = memory;
+show create table t1;
+
+# alter statements not allowed after partition modifications.
+--error ER_PARSE_ERROR
+alter table t1 
+  add column third int first,
+  partition by range (id) ( 
+    partition p1 values less than (1002), 
+    partition p2 values less than (maxvalue)
+  ),
+  add column fourth int first,
+  engine = myisam;
+show create table t1;
+
+drop table t1;
+
 --echo End of 5.1 tests
diff -Nrup a/sql/sql_yacc.yy b/sql/sql_yacc.yy
--- a/sql/sql_yacc.yy	2007-11-05 18:51:58 -05:00
+++ b/sql/sql_yacc.yy	2007-11-29 17:22:09 -05:00
@@ -5405,10 +5405,10 @@ alter_commands:
           /* empty */
         | DISCARD TABLESPACE { Lex->alter_info.tablespace_op= DISCARD_TABLESPACE; }
         | IMPORT TABLESPACE { Lex->alter_info.tablespace_op= IMPORT_TABLESPACE; }
-        | alter_list
-          opt_partitioning
-        | alter_list
-          remove_partitioning
+        | alter_list opt_partitioning
+        | alter_list ',' opt_partitioning
+        | alter_list remove_partitioning
+        | alter_list ',' remove_partitioning
         | remove_partitioning
         | partitioning
 /*
Thread
bk commit into 5.1 tree (cmiller:1.2610) BUG#32432Chad MILLER29 Nov