@@ -871,6 +871,12 @@ var (
871871 }, {
872872 input : "alter table a partition by range (id) (partition p0 values less than (10), partition p1 values less than (maxvalue))" ,
873873 output : "alter table a partition by range (id) (partition p0 values less than (10), partition p1 values less than (maxvalue))" ,
874+ }, {
875+ input : "alter table tbl_hash_a partition by hash (col_a) partitions 8" ,
876+ output : "alter table tbl_hash_a partition by hash (col_a) partitions 8" ,
877+ }, {
878+ input : "alter table tbl_hash_b partition by linear hash (col_b) partitions 4" ,
879+ output : "alter table tbl_hash_b partition by linear hash (col_b) partitions 4" ,
874880 }, {
875881 input : "alter table tbl_part add partition (partition p2 values less than (100))" ,
876882 output : "alter table tbl_part add partition (partition p2 values less than (100))" ,
@@ -2831,6 +2837,12 @@ func TestCreateTable(t *testing.T) {
28312837 "create table t (id int) partition by range (id) (partition p0 values less than (10) engine =)" ,
28322838 // STORAGE ENGINE option requires the ENGINE keyword.
28332839 "create table t (id int) partition by range (id) (partition p0 values less than (10) storage = InnoDB)" ,
2840+ // HASH expression must be parenthesized.
2841+ "create table t (id int) partition by hash id partitions 8" ,
2842+ // PARTITIONS requires an integer value.
2843+ "create table t (id int) partition by hash (id) partitions" ,
2844+ // PARTITIONS keyword must not be misspelled.
2845+ "create table t (id int) partition by hash (id) partition 8" ,
28342846 }
28352847 for _ , sql := range invalidCreateTablePartitionSQL {
28362848 tree , err := Parse (sql )
@@ -3135,6 +3147,24 @@ func TestCreateTable(t *testing.T) {
31353147 "\t id bigint unsigned not null auto_increment,\n " +
31363148 "\t primary key (id)\n " +
31373149 ") partition by range (id) (partition p0 values less than (100) engine InnoDB, partition p1 values less than (maxvalue) engine InnoDB)" ,
3150+ }, {
3151+ input : "create table tbl_hash_main (\n " +
3152+ " col_a bigint unsigned not null,\n " +
3153+ " primary key (col_a)\n " +
3154+ ") partition by hash (col_a) partitions 10" ,
3155+ output : "create table tbl_hash_main (\n " +
3156+ "\t col_a bigint unsigned not null,\n " +
3157+ "\t primary key (col_a)\n " +
3158+ ") partition by hash (col_a) partitions 10" ,
3159+ }, {
3160+ input : "create table tbl_hash_linear (\n " +
3161+ " col_b bigint unsigned not null,\n " +
3162+ " primary key (col_b)\n " +
3163+ ") partition by linear hash (col_b) partitions 6" ,
3164+ output : "create table tbl_hash_linear (\n " +
3165+ "\t col_b bigint unsigned not null,\n " +
3166+ "\t primary key (col_b)\n " +
3167+ ") partition by linear hash (col_b) partitions 6" ,
31383168 }, {
31393169 input : "create table t_part (\n " +
31403170 " c_id bigint unsigned not null,\n " +
0 commit comments