Inconsistent results from seqscan and gist indexscan

Started by Richard Guoabout 4 years ago4 messages
#1Richard Guo
guofenglinux@gmail.com

Here is how it can be reproduced.

create table point_tbl (f1 point);

insert into point_tbl(f1) values ('(5.1, 34.5)');
insert into point_tbl(f1) values (' ( Nan , NaN ) ');
analyze;

create index gpointind on point_tbl using gist (f1);

set enable_seqscan to on;
set enable_indexscan to off;
# select * from point_tbl where f1 <@ polygon
'(0,0),(0,100),(100,100),(100,0),(0,0)';
f1
------------
(5.1,34.5)
(NaN,NaN)
(2 rows)

set enable_seqscan to off;
set enable_indexscan to on;
# select * from point_tbl where f1 <@ polygon
'(0,0),(0,100),(100,100),(100,0),(0,0)';
f1
------------
(5.1,34.5)
(1 row)

Seems point_inside() does not handle NaN properly.

BTW, I'm using 15devel. But this issue can be seen in at least 12
version also.

Thanks
Richard

#2Julien Rouhaud
rjuju123@gmail.com
In reply to: Richard Guo (#1)
Re: Inconsistent results from seqscan and gist indexscan

Hi,

On Fri, Nov 26, 2021 at 2:10 PM Richard Guo <guofenglinux@gmail.com> wrote:

Seems point_inside() does not handle NaN properly.

This is unfortunately a known issue, which was reported twice ([1]/messages/by-id/CAGf+fX70rWFOk5cd00uMfa__0yP+vtQg5ck7c2Onb-Yczp0URA@mail.gmail.com and
[2]: /messages/by-id/20210330095751.x5hnqbqcxilzwjlm@nol
https://commitfest.postgresql.org/32/2710/ (adding Horiguchi-san in
Cc).

[1]: /messages/by-id/CAGf+fX70rWFOk5cd00uMfa__0yP+vtQg5ck7c2Onb-Yczp0URA@mail.gmail.com
[2]: /messages/by-id/20210330095751.x5hnqbqcxilzwjlm@nol

#3Richard Guo
guofenglinux@gmail.com
In reply to: Julien Rouhaud (#2)
Re: Inconsistent results from seqscan and gist indexscan

On Fri, Nov 26, 2021 at 5:23 PM Julien Rouhaud <rjuju123@gmail.com> wrote:

Hi,

On Fri, Nov 26, 2021 at 2:10 PM Richard Guo <guofenglinux@gmail.com>
wrote:

Seems point_inside() does not handle NaN properly.

This is unfortunately a known issue, which was reported twice ([1] and
[2]) already. There's a patch proposed for it:
https://commitfest.postgresql.org/32/2710/ (adding Horiguchi-san in
Cc).

Ah, I missed the previous threads. Good to know there is a patch fixing
it.

Thanks
Richard

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Richard Guo (#3)
Re: Inconsistent results from seqscan and gist indexscan

Richard Guo <guofenglinux@gmail.com> writes:

On Fri, Nov 26, 2021 at 5:23 PM Julien Rouhaud <rjuju123@gmail.com> wrote:

On Fri, Nov 26, 2021 at 2:10 PM Richard Guo <guofenglinux@gmail.com>
wrote:

Seems point_inside() does not handle NaN properly.

This is unfortunately a known issue, which was reported twice ([1] and
[2]) already. There's a patch proposed for it:
https://commitfest.postgresql.org/32/2710/ (adding Horiguchi-san in
Cc).

Ah, I missed the previous threads. Good to know there is a patch fixing
it.

Note that that patch seems pretty well stalled; if you'd like to
see it move forward, please pitch in and help review.

(Maybe we should scale back the patch's ambitions, and just try
to get the seqscan/indexscan inconsistency fixed.)

regards, tom lane