public inbox for [email protected]  
help / color / mirror / Atom feed
From: PG Bug reporting form <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: BUG #19442: PL/pgSQL: domain over composite type bypasses type validation when assigning NULL (PostgreSQL 18.3)
Date: Mon, 30 Mar 2026 03:09:12 +0000
Message-ID: <[email protected]> (raw)

The following bug has been logged on the website:

Bug reference:      19442
Logged by:          Xianghang Zheng
Email address:      [email protected]
PostgreSQL version: 18.3
Operating system:   Linux x86_64
Description:        

I found an issue on PostgreSQL 18.3 related to domain handling over
composite types in PL/pgSQL.
After the fix for BUG #18735, the "cache lookup failed for type 0" error no
longer occurs, but a new correctness problem arises:
When assigning a NULL composite variable to a domain over composite type in
PL/pgSQL,
the domain's type validation and coercion logic is bypassed.
This indicates an incomplete fix and may lead to incorrect enforcement of
domain constraints (CHECK, NOT NULL, etc.) in the future.
Version: PostgreSQL 18.3
Test case:
CREATE TYPE comp AS (a int, b text);
CREATE DOMAIN dcomp AS comp;
CREATE OR REPLACE FUNCTION test_domain_bug()
RETURNS dcomp
AS $$
DECLARE
  v_comp  comp := NULL;
  v_dcomp dcomp;
BEGIN
  v_dcomp := v_comp;
  RETURN v_dcomp;
END;
$$ LANGUAGE plpgsql;
SELECT test_domain_bug();
Actual result:  NULL (no error)
Expected result: Domain type coercion should be properly executed even for
NULL values.
This is a regression caused by incomplete backpatch of BUG #18735.








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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: BUG #19442: PL/pgSQL: domain over composite type bypasses type validation when assigning NULL (PostgreSQL 18.3)
  In-Reply-To: <[email protected]>

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

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