Re: Support functions for range types

From: Kim Johan Andersson <kimjand(at)kimmet(dot)dk>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Support functions for range types
Date: 2022-09-26 04:57:42
Message-ID: 313e94ac-1c29-6a61-f09b-1389af012306@kimmet.dk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message vignesh C 2022-09-26 10:26:07 Re: Support logical replication of DDLs
Previous Message Tom Lane 2022-09-25 14:43:51 Re: Support functions for range types