Re: BUG #19705: One NaN box makes a BRIN box_inclusion_ops index omit unrelated rows

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Manu <manuelreyesbravo(at)gmail(dot)com>
Cc: Kirill Reshke <reshkekirill(at)gmail(dot)com>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, kehan5800(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19705: One NaN box makes a BRIN box_inclusion_ops index omit unrelated rows
Date: 2026-09-28 07:01:52
Message-ID: CAGRkXqSN7vB_h41_jvsBbDb2sVNW=rmjxpndvL70oCDrYhbh=w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Manu,

Thanks for the matrix.

> Most of what is left is ordering: the index scan fails with
> "inconsistent point values"

computeDistance() assumes low <= high and a query point without NaN.
So this doesn't need NaN rows. On a table with only finite values,
ORDER BY v <-> point '(1,NaN)' fails for all four GiST opclasses.

v6-0004 gives distance 0 to keys and query points with a NaN, as 0002
already does for internal keys. A box_ops leaf must be exact, and
index-only scans can't recheck, so it calls the operator instead.
With your script, GiST has 9 mismatches left on master, all point <@
polygon with a NaN vertex. GiST indexes built by unpatched master give
the same.

0001 to 0003 are v5. 0003 is Kirill's polygon and circle patch after
pgindent.

> palloc_object(), which 18 does not have

18 has it. The conflict comes from 1b105f9472b, which changed those
lines in 19.

> I have not checked whether the patch there covers NaN too.

It doesn't. The v2 there leaves NaN on the same error on purpose.

Regards,
Shihao

Attachment Content-Type Size
v6-0002-Fix-GiST-box-indexes-hiding-rows-next-to-a-NaN-bo.patch application/octet-stream 13.8 KB
v6-0004-Fix-GiST-KNN-searches-with-a-NaN-in-a-key-or-the-.patch application/octet-stream 6.7 KB
v6-REL_18-0001-Fix-BRIN-box_inclusion_ops-hiding-rows-next-to-a-.patch.nocfbot application/octet-stream 5.6 KB
v6-0003-Check-for-NaN-point-in-GiST-polygon-and-circle-se.patch application/octet-stream 6.2 KB
v6-0001-Fix-BRIN-box_inclusion_ops-hiding-rows-next-to-a-.patch application/octet-stream 13.0 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Daniel Gustafsson 2026-09-28 13:13:41 Re: autovacuum: automatically propagate updated parameters
Previous Message shihao zhong 2026-09-28 06:37:43 Re: PostgreSQL 18.6/17.11: standby PANIC on restart after VM truncation