diff --git a/ddl/db_partition_test.go b/ddl/db_partition_test.go index f40c8daaf97d1..0d822ad96b981 100644 --- a/ddl/db_partition_test.go +++ b/ddl/db_partition_test.go @@ -512,6 +512,14 @@ create table log_message_1 ( "partition p1 values less than ('G'));", ddl.ErrRangeNotIncreasing, }, + { + "create table t(d datetime)" + + "partition by range columns (d) (" + + "partition p0 values less than ('2022-01-01')," + + "partition p1 values less than (MAXVALUE), " + + "partition p2 values less than (MAXVALUE));", + ddl.ErrRangeNotIncreasing, + }, { "CREATE TABLE t1(c0 INT) PARTITION BY HASH((NOT c0)) PARTITIONS 2;", ddl.ErrPartitionFunctionIsNotAllowed, diff --git a/ddl/ddl_api.go b/ddl/ddl_api.go index 6c9baaba572a6..88716d1942069 100644 --- a/ddl/ddl_api.go +++ b/ddl/ddl_api.go @@ -2319,7 +2319,7 @@ func checkTwoRangeColumns(ctx sessionctx.Context, curr, prev *model.PartitionDef } for i := 0; i < len(pi.Columns); i++ { // Special handling for MAXVALUE. - if strings.EqualFold(curr.LessThan[i], partitionMaxValue) { + if strings.EqualFold(curr.LessThan[i], partitionMaxValue) && !strings.EqualFold(prev.LessThan[i], partitionMaxValue) { // If current is maxvalue, it certainly >= previous. return true, nil }