Peter Eisentraut <peter_e@gmx.net> writes:
> Rene Pijlman writes:
>> Currently the JDBC driver says:
>> - Backend >= 7.2 sorts nulls higher than any other value in a
>> domain. In other words: ascending means nulls at the end,
>> descending means nulls at the start.
>> - Backend < 7.2 puts nulls at the end regardless of sort order.
> That is correct.
Actually it's more complex than that. 7.2 will provide the above-stated
consistent ordering of nulls relative to non-nulls. The problem with
earlier versions is that the ordering of nulls depends on what plan the
optimizer chooses for the query: sorting based on a scan of a btree
index would work the same as is described for 7.2, whereas sorting
based on an explicit sort step would put the nulls at the end (for
either ASC or DESC sort). So there was *no* consistent behavior at all
in prior versions. The fix that's been applied for 7.2 is to make
explicit sorts act the same as indexscans already did.
regards, tom lane