v8-0003-Fix-error-message-in-check_partition_bounds_for_s.patch
application/octet-stream
Filename: v8-0003-Fix-error-message-in-check_partition_bounds_for_s.patch
Type: application/octet-stream
Part: 0
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 v8-0003
Subject: Fix error message in check_partition_bounds_for_split_range()
| File | + | − |
|---|---|---|
| src/backend/partitioning/partbounds.c | 50 | 21 |
From f1b75b45cb6c7f0070344f4d4e3d7b14b7792733 Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Thu, 18 Apr 2024 12:56:51 +0300
Subject: [PATCH v8 3/7] Fix error message in
check_partition_bounds_for_split_range()
Currently, the error message is produced by a system of complex substitutions
making it quite untranslatable and hard to read. This commit splits this into
4 plain error messages suitable for translation.
Reported-by: Kyotaro Horiguchi
Discussion: https://postgr.es/m/20240408.152402.1485994009160660141.horikyota.ntt%40gmail.com
---
src/backend/partitioning/partbounds.c | 71 +++++++++++++++++++--------
1 file changed, 50 insertions(+), 21 deletions(-)
diff --git a/src/backend/partitioning/partbounds.c b/src/backend/partitioning/partbounds.c
index b08edf87a69..2fb39e3d006 100644
--- a/src/backend/partitioning/partbounds.c
+++ b/src/backend/partitioning/partbounds.c
@@ -5211,7 +5211,7 @@ check_partition_bounds_for_split_range(Relation parent,
if (first || last)
{
PartitionBoundSpec *split_spec = get_partition_bound_spec(splitPartOid, splitPartName);
- bool overlap = false;
+ PartitionRangeDatum *datum;
if (first)
{
@@ -5229,8 +5229,30 @@ check_partition_bounds_for_split_range(Relation parent,
* Lower bound of "spec" should be equal (or greater than or equal
* in case defaultPart=true) to lower bound of split partition.
*/
- if ((!defaultPart && cmpval) || (defaultPart && cmpval < 0))
- overlap = true;
+ if (!defaultPart)
+ {
+ if (cmpval != 0)
+ {
+ datum = list_nth(spec->lowerdatums, abs(cmpval) - 1);
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ errmsg("lower bound of partition \"%s\" is not equal to lower bound of split partition",
+ relname),
+ parser_errposition(pstate, datum->location)));
+ }
+ }
+ else
+ {
+ if (cmpval < 0)
+ {
+ datum = list_nth(spec->lowerdatums, abs(cmpval) - 1);
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ errmsg("lower bound of partition \"%s\" is less than lower bound of split partition",
+ relname),
+ parser_errposition(pstate, datum->location)));
+ }
+ }
}
else
{
@@ -5243,29 +5265,36 @@ check_partition_bounds_for_split_range(Relation parent,
key->partcollation,
upper->datums, upper->kind,
false, split_upper);
+ datum = cmpval ? list_nth(spec->lowerdatums, abs(cmpval) - 1) : NULL;
/*
* Upper bound of "spec" should be equal (or less than or equal in
* case defaultPart=true) to upper bound of split partition.
*/
- if ((!defaultPart && cmpval) || (defaultPart && cmpval > 0))
- overlap = true;
- }
-
- if (overlap)
- {
- PartitionRangeDatum *datum;
-
- datum = list_nth(first ? spec->lowerdatums : spec->upperdatums, abs(cmpval) - 1);
-
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
- errmsg("%s bound of partition \"%s\" is %s %s bound of split partition",
- first ? "lower" : "upper",
- relname,
- defaultPart ? (first ? "less than" : "greater than") : "not equal to",
- first ? "lower" : "upper"),
- parser_errposition(pstate, datum->location)));
+ if (!defaultPart)
+ {
+ if (cmpval != 0)
+ {
+ datum = list_nth(spec->upperdatums, abs(cmpval) - 1);
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ errmsg("upper bound of partition \"%s\" is not equal to upper bound of split partition",
+ relname),
+ parser_errposition(pstate, datum->location)));
+ }
+ }
+ else
+ {
+ if (cmpval > 0)
+ {
+ datum = list_nth(spec->upperdatums, abs(cmpval) - 1);
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ errmsg("upper bound of partition \"%s\" is greater than upper bound of split partition",
+ relname),
+ parser_errposition(pstate, datum->location)));
+ }
+ }
}
}
}
--
2.39.3 (Apple Git-145)