public inbox for [email protected]
help / color / mirror / Atom feedFrom: myzhen <[email protected]>
To: [email protected]
Subject: Fix incorrect column name in error message for range partition bound check
Date: Wed, 7 Jan 2026 13:44:46 +0800 (CST)
Message-ID: <[email protected]> (raw)
Hi all,
Recently, while working with partitioned tables, I identified an issue where the error message references an incorrect column name when a range-partitioned table’s boundary values include MINVALUE or MAXVALUE.
For example:
postgres=# CREATE TABLE pt_test_colname(a int, b int, c int) PARTITION BY RANGE(a, b);
-- right case
postgres=# CREATE TABLE pt_test_colname_p1 PARTITION OF pt_test_colname FOR VALUES FROM (10, now()) TO (100, 100);
ERROR: specified value cannot be cast to type integer for column "b"
LINE 1: ...PARTITION OF pt_test_colname FOR VALUES FROM (10, now()) TO ...
^
-- wrong case
postgres=# CREATE TABLE pt_test_colname_p1 PARTITION OF pt_test_colname FOR VALUES FROM (minvalue, now()) TO (100, 100);
ERROR: specified value cannot be cast to type integer for column "a"
LINE 1: ...ION OF pt_test_colname FOR VALUES FROM (minvalue, now()) TO ...
^
The datetime value returned by now() cannot be cast to the partition key b (integer type), yet the error message incorrectly attributes this casting failure to column a when the preceding boundary value is the special MINVALUE or MAXVALUE.
Attachments:
[application/octet-stream] v1-0001-Fix-incorrect-column-name-in-error-message-for-range.patch (1.1K, ../[email protected]/3-v1-0001-Fix-incorrect-column-name-in-error-message-for-range.patch)
download | inline diff:
From 11f9f048a40d15ad563e4ca405c7e27ca2ae6e36 Mon Sep 17 00:00:00 2001
From: myzhen <[email protected]>
Date: Tue, 6 Jan 2026 18:42:28 +0800
Subject: [PATCH] Fix incorrect column name in error message for range
partition bound check.
When range partition boundary value lists contain MINVALUE or MAXVALUE, and subsequent
boundary values cannot be implicitly cast to the corresponding partition key data type,
the error message references an incorrect column name.
---
src/backend/parser/parse_utilcmd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index 3f4393b52ea..d739ca96813 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -4841,10 +4841,10 @@ transformPartitionRangeBounds(ParseState *pstate, List *blist,
prd = makeNode(PartitionRangeDatum);
prd->kind = PARTITION_RANGE_DATUM_VALUE;
prd->value = (Node *) value;
- ++i;
}
prd->location = exprLocation(expr);
+ ++i;
result = lappend(result, prd);
}
--
2.28.0.windows.1
view thread (5+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Fix incorrect column name in error message for range partition bound check
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox