ddl: fix panic in checkRangePartitioningKeysConstraints when patition by range columns (#7366)

This commit is contained in:
winkyao
2018-08-13 14:07:51 +08:00
committed by Ewan Chou
parent d1246b3c91
commit 9e1ae02df7
2 changed files with 5 additions and 1 deletions

View File

@ -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) {

View File

@ -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
}