From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> |
Cc: | gkokolatos(at)pm(dot)me, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Strange behavior with polygon and NaN |
Date: | 2020-11-24 17:29:41 |
Message-ID: | 290594.1606238981@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> writes:
> At Fri, 20 Nov 2020 15:57:46 -0500, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Daniil Zakhlystov | 2020-11-24 17:34:39 | Re: libpq compression |
Previous Message | Tomas Vondra | 2020-11-24 17:29:05 | Re: PoC/WIP: Extended statistics on expressions |