From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: gkokolatos@pm.me
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Strange behavior with polygon and NaN
Date: Tue, 24 Nov 2020 12:29:41 -0500
Message-ID: <290594.1606238981@sss.pgh.pa.us> (raw)
In-Reply-To: <20201124.135544.121959508317571971.horikyota.ntt@gmail.com>
References: <289049.1605284781@sss.pgh.pa.us>
<20201116.151636.571392156451834232.horikyota.ntt@gmail.com>
<1456736.1605905866@sss.pgh.pa.us>
<20201124.135544.121959508317571971.horikyota.ntt@gmail.com>
Kyotaro Horiguchi <horikyota.ntt@gmail.com> writes:
> At Fri, 20 Nov 2020 15:57:46 -0500, Tom Lane <tgl@sss.pgh.pa.us> wrote in
>> I don't much like anything about float8_coef_mul().
> I have the same feeling on the function, but I concluded that
> coefficients and coordinates should be regarded as different things in
> the practical standpoint.
> For example, consider Ax + By + C == 0, if B is 0.0, we can remove the
> second term from the equation, regardless of the value of y, of course
> even if it were inf. that is, The function imitates that kind of
> removals.
Meh --- I can see where you're going with that, but I don't much like it.
I fear that it's as likely to introduce weird behaviors as remove any.
The core of the issue in
> | postgres=# select point(1e+300, 'Infinity') <-> line('{1,0,5}');
> | ?column?
> | ----------
> | NaN
is that we generate the line y = Inf:
(gdb) p tmp
$1 = {A = 0, B = -1, C = inf}
and then try to find the intersection with {1,0,5} (x = -5), but that
calculation involves 0 * Inf so we get NaNs. It seems reasonable that
the intersection should be (-5,Inf), but I don't think we should try
to force the normal calculation to produce that. I think we'd be
better off to explicitly special-case vertical and/or horizontal lines
in line_interpt_line.
Actually though ... even if we successfully got that intersection
point, we'd still end up with a NaN distance between (1e300,Inf) and
(-5,Inf), on account of Inf - Inf being NaN. I think this is correct
and we'd be ill-advised to try to force it to be something else.
Although we pretend that two Infs are equal for purposes such as
sorting, they aren't really, so we should not assume that their
difference is zero.
So that line of thought prompts me to tread *very* carefully when
trying to dodge NaN results. We need to be certain that we
introduce only logically-defensible special cases. Something like
float8_coef_mul() seems much more likely to lead us into errors
than away from them.
regards, tom lane
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: tgl@sss.pgh.pa.us, horikyota.ntt@gmail.com, gkokolatos@pm.me, pgsql-hackers@lists.postgresql.org
Subject: Re: Strange behavior with polygon and NaN
In-Reply-To: <290594.1606238981@sss.pgh.pa.us>
* 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