Re: Operators on ranges with a domain subtype do not implicitly cast operands of the domain's base type

From: Bryn Llewellyn <bryn(at)yugabyte(dot)com>
To: Daniel Popowich <dpopowich(at)artandlogic(dot)com>
Cc: pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>, david(dot)g(dot)johnston(at)gmail(dot)com
Subject: Re: Operators on ranges with a domain subtype do not implicitly cast operands of the domain's base type
Date: 2022-06-16 20:40:56
Message-ID: F5165B09-1F48-47C0-BD8C-0B617337BFC0@yugabyte.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> dpopowich(at)artandlogic(dot)com <mailto:dpopowich(at)artandlogic(dot)com> wrote:
>
> I'm using PG 14 and have an application using a custom range with a custom domain subtype. My problem: PG does not do an implicit cast from the domain's base type when used with range operators.

I hit what looks to be the same issue. I reported in here:

https://www.postgresql.org/message-id/37D76918-6FD7-4598-A409-A7091687D8E6@yugabyte.com <https://www.postgresql.org/message-id/37D76918-6FD7-4598-A409-A7091687D8E6@yugabyte.com>

David Johnston said that he thought that it was a bug.

My workaround is to typecast the two operands explicitly back to their base types.

I don't think that there's any magic to fix it declaratively. My guess is that you might work around it with a user-defined operator for the domains in question that hides the typecasts in its implementation function. (This has worked for me in other cases for other reasons. But I didn't try that in my testcase.)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Abdul Qoyyuum 2022-06-17 02:38:57 Re:
Previous Message Tom Lane 2022-06-16 20:26:39 Re: Operators on ranges with a domain subtype do not implicitly cast operands of the domain's base type