Re: Support functions for range types - Mailing list pgsql-general

From Tom Lane
Subject Re: Support functions for range types
Date
Msg-id 2714336.1664117031@sss.pgh.pa.us
Whole thread Raw
In response to Support functions for range types  (Kim Johan Andersson <kimjand@kimmet.dk>)
Responses Re: Support functions for range types
List pgsql-general
Kim Johan Andersson <kimjand@kimmet.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



pgsql-general by date:

Previous
From: Kim Johan Andersson
Date:
Subject: Support functions for range types
Next
From: Kim Johan Andersson
Date:
Subject: Re: Support functions for range types