Thread: BUG #15317: Sort order error

BUG #15317: Sort order error

From
PG Bug reporting form
Date:
The following bug has been logged on the website:

Bug reference:      15317
Logged by:          sumit pahwa
Email address:      pahwa.sumit@gmail.com
PostgreSQL version: 10.3
Operating system:   Linux
Description:

Version of Postgres deployed
PostgreSQL 10.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623
(Red Hat 4.8.5-16), 64-bit

When I execute a query
select 'ALEX DARGAY' >  'ALEXANDER';
It should return false as output because ascii value of space is lower than
ascii value of 'A'.
But the output is true, which is incorrect.
In a bigger picture, It gives a corrupted sorted order.

However, this works fine on PostgreSQL 10.4, compiled by Visual C++ build
1800, 64-bit

Please suggest.

Thanks


Re: BUG #15317: Sort order error

From
Heikki Linnakangas
Date:
On 08/08/18 09:53, PG Bug reporting form wrote:
> When I execute a query
> select 'ALEX DARGAY' >  'ALEXANDER';
> It should return false as output because ascii value of space is lower than
> ascii value of 'A'.
> But the output is true, which is incorrect.

The correct answer to that query depends on the current locale. You seem 
to be assuming that POSIX / C locale is used. You can check the current 
locale's collation order with "show lc_collate;". The locale support is 
provided by the Operating System, so even if the locale is nominally the 
same, e.g. "UK English", it might behave slightly differently on 
different systems.

See the user manual, sections 23.1 Locale Support and 23.2 Collation 
Support for more information:

https://www.postgresql.org/docs/10/static/locale.html
https://www.postgresql.org/docs/10/static/collation.html

- Heikki