v2-0002-Fix-SPLIT-PARTITION-hint-for-DEFAULT-partition-bo.patch

application/octet-stream

Filename: v2-0002-Fix-SPLIT-PARTITION-hint-for-DEFAULT-partition-bo.patch
Type: application/octet-stream
Part: 1
Message: Re: Fix SPLIT PARTITION bound-overlap bug and other improvements

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v2-0002
Subject: Fix SPLIT PARTITION hint for DEFAULT partition bounds
File+
src/backend/partitioning/partbounds.c 2 4
src/test/regress/expected/partition_split.out 1 1
From 1a30c86cdc81482793298602f89d03821207339c Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <lic@highgo.com>
Date: Thu, 14 May 2026 13:53:25 +0800
Subject: [PATCH v2 2/4] Fix SPLIT PARTITION hint for DEFAULT partition bounds

When ALTER TABLE ... SPLIT PARTITION specifies a DEFAULT partition, the
explicit partitions do not need to cover the split partition's bound
exactly.  They may cover only part of it, with the DEFAULT partition
covering the remaining range.

However, the existing hint said that the combined bounds of the new
partitions must exactly match the bound of the split partition, which is
misleading for this case and inconsistent with the code comment.

Fix the hint to state the actual requirement: explicit partition bounds
must stay within the bounds of the split partition when a DEFAULT
partition is specified.

Author: Chao Li <lic@highgo.com>
Reviewed-by:
Discussion: https://postgr.es/m/C18878AB-DEB2-4A61-9995-A035DD644B81@gmail.com
---
 src/backend/partitioning/partbounds.c         | 6 ++----
 src/test/regress/expected/partition_split.out | 2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/backend/partitioning/partbounds.c b/src/backend/partitioning/partbounds.c
index 73dea0375be..19589dc687f 100644
--- a/src/backend/partitioning/partbounds.c
+++ b/src/backend/partitioning/partbounds.c
@@ -5415,8 +5415,7 @@ check_partition_bounds_for_split_range(Relation parent,
 						errmsg("lower bound of partition \"%s\" is less than lower bound of split partition \"%s\"",
 							   relname,
 							   get_rel_name(splitPartOid)),
-						errhint("%s require combined bounds of new partitions must exactly match the bound of the split partition.",
-								"ALTER TABLE ... SPLIT PARTITION"),
+						errhint("Explicit partition bounds must be contained within the bounds of the split partition when a DEFAULT partition is specified."),
 						parser_errposition(pstate, exprLocation((Node *) datum)));
 		}
 
@@ -5458,8 +5457,7 @@ check_partition_bounds_for_split_range(Relation parent,
 						errmsg("upper bound of partition \"%s\" is greater than upper bound of split partition \"%s\"",
 							   relname,
 							   get_rel_name(splitPartOid)),
-						errhint("%s require combined bounds of new partitions must exactly match the bound of the split partition.",
-								"ALTER TABLE ... SPLIT PARTITION"),
+						errhint("Explicit partition bounds must be contained within the bounds of the split partition when a DEFAULT partition is specified."),
 						parser_errposition(pstate, exprLocation((Node *) datum)));
 		}
 	}
diff --git a/src/test/regress/expected/partition_split.out b/src/test/regress/expected/partition_split.out
index a2ccbe5138b..d4f536c5e00 100644
--- a/src/test/regress/expected/partition_split.out
+++ b/src/test/regress/expected/partition_split.out
@@ -1201,7 +1201,7 @@ ALTER TABLE t SPLIT PARTITION tp_0_51 INTO
 ERROR:  upper bound of partition "tp_0_51" is greater than upper bound of split partition "tp_0_51"
 LINE 2:   (PARTITION tp_0_51 FOR VALUES FROM (0) TO (53),
                                                      ^
-HINT:  ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition.
+HINT:  Explicit partition bounds must be contained within the bounds of the split partition when a DEFAULT partition is specified.
 DROP TABLE t;
 --
 -- Try to SPLIT partition of another table.
-- 
2.50.1 (Apple Git-155)