Re: Fix incorrect column name in error message for range partition bound check - Mailing list pgsql-hackers

From zhibin wang
Subject Re: Fix incorrect column name in error message for range partition bound check
Date
Msg-id CAO1Vn_zMn-daxf9jcSRctcdx6S6QORy=6MnRQ6PaztQ3cucUqQ@mail.gmail.com
Whole thread Raw
In response to Fix incorrect column name in error message for range partition bound check  (myzhen <zhenmingyang@yeah.net>)
Responses Re:Re: Fix incorrect column name in error message for range partition bound check
List pgsql-hackers
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?

pgsql-hackers by date:

Previous
From: Kirill Reshke
Date:
Subject: Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)
Next
From: Chao Li
Date:
Subject: docs: clarify ALTER TABLE behavior on partitioned tables