Re: btree_gist: Fix NaN handling in float4 and float8 opclasses

From: Tender Wang <tndrwang(at)gmail(dot)com>
To: Ewan Young <kdbase(dot)hack(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: btree_gist: Fix NaN handling in float4 and float8 opclasses
Date: 2026-06-17 09:56:24
Message-ID: CAHewXNkxQXK+47Du_veTqg5nkOPtkLRAi7-eb9svBNJLR7o3kw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Ewan Young <kdbase(dot)hack(at)gmail(dot)com> 于2026年6月17日周三 16:40写道:
>
> Hi,
>
> A GiST index on a float4/float8 column (via btree_gist) can silently
> omit rows containing NaN, returning different results from a sequential
> scan:
>
> CREATE EXTENSION btree_gist;
> CREATE TABLE t (a float8);
> INSERT INTO t SELECT 1 FROM generate_series(1, 1000);
> INSERT INTO t SELECT 'NaN' FROM generate_series(1, 1000);
> CREATE INDEX ON t USING gist (a);
>
> SET enable_seqscan = on;
> SELECT count(*) FROM t WHERE a = 'NaN'; -- 1000
> SET enable_seqscan = off;
> SELECT count(*) FROM t WHERE a = 'NaN'; -- 0 (wrong)
>

It seems the issue you reported is the same as [1].
Please double-check.

[1] https://www.postgresql.org/message-id/19501-3bff3bbc97f1e7c9%40postgresql.org

--
Thanks,
Tender Wang

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2026-06-17 10:23:07 Re: use of SPI by postgresImportForeignStatistics
Previous Message Ajin Cherian 2026-06-17 09:19:19 Re: [PATCH] Preserve replication origin OIDs in pg_upgrade