| From: | shihao zhong <zhong950419(at)gmail(dot)com> |
|---|---|
| To: | Kirill Reshke <reshkekirill(at)gmail(dot)com> |
| Cc: | 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-25 04:29:41 |
| Message-ID: | CAGRkXqSYJbL_s6iCpq-GCUR8bfCdF57Q8knJZA9M228nPvDo1g@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Hi Kirill,
> But I cannot reproduce any wrong results with unpatched binary for
> KNN.
It does fail on master. Your points lie on one line and the query is at
the origin, so the low corner is always the closest point of a box. Try
a grid:
CREATE TABLE knn (p point);
INSERT INTO knn SELECT point(x, y)
FROM generate_series(0, 99) x, generate_series(0, 99) y;
INSERT INTO knn VALUES ('(NaN,NaN)');
CREATE INDEX ON knn USING gist (p);
SET enable_seqscan = off;
SELECT p FROM knn ORDER BY p <-> point '(99,99)' LIMIT 1;
Master returns (92,99), v5 returns (99,99). With a NaN high corner,
computeDistance() falls to the vertex case and returns the distance to
the low corner. That is too big for a query point inside the box. The
new union code alone fixes fresh indexes. Without the distance hunk, an
index built by master still gives the same wrong answers.
> So, v4 keeps point <@ polygon and point <@ circle losing NaN points
> that the heap returns.
0003 looks right to me, it just needs pgindent. Your circle test passes
without the circle hunk though, its failure on master comes from 0002.
A NaN point only matches a circle when it also has an infinity and the
radius is infinite.
The root of the polygon case is point_inside(), which puts (NaN,NaN)
inside every polygon, even '((0,0))'. Changing that changes query
results, so I'd leave it for a separate master only patch.
Thanks,
Shihao
| From | Date | Subject | |
|---|---|---|---|
| Next Message | shihao zhong | 2026-09-25 04:37:21 | Re: BUG #19714: pgcrypto pgp_sym_encrypt accepts nonnumeric s2k-mode as mode 0 |
| Previous Message | Manu | 2026-09-25 01:04:41 | Re: BUG #19715: pg_restore_attribute_stats() rejects range statistics for a domain over int4multirange |