Fix incorrect column name in error message for range partition bound check
myzhen <zhenmingyang@yeah.net>
From: myzhen <zhenmingyang@yeah.net>
To: pgsql-hackers@lists.postgresql.org
Date: 2026-01-07T05:44:46Z
Lists: pgsql-hackers
Attachments
- v1-0001-Fix-incorrect-column-name-in-error-message-for-range.patch (application/octet-stream) patch v1-0001
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.
Commits
-
Fix possible incorrect column reference in ERROR message
- a65995947cfe 14.21 landed
- 3ad05640b67f 15.16 landed
- 821c4d27bca2 16.12 landed
- 84b787ae66e6 17.8 landed
- c35e5dd9ae97 18.2 landed
- 349107537d22 19 (unreleased) landed