Re: Fix incorrect column name in error message for range partition bound check

From: zhibin wang <killerwzb(at)gmail(dot)com>
To: myzhen <zhenmingyang(at)yeah(dot)net>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Fix incorrect column name in error message for range partition bound check
Date: 2026-01-07 05:55:18
Message-ID: CAO1Vn_zMn-daxf9jcSRctcdx6S6QORy=6MnRQ6PaztQ3cucUqQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi myzhen,

On Wed, Jan 7, 2026 at 1:48 PM myzhen <zhenmingyang(at)yeah(dot)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?

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-01-07 05:59:28 docs: clarify ALTER TABLE behavior on partitioned tables
Previous Message Kirill Reshke 2026-01-07 05:55:03 Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)