Re: GiST multirange index scans can fail to return rows - Mailing list pgsql-hackers

From Kirill Reshke
Subject Re: GiST multirange index scans can fail to return rows
Date
Msg-id CALdSSPiRxHGfR0yY3OmJSVu+PEAKLUgFUd2U5VNHeAEP0V8Xig@mail.gmail.com
Whole thread
In response to GiST multirange index scans can fail to return rows  (Peter Geoghegan <pg@bowt.ie>)
Responses Re: Heads Up: cirrus-ci is shutting down June 1st
List pgsql-hackers
On Sun, 2 Aug 2026 at 20:30, Alexander Korotkov <aekorotkov@gmail.com> wrote:
>
> Hi Peter,
> Hi Andrey,
>
> On Sun, Aug 2, 2026 at 9:55 AM Andrey Borodin <x4mmm@yandex-team.ru> wrote:
> >
> > > On 2 Aug 2026, at 12:03, Peter Geoghegan <pg@bowt.ie> wrote:
> > >
> > > I think that you forgot to attach the patch with the actual fix?
> >
> > Oops. Sorry.
>
> Peter, thank you for catching this.  Andrey, thank you for the patch.
> Yes, multirange_gist_consistent() re-uses consistent functions from
> range opclass.  And range_gist_consistent_leaf_multirange() generate
> false negatives when applied to union range of multirange.  I've
> rechecked, and it appears to be the only case among the predicates.
>
> Regarding this contained-by case, I think we can build more precise
> test function.  If we have multiranges q and k, and union() produces
> union range from multirange.
>
> q @> r doesn't mean q @> union(r)
> But if q @> r then union(q) @> union(r)
>

Hi!
I reviewed v3.

multirange_contains_union_range function comment contains typo at 'give'

'Every multiranges contains an infinite number of empty multiranges,
even an empty one.' also contain typos

Return statement can be :
return range_cmp_bounds(rangetyp, &lower1, &lower2) <= 0 &&
   range_cmp_bounds(rangetyp, &upper1, &upper2) >= 0;

But I don't insist. Better for my taste.

--
Best regards,
Kirill Reshke



pgsql-hackers by date:

Previous
From: Andrey Borodin
Date:
Subject: Re: GiST multirange index scans can fail to return rows
Next
From: Siddharth Kothari
Date:
Subject: Re: [PATCH] Add RetrieveInstrumentation hook for CustomScan providers