On Mon, Aug 21, 2000 at 01:39:32PM -0400, Tom Lane wrote:
> "Ross J. Reedstrom" <reedstrm@rice.edu> writes:
> > While examining the output from ORDER BY queries, both using and not using
> > an index, I came across a discrepancy: the explicit handling of NULLs in
> > the tuplesort case always sorts NULLs to the end, regardless of direction
> > of sort.
>
> Yeah. I think that's widely considered a bug --- we have a TODO item to
> fix it. You might care to dig in the archives for prior discussions.
I'll take a look.
>
> > To make the direct sort the same as the index read would work for NULL,
> > but for NaN would either require allowing NaN to be returned as >
> > Infinity, which doesn't happen now,
>
> Seems to me the sort order should be
>
> -Infinity
> normal values
> +Infinity
> other types of NaN
> NULL
>
> and the reverse in a descending sort.
>
> > or add another ordering operator that is only used for the sort case
> > (use of '>' and '<' seems to be hardcoded all the way to the parser)
>
> don't even think about that...
Sure, but any ideas _how_ to get 'NaN > +Infinity' to happen only during a
sort operation, and not when '>' is called explicity as a WHERE condition,
by touching only type specific code? 'Cause I'd call it a bug to be able
to say:
SELECT * from foo where f8 > 'Infinity';
and get anything at all back.
NULL is taken care of by special casing in the sort code, as I already mentioned,
and can be fixed immediately.
Ross
--
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005