"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.
> 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
-Infinitynormal values+Infinityother types of NaNNULL
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...
regards, tom lane