Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xSyVl-000000000RD-3KIO for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Nov 2026 15:20:50 +0000 Received: from localhost ([127.0.0.1]:53100 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xSyVk-00000001q9L-3Jov for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Nov 2026 15:20:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:57394) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xSvlk-000000011hE-0dNg for pgsql-bugs@lists.postgresql.org; Mon, 16 Nov 2026 12:25:08 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xSvlh-00000001K7l-25II for pgsql-bugs@lists.postgresql.org; Mon, 16 Nov 2026 12:25:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=/D1m1akPwwHmuRhCAuTcNSGZBzyDIJbLD3cxucAwtHQ=; b=aRpEfymHxdSc+nnmEpM1qc1ev5 iWjZbqTEUSN0Qn6JSiOqp66uplZd6/2G8pYpb0ufgsOiA+HbB8zQuvTBmN7HZlkop7hyUlrEUnGIm 9xDKARuTfoiaDQWc+yOPFsErkEUbVJEModCsLFdvNW08OM6ZBRsYl3JRR9nh12eKC5lduLmIa4q7Y Km4CdGRRMN1Ut6CQGdyVPJdKmDLKa6cCpslnJiDMGHVbeMcKGjQRNjEFWeRQRlEYRG+y8RufszQpL /sOsxYbqaoqZPZw588qiQqjzpv03K47zCdXvH/gNwPrdHt1F/AgXP6MfnSMfmb9sUnttMLPvmQIbI VkYvYPtg==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xSvlf-00000003PiZ-3fRA for pgsql-bugs@lists.postgresql.org; Mon, 16 Nov 2026 12:25:04 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xSvlf-00000008aGN-0N35 for pgsql-bugs@lists.postgresql.org; Mon, 16 Nov 2026 12:25:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19907: INSERT through partitioned table fails with domain-typed generated column To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: hello@bjornpagen.com Reply-To: hello@bjornpagen.com, pgsql-bugs@lists.postgresql.org Date: Mon, 16 Nov 2026 12:24:25 +0000 Message-ID: <19907-7d313da9297e91f2@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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: =20 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.