Re: [HACKERS] NULL field records handling in order clause - Mailing list pgsql-hackers

From Thomas G. Lockhart
Subject Re: [HACKERS] NULL field records handling in order clause
Date
Msg-id 99ecb3b4541630e51ded6f4b02828766
Whole thread Raw
In response to [HACKERS] NULL field records handling in order clause  (Constantin Teodorescu <teo@flex.ro>)
List pgsql-hackers
Constantin Teodorescu wrote:
> PostgreSQL 6.1 , Linux RedHat 4.2 Kernel 2.0.30
> Selecting all records and ordering ascending and descending on a field :
> template1=> select * from pers order by cod;
> template1=> select * from pers order by cod desc;
> ("cod" fields which are null _always_ show up at the end)

This is an interesting feature. The reason for this behavior is that
"null" fields should (I think) always return FALSE in comparisons, and
the order-by is done using "<" or ">" operators. Remember, "null" is
nothing, *not anything*, and hence is not comparable to anything which
is not null. Even two null values should compare FALSE, I think.

I believe that this is correct behavior. Is anyone aware of anything
goofy in some SQL standards which would have this behave differently??

            - Tom

------------------------------

pgsql-hackers by date:

Previous
From: "Vadim B. Mikheev"
Date:
Subject: [HACKERS] Re: [PORTS] GEQO broken on 6-6-97?!?
Next
From: hakan@twins.iconsult.com (Hakan Tandogan)
Date:
Subject: Re: [HACKERS] Third Party Stuff