Bug #70343 Table Comment and Partition Statements Cannot Co-exist in Create Table Stmt
Submitted: 14 Sep 2013 8:58 Modified: 14 Sep 2013 9:51
Reporter: Chao Yang Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Partitions Severity:S3 (Non-critical)
Version:5.6.12 OS:MacOS
Assigned to: CPU Architecture:Any
Tags: comment, partition

[14 Sep 2013 8:58] Chao Yang
Description:
Table comment and partition statements cannot co-exist in a single CREATE TABLE statement.

The following statement, at first glance, contains no syntax error but MySQL
client produced the following error:

ERROR 1064 (42000) at line 37: 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 'partition by linear key(id)
  partitions 4' at line 10

create table if not exists t_linearpart (
  id            int unsigned auto_increment key,
  lname         varchar(20) not null,
  fname         varchar(20) not null,
  sex           enum('M','F'),
  score         mediumint unsigned,
  index (lname,fname)
    comment 'table cannot have non-integer unique key on linear partition'
) comment "linear hash is also possible",
  partition by linear key(id)
  partitions 4;

However, when separated, CREATE TABLE with comment ONLY and with partition ONLY produce no MySQL error.

How to repeat:
Run the following CREATE TABLE statement on MySQL client:

create table if not exists t_linearpart (
  id            int unsigned auto_increment key,
  lname         varchar(20) not null,
  fname         varchar(20) not null,
  sex           enum('M','F'),
  score         mediumint unsigned,
  index (lname,fname)
    comment 'table cannot have non-integer unique key on linear partition'
) comment "linear hash is also possible",
  partition by linear key(id)
  partitions 4;

The following error is produced:

ERROR 1064 (42000) at line 37: 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 'partition by linear key(id)
  partitions 4' at line 10

Suggested fix:
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
    (create_definition,...)
    [table_options]
    [partition_options]

table_options:
    table_option [[,] table_option] ...

table_option:
  ...
  | COMMENT [=] 'string'

partition_options:
    PARTITION BY
        { [LINEAR] HASH(expr)
        | [LINEAR] KEY [ALGORITHM={1|2}] (column_list)
        | RANGE{(expr) | COLUMNS(column_list)}
        | LIST{(expr) | COLUMNS(column_list)} }
    [PARTITIONS num]...

Based on the Syntax above for CREATE TABLE, table comment and partition should be able to co-exist.
[14 Sep 2013 9:51] Chao Yang
Sorry, the comma after the comment should have been removed.