Re: Issue with point_ops and NaN

From: Julien Rouhaud <rjuju123(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Issue with point_ops and NaN
Date: 2021-03-30 15:39:40
Message-ID: 20210330153940.vmncwnmuw3qnpkfa@nol
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Mar 30, 2021 at 11:02:32AM -0400, Tom Lane wrote:
> Julien Rouhaud <rjuju123(at)gmail(dot)com> writes:
> > On Tue, Mar 30, 2021 at 02:47:05PM +0200, Laurenz Albe wrote:
> >> I'd say that this is certainly wrong:
> >> SELECT point('NaN','NaN') <@ polygon('(0,0),(1,0),(1,1),(0,0)');
> >>
> >> ?column?
> >> ----------
> >> t
> >> (1 row)
>
> > Yeah that's what I think too, but I wanted to have confirmation.
>
> Agreed --- one could make an argument for either 'false' or NULL
> result, but surely not 'true'.

I would think that it should return NULL since it's not inside nor outside the
polygon, but I'm fine with false.

> I wonder if Horiguchi-san's patch [1] improves this case.

Oh I totally missed that patch :(

After a quick look I see this addition in point_inside():

+ /* NaN makes the point cannot be inside the polygon */
+ if (unlikely(isnan(x) || isnan(y)))
+ return 0;

So I would assume that it should fix this case too. I'll check tomorrow.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2021-03-30 15:40:10 Re: Autovacuum on partitioned table (autoanalyze)
Previous Message Daniil Zakhlystov 2021-03-30 15:22:25 Re: libpq compression