From bd581e1fbe764c72e43c6cba3586c645291945b4 Mon Sep 17 00:00:00 2001 From: "Y.Horie" Date: Fri, 22 Jul 2022 01:57:10 +0900 Subject: [PATCH 1/2] cherry pick #36345 to release-5.0 Signed-off-by: ti-srebot --- ddl/db_partition_test.go | 8 ++++++++ ddl/ddl_api.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ddl/db_partition_test.go b/ddl/db_partition_test.go index 8383a777c0007..e4c473ece27db 100644 --- a/ddl/db_partition_test.go +++ b/ddl/db_partition_test.go @@ -504,6 +504,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));", + dbterror.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 88395d67fe521..eca2e9569dd0c 100644 --- a/ddl/ddl_api.go +++ b/ddl/ddl_api.go @@ -2114,7 +2114,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 } From 664225432cb67389f2ca9a4e2ddb5c17c6f1e95a Mon Sep 17 00:00:00 2001 From: xhe Date: Wed, 27 Jul 2022 17:35:07 +0800 Subject: [PATCH 2/2] *: fix CI Signed-off-by: xhe --- ddl/db_partition_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddl/db_partition_test.go b/ddl/db_partition_test.go index e4c473ece27db..50a2d6f630f65 100644 --- a/ddl/db_partition_test.go +++ b/ddl/db_partition_test.go @@ -510,7 +510,7 @@ create table log_message_1 ( "partition p0 values less than ('2022-01-01')," + "partition p1 values less than (MAXVALUE), " + "partition p2 values less than (MAXVALUE));", - dbterror.ErrRangeNotIncreasing, + ddl.ErrRangeNotIncreasing, }, { "CREATE TABLE t1(c0 INT) PARTITION BY HASH((NOT c0)) PARTITIONS 2;",