diff --git a/ddl/db_test.go b/ddl/db_test.go index ff7d487471..69921cb423 100644 --- a/ddl/db_test.go +++ b/ddl/db_test.go @@ -1723,6 +1723,9 @@ func (s *testDBSuite) TestCreateTableWithPartition(c *C) { // test check order. The sql below have 2 problem: 1. ErrFieldTypeNotAllowedAsPartitionField 2. ErrPartitionMaxvalue , mysql will return ErrPartitionMaxvalue. s.testErrorCode(c, `create TABLE t25 (c1 float) partition by range( c1 ) (partition p1 values less than maxvalue,partition p0 values less than (2000));`, tmysql.ErrPartitionMaxvalue) + + // Fix issue 7362. + s.tk.MustExec("create table test_partition(id bigint, name varchar(255), primary key(id)) ENGINE=InnoDB DEFAULT CHARSET=utf8 PARTITION BY RANGE COLUMNS(id) (PARTITION p1 VALUES LESS THAN (10) ENGINE = InnoDB);") } func (s *testDBSuite) TestTableDDLWithFloatType(c *C) { diff --git a/ddl/partition.go b/ddl/partition.go index f9eaac5192..25f18d9555 100644 --- a/ddl/partition.go +++ b/ddl/partition.go @@ -285,7 +285,8 @@ func getPartitionIDs(table *model.TableInfo) []int64 { // checkRangePartitioningKeysConstraints checks that the range partitioning key is included in the table constraint. func checkRangePartitioningKeysConstraints(ctx sessionctx.Context, s *ast.CreateTableStmt, tblInfo *model.TableInfo, constraints []*ast.Constraint) error { // Returns directly if there is no constraint in the partition table. - if len(constraints) == 0 { + // TODO: Remove the test 's.Partition.Expr == nil' when we support 'PARTITION BY RANGE COLUMNS' + if len(constraints) == 0 || s.Partition.Expr == nil { return nil }