Search Postgresql Archives

Re: any way for ORDER BY x to imply NULLS FIRST in 8.3?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



rihad <rihad@xxxxxxx> writes:
> Is there any way to "hardcode" the NULL handling in an index (as  per 
> http://www.postgresql.org/docs/8.3/static/indexes-ordering.html) so that 
> SELECT * FROM t ORDER BY foo automatically implies NULLS FIRST (and, 
> similarly so that SELECT * FROM t ORDER BY foo DESC automatically 
> implies NULLS LAST)?

No.  This is not a question of how indexes behave, it is a question of
which semantics the parser ascribes to an undecorated ORDER BY request.

> Thing is, I'm using PHP Symfony/Propel to generate 
> their SQL and have no easy way to influence how they do so.

SQL99 section 14.1 <declare cursor> saith:

              ... Whether
              a sort key value that is null is considered greater or less
              than a non-null value is implementation-defined, but all sort
              key values that are null shall either be considered greater
              than all non-null values or be considered less than all non-
              null values. ...

Essentially the same text appears in SQL2003.  Any application that
depends on one particular choice here is therefore broken, or at least
has chosen to work with only about half of the DBMSes in the world.

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux