From: Nikita Glukhov <n.gluhov@postgrespro.ru>
To: Alexander Korotkov <aekorotkov@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Darafei Praliaskouski <me@komzpa.net>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Fedor Sigaev <teodor@sigaev.ru>
Subject: Re: compress method for spgist - 2
Date: Thu, 21 Sep 2017 00:57:49 +0300
Message-ID: <60e048d3-aa29-8289-5438-3b0c4c1d8d84@postgrespro.ru> (raw)
In-Reply-To: <CAPpHfduv0XZ_k+D3NoFMr=wFVM22D=wFZCMMswoLwBe2jAbuJw@mail.gmail.com>
References: <54907069.1030506@sigaev.ru>
<CAPpHfdsoy2bJMSTtvQySJ9zN2YJmzWJBLvdHV=ZvMOm6BR0UFg@mail.gmail.com>
<20170920190059.1354.29457.pgcf@coridan.postgresql.org>
<31999.1505938053@sss.pgh.pa.us>
<CAPpHfduv0XZ_k+D3NoFMr=wFVM22D=wFZCMMswoLwBe2jAbuJw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
On 20.09.2017 23:19, Alexander Korotkov wrote:
> On Wed, Sep 20, 2017 at 11:07 PM, Tom Lane <tgl@sss.pgh.pa.us
> <mailto:tgl@sss.pgh.pa.us>> wrote:
>
> Darafei Praliaskouski <me@komzpa.net <mailto:me@komzpa.net>> writes:
> > I have some questions about the circles example though.
>
> > * What is the reason for isnan check and swap of box ordinates
> for circle? It wasn't in the code previously.
>
> I hadn't paid any attention to this patch previously, but this comment
> excited my curiosity, so I went and looked:
>
> + bbox->high.x = circle->center.x + circle->radius;
> + bbox->low.x = circle->center.x - circle->radius;
> + bbox->high.y = circle->center.y + circle->radius;
> + bbox->low.y = circle->center.y - circle->radius;
> +
> + if (isnan(bbox->low.x))
> + {
> + double tmp = bbox->low.x;
> + bbox->low.x = bbox->high.x;
> + bbox->high.x = tmp;
> + }
>
> Maybe I'm missing something, but it appears to me that it's
> impossible for
> bbox->low.x to be NaN unless circle->center.x and/or
> circle->radius is a
> NaN, in which case bbox->high.x would also have been computed as a
> NaN,
> making the swap entirely useless. Likewise for the Y case. There
> may be
> something useful to do about NaNs here, but this doesn't seem like it.
>
> Yeah, +1.
>
It is possible for bbox->low.x to be NaN when circle->center.x is and
circle->radius are both +Infinity. Without this float-order-preserving
swapping
one regression test for KNN with ORDER BY index will be totally broken
(you can
try it: https://github.com/glukhovn/postgres/tree/knn). Unfortunately, I
do not
remember exactly why, but most likely because of the incorrect index
structure.
--
Nikita Glukhov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: n.gluhov@postgrespro.ru, aekorotkov@gmail.com, tgl@sss.pgh.pa.us, me@komzpa.net, hlinnaka@iki.fi, teodor@sigaev.ru
Subject: Re: compress method for spgist - 2
In-Reply-To: <60e048d3-aa29-8289-5438-3b0c4c1d8d84@postgrespro.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox