Thread
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
-
Fix incorrect column name in error message for range partition bound check
myzhen <zhenmingyang@yeah.net> — 2026-01-07T05:44:46Z
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. -
Re: Fix incorrect column name in error message for range partition bound check
zhibin wang <killerwzb@gmail.com> — 2026-01-07T05:55:18Z
Hi myzhen, On Wed, Jan 7, 2026 at 1:48 PM myzhen <zhenmingyang@yeah.net> wrote: > > 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. > Yes, I think you are correct. It seems that this is an error prompt caused by the infinite boundary values MINVALUE and MAXVALUE. By the way, based on the context, once a column is set to MINVALUE or MAXVALUE, the values of the remaining columns must be the same. However, I noticed that 'validateInfiniteBounds' is only invoked after all boundary value transformations are completed. Perhaps we can perform the validity check for infinite boundary values earlier. In this way, we can not only avoid this error but also achieve timely "short-circuit" — because any non-MINVALUE transformation performed after MINVALUE is essentially meaningless overhead. ideas?
-
Re:Re: Fix incorrect column name in error message for range partition bound check
myzhen <zhenmingyang@yeah.net> — 2026-01-07T09:50:28Z
Hi zhibin, By the way, based on the context, once a column is set to MINVALUE or MAXVALUE, the values of the remaining columns must be the same. However, I noticed that 'validateInfiniteBounds' is only invoked after all boundary value transformations are completed. Perhaps we can perform the validity check for infinite boundary values earlier. In this way, we can not only avoid this error but also achieve timely "short-circuit" — because any non-MINVALUE transformation performed after MINVALUE is essentially meaningless overhead. ideas? Thanks, I think it makes some sense, so I tried to make the second version.
-
Re:Re: Re: Fix incorrect column name in error message for range partition bound check
myzhen <zhenmingyang@yeah.net> — 2026-01-08T12:03:41Z
Um, yes, as long as this problem can be solved, that's fine. patch v2 may do less and reduce unnecessary transforms, but the impact on DDL is minimal and may not need to be considered. At 2026-01-08 08:36:06, "Eden Wang" <wanglintao_cn@163.com> wrote: Hi myzhen, Hmmm...personally, I prefer the first patch – it resolves this issue and is more concise. Eden Wang -
Re: Fix incorrect column name in error message for range partition bound check
David Rowley <dgrowleyml@gmail.com> — 2026-01-12T02:45:42Z
On Wed, 7 Jan 2026 at 18:45, myzhen <zhenmingyang@yeah.net> wrote: > postgres=# CREATE TABLE pt_test_colname(a int, b int, c int) PARTITION BY RANGE(a, b); > -- 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 ... (I thought I'd sent this email last week, but I don't see it in the archives or my sent items) I've pushed a fix similar to your v1 patch for this. I used foreach_current_index rather than what you did in your v1. That seems less prone to get broken again in the future if someone were to add additional logic within the loop body. I didn't see any need to do any more than that, so I didn't consider anything your v2 patch did. Thanks for the patch. David