Skip to content

Commit 96c7381

Browse files
committed
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 Reviewed-by: Pavel Borisov
1 parent fcf80c5 commit 96c7381

File tree

1 file changed

+49
-21
lines changed

1 file changed

+49
-21
lines changed

src/backend/partitioning/partbounds.c

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5211,7 +5211,7 @@ check_partition_bounds_for_split_range(Relation parent,
52115211
if (first || last)
52125212
{
52135213
PartitionBoundSpec *split_spec = get_partition_bound_spec(splitPartOid, splitPartName);
5214-
bool overlap = false;
5214+
PartitionRangeDatum *datum;
52155215

52165216
if (first)
52175217
{
@@ -5229,8 +5229,30 @@ check_partition_bounds_for_split_range(Relation parent,
52295229
* Lower bound of "spec" should be equal (or greater than or equal
52305230
* in case defaultPart=true) to lower bound of split partition.
52315231
*/
5232-
if ((!defaultPart && cmpval) || (defaultPart && cmpval < 0))
5233-
overlap = true;
5232+
if (!defaultPart)
5233+
{
5234+
if (cmpval != 0)
5235+
{
5236+
datum = list_nth(spec->lowerdatums, abs(cmpval) - 1);
5237+
ereport(ERROR,
5238+
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
5239+
errmsg("lower bound of partition \"%s\" is not equal to lower bound of split partition",
5240+
relname),
5241+
parser_errposition(pstate, datum->location)));
5242+
}
5243+
}
5244+
else
5245+
{
5246+
if (cmpval < 0)
5247+
{
5248+
datum = list_nth(spec->lowerdatums, abs(cmpval) - 1);
5249+
ereport(ERROR,
5250+
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
5251+
errmsg("lower bound of partition \"%s\" is less than lower bound of split partition",
5252+
relname),
5253+
parser_errposition(pstate, datum->location)));
5254+
}
5255+
}
52345256
}
52355257
else
52365258
{
@@ -5248,24 +5270,30 @@ check_partition_bounds_for_split_range(Relation parent,
52485270
* Upper bound of "spec" should be equal (or less than or equal in
52495271
* case defaultPart=true) to upper bound of split partition.
52505272
*/
5251-
if ((!defaultPart && cmpval) || (defaultPart && cmpval > 0))
5252-
overlap = true;
5253-
}
5254-
5255-
if (overlap)
5256-
{
5257-
PartitionRangeDatum *datum;
5258-
5259-
datum = list_nth(first ? spec->lowerdatums : spec->upperdatums, abs(cmpval) - 1);
5260-
5261-
ereport(ERROR,
5262-
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
5263-
errmsg("%s bound of partition \"%s\" is %s %s bound of split partition",
5264-
first ? "lower" : "upper",
5265-
relname,
5266-
defaultPart ? (first ? "less than" : "greater than") : "not equal to",
5267-
first ? "lower" : "upper"),
5268-
parser_errposition(pstate, datum->location)));
5273+
if (!defaultPart)
5274+
{
5275+
if (cmpval != 0)
5276+
{
5277+
datum = list_nth(spec->upperdatums, abs(cmpval) - 1);
5278+
ereport(ERROR,
5279+
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
5280+
errmsg("upper bound of partition \"%s\" is not equal to upper bound of split partition",
5281+
relname),
5282+
parser_errposition(pstate, datum->location)));
5283+
}
5284+
}
5285+
else
5286+
{
5287+
if (cmpval > 0)
5288+
{
5289+
datum = list_nth(spec->upperdatums, abs(cmpval) - 1);
5290+
ereport(ERROR,
5291+
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
5292+
errmsg("upper bound of partition \"%s\" is greater than upper bound of split partition",
5293+
relname),
5294+
parser_errposition(pstate, datum->location)));
5295+
}
5296+
}
52695297
}
52705298
}
52715299
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy