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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: CREATE CAST allows creation of binary-coercible cast to range over domain
Date: 2024-08-20 17:30:39
Message-ID: 1611527.1724175039@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I wrote:
> I think it's an oversight that we allow binary-coercible casts
> involving range types at all. There are no other nesting cases to
> worry about, because CreateCast already rejects binary-coercible casts
> applied to composites and arrays, explaining
> * We know that composite, enum and array types are never binary-
> * compatible with each other. They all have OIDs embedded in them.
> But range types also embed their own OID, so I don't see why that
> concern doesn't apply to them.

In short, more or less as attached. (I didn't bother with a
regression test, since none of the adjacent error checks are
covered either.)

I'm unsure whether to back-patch this. If somebody were using
such a cast today, it might seem to mostly work, as long as the
two kinds of ranges had the same behavior. So they might not
appreciate us breaking it in a minor release. Maybe we should
put this into 17 but not further back.

regards, tom lane

Attachment Content-Type Size
reject-binary-coercions-on-ranges.patch text/x-diff 1.9 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera from 2ndQuadrant 2024-08-20 18:46:41 Re: BUG #18559: Crash after detaching a partition concurrently from another session
Previous Message Tom Lane 2024-08-20 14:46:15 Re: CREATE CAST allows creation of binary-coercible cast to range over domain