Subject: Re: btree_gin: Incorrect leftmost interval value

From: Heikki Linnakangas <[email-masked]>
Date: Fri, 27 Oct 2023 15:42:52 +0300

On 27/10/2023 12:26, Dean Rasheed wrote:
> In contrib/btree_gin, leftmostvalue_interval() does this:
> 
> leftmostvalue_interval(void)
> {
>      Interval   *v = palloc(sizeof(Interval));
> 
>      v->time = DT_NOBEGIN;
>      v->day = 0;
>      v->month = 0;
>      return IntervalPGetDatum(v);
> }
> 
> which is a long way short of the minimum possible interval value.

Good catch!

> Attached is a patch fixing this by setting all the fields to their
> minimum values, which is guaranteed to be less than any other
> interval.

LGTM. I wish extractQuery could return "leftmost" more explicitly, so 
that we didn't need to construct these leftmost values. But I don't 
think that's supported by the current extractQuery interface.

-- 
Heikki Linnakangas
Neon (https://neon.tech)