CREATE CAST allows creation of binary-coercible cast to range over domain
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-bugs <pgsql-bugs@postgresql.org>
Date: 2024-08-20T09:00:21Z
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.)
Commits
-
Disallow creating binary-coercible casts involving range types.
- 86488cdf1249 18.0 landed
- 2366ab246a32 17.0 landed