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

From Kim Johan Andersson
Subject Re: Support functions for range types
Date
Msg-id 313e94ac-1c29-6a61-f09b-1389af012306@kimmet.dk
Whole thread Raw
In response to Re: Support functions for range types  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Support functions for range types
List pgsql-general
On 25-09-2022 16:43, Tom Lane wrote:
> 
> 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 was suspecting that it would not be possible. So we can peek at the 
constructor parameters, but we won't know the actual value until execution.

> 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.
> 

I was hoping it was possible to rely on the existing range mechanics for 
handling the data types. Along the lines of adding nodes dependent on 
the result of the constructor call.
But if there is no opportunity to make a dynamic expression suitable for 
the index, then I guess it won't be possible to make a really useful 
support function for range types.
Thanks for the input.

    Regards,
        Kim Johan Andersson



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Support functions for range types
Next
From: Laurenz Albe
Date:
Subject: Re: Support functions for range types