pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: hello@bjornpagen.com
Subject: BUG #19907: INSERT through partitioned table fails with domain-typed generated column
Date: Mon, 16 Nov 2026 12:24:25 +0000
Message-ID: <19907-7d313da9297e91f2@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      19907
Logged by:          Bjorn Pagen
Email address:      hello@bjornpagen.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.







view thread (2+ messages)  latest in thread

Message-ID: <19907-7d313da9297e91f2@postgresql.org>
Permalink:  ../19907-7d313da9297e91f2@postgresql.org/
Also on:    postgresql.org/message-id/19907-7d313da9297e91f2@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, hello@bjornpagen.com
  Subject: Re: BUG #19907: INSERT through partitioned table fails with domain-typed generated column
  In-Reply-To: <19907-7d313da9297e91f2@postgresql.org>
  References: <19907-7d313da9297e91f2@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox