Re: Fix picksplit with nan values - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Fix picksplit with nan values
Date
Msg-id 6864.1378504031@sss.pgh.pa.us
Whole thread Raw
In response to Fix picksplit with nan values  (Alexander Korotkov <aekorotkov@gmail.com>)
Responses Re: Fix picksplit with nan values
List pgsql-hackers
Alexander Korotkov <aekorotkov@gmail.com> writes:
> PostGIS spotted that picksplit algorithm freezes in infinite loop when
> dealing with nan values. I discovered same bug is present in core
> opclasses. Attached patch fixes this issue interpreting nan as value
> greater than infinity like btree comparison function does.

Hm.  Good point, but it seems like some of these hunks are only taking
care of a subset of the possible combinations of input NaNs.  If you're
certain the other combinations are impossible, there should be code
comments explaining why.

BTW, as a stylistic matter, I think it sucks to write     !float8_cmp_internal(x,y)
when what you mean is     float8_cmp_internal(x,y) == 0
The "!" syntax should pretty much only be used for boolean tests IMO.

I do recognize that there's a tradition of writing "!ptr" rather than
"ptr == NULL", which I think is all right in most contexts, mainly
because returning a null pointer has an element of boolean yes-or-no-ness
to it.  When you're doing arithmetic comparisons, though, it's just
confusing.

I wrote another rant about this years ago in the context of complaining
about "!strcmp" tests; there was probably more detail in that, if you
care to look in the archives.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [RFC] Extend namespace of valid guc names
Next
From: Andres Freund
Date:
Subject: Re: [PERFORM] encouraging index-only scans