Obscure behavior of ORDER BY - Mailing list pgsql-sql

From Tambet Matiisen
Subject Obscure behavior of ORDER BY
Date
Msg-id 4D871A6E.6050608@gmail.com
Whole thread Raw
Responses Re: Obscure behavior of ORDER BY  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-sql
Hi everyone!

I recently noticed obscure behavior of ORDER BY. Consider this example:

select email from
(
select '@'::text as email
union all
select '.'::text as email
) a
order by email;

The result is: email
------- . @
(2 rows)

This is all normal - I expect, that dot is smaller than ampersand. But 
if I add anything after dot, the order is reversed:

select email from
(
select '@'::text as email
union all
select '.m'::text as email
) a
order by email

The result is: email
------- @ .m
(2 rows)

Why is this happening? As dot is smaller than ampersand, anything after 
dot shouldn't matter.

I'm using PostgreSQL 8.4.7 on 32-bit Debian.

Thanks in advance,  Tambet


pgsql-sql by date:

Previous
From: Serdar Gül
Date:
Subject: Re: xml2 support
Next
From: Rob Sargent
Date:
Subject: xml2 support