Re: Support functions for range types

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kim Johan Andersson <kimjand(at)kimmet(dot)dk>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Support functions for range types
Date: 2022-09-25 14:43:51
Message-ID: 2714336.1664117031@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Kim Johan Andersson <kimjand(at)kimmet(dot)dk> writes:
> So my question here is, how to go about handling the more interesting
> cases, where we are passed a FuncExpr (instead of a Const)?
> Is it even possible to return something useful in this case?

Doesn't look like it to me. You could check whether the RHS is a
range constructor function call, but there's a big semantic problem:
int4_range(NULL, ...) converts to a range with an infinite bound,
not a null bound. So translating that to "indxvar >= NULL" would
give the wrong answers. And generally speaking, if the argument
isn't a constant then you're not going to be able to be sure that
it doesn't produce NULL.

I guess you could produce something like

indxvar >= coalesce(argument, minimum-value-of-type)

in cases where the data type has an identifiable minimum resp.
maximum value, but that'd make the whole affair annoyingly
data-type-specific. Not sure it's worth going there.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kim Johan Andersson 2022-09-26 04:57:42 Re: Support functions for range types
Previous Message Kim Johan Andersson 2022-09-25 09:35:17 Support functions for range types