GiST multirange index scans can fail to return rows

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Subject: GiST multirange index scans can fail to return rows
Date: 2026-08-01 15:01:52
Message-ID: CAH2-Wzm1GpQ9qixP=Xs2TYdfnLM88OZ=yUFHNuajS_W7U90-tQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The attached regression test patch (written by Claude Code) shows that
a GiST index on a multirange column can fail to return rows during
scans that use the contained-by operator.

The multirangetypes test already runs every GiST query twice, once
with a sequential scan and once with the index, and the two must
agree. The added query asks for rows contained in
'{[1,11),[21,31),[41,51)}', which is a value the test table already
contains. The sequential scan returns 501 and the index scan returns
500. The row it loses has a multirange that exactly matches the one
from the query.

The multirange GiST support was added by db6335b5b. This is an issue
on 14 and up.

--
Peter Geoghegan

Attachment Content-Type Size
0001-Add-regression-test-for-multirange-GiST-containment-.patch application/octet-stream 4.7 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Pierre Forstmann 2026-08-01 15:09:51 Re: [PATCH] Doc: Mention OFF as an alias for EXPLAIN SERIALIZE NONE
Previous Message Hannu Krosing 2026-08-01 13:08:48 ANSI SQL proposal: SELECT DISTINCT ON (... ORDER BY ...) and UNION DISTINCT ON (... ORDER BY ...)