CREATE CAST allows creation of binary-coercible cast to range over domain

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: CREATE CAST allows creation of binary-coercible cast to range over domain
Date: 2024-08-20 09:00:21
Message-ID: 076968e1-0852-40a9-bc0b-117cd3f0e43c@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

CREATE CAST disallows creating a binary-coercible cast to a domain
(because that would bypass checking the domain constraints). But it
allows it if the domain is wrapped inside a range type:

CREATE DOMAIN mydomain AS int4 CHECK (VALUE > 0);
CREATE CAST (int4 AS mydomain) WITHOUT FUNCTION; -- error (ok)

CREATE TYPE mydomainrange AS range (subtype=mydomain);
CREATE CAST (int4range AS mydomainrange) WITHOUT FUNCTION; -- FIXME

SELECT int4range(-5,-4)::mydomainrange; -- this succeeds

This particular case seems straightforward to fix, but maybe there are
also cases with more nesting to consider.

(I just found this while exploring other range-over-domain issues in
some in-progress work.)

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrei Lepikhov 2024-08-20 09:43:57 Re: BUG #18576: Using EXPLAIN (VERBOSE) in information_schema.element_types returns ERROR: failed to find plan for
Previous Message Sindhu S 2024-08-20 03:37:18 Re: Report Postgres Bug - Unlogged table sequence