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 4846958c24bc8ef72eebebcf615c240e
Whole thread
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: The Hermit Hacker
Date:
Subject: Re: [HACKERS] Compilation flags
Next
From: Sean Lyndersay
Date:
Subject: Re: [HACKERS] NULL field records handling in order clause