BUG #19907: INSERT through partitioned table fails with domain-typed generated column

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: hello(at)bjornpagen(dot)com
Subject: BUG #19907: INSERT through partitioned table fails with domain-typed generated column
Date: 2026-11-16 12:24:25
Message-ID: 19907-7d313da9297e91f2@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 19907
Logged by: Bjorn Pagen
Email address: hello(at)bjornpagen(dot)com
PostgreSQL version: Unsupported/Unknown
Operating system: macOS 27 (arm64)
Description:

On master (7fc2f04233), an INSERT through a partitioned table fails if
a CHECK constraint reads a stored generated column of a domain type:

CREATE DOMAIN d AS int;
CREATE TABLE p (k int, g d GENERATED ALWAYS AS (k * 2) STORED CHECK (g >
0))
PARTITION BY RANGE (k);
CREATE TABLE p1 PARTITION OF p FOR VALUES FROM (1) TO (10);
INSERT INTO p (k) VALUES (1);
ERROR: attribute 2 of type record has wrong type
DETAIL: Table has type integer, but query expects d.

The same happens when an index expression or predicate reads g. A
plain table, or an INSERT directly into p1, works.

This comes from 7c87284940: expand_insert_targetlist() now fills g
with a NULL of the domain's base type, and since the tuple is routed
without being copied into a slot of the table's rowtype, the CHECK
sees an integer where it expects d. With that commit reverted, the
INSERT works. I'll follow up with a patch.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bjorn Pagen 2026-11-16 12:38:45 Re: BUG #19907: INSERT through partitioned table fails with domain-typed generated column
Previous Message Daniel Gustafsson 2026-11-16 12:23:11 Re: BUG #19905: loread() with length near INT_MAX: "invalid memory alloc request size" (int32 overflow)