CREATE CAST allows creation of binary-coercible cast to range over domain - Mailing list pgsql-bugs

From Peter Eisentraut
Subject CREATE CAST allows creation of binary-coercible cast to range over domain
Date
Msg-id 076968e1-0852-40a9-bc0b-117cd3f0e43c@eisentraut.org
Whole thread Raw
Responses Re: CREATE CAST allows creation of binary-coercible cast to range over domain
List 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.)



pgsql-bugs by date:

Previous
From: Sindhu S
Date:
Subject: Re: Report Postgres Bug - Unlogged table sequence
Next
From: Andrei Lepikhov
Date:
Subject: Re: BUG #18576: Using EXPLAIN (VERBOSE) in information_schema.element_types returns ERROR: failed to find plan for