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

From: myzhen <zhenmingyang(at)yeah(dot)net>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Fix incorrect column name in error message for range partition bound check
Date: 2026-01-07 05:44:46
Message-ID: 273cab52.978.19b96fc75e7.Coremail.zhenmingyang@yeah.net
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

Attachment Content-Type Size
v1-0001-Fix-incorrect-column-name-in-error-message-for-range.patch application/octet-stream 1.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirill Reshke 2026-01-07 05:55:03 Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)
Previous Message Michael Paquier 2026-01-07 05:32:42 Re: Sequence Access Methods, round two