dbTalk Databases Forums  

[BUGS] BUG #2309: Wrong string comparison

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #2309: Wrong string comparison in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Yury Don
 
Posts: n/a

Default [BUGS] BUG #2309: Wrong string comparison - 03-09-2006 , 06:26 PM







The following bug has been logged online:

Bug reference: 2309
Logged by: Yury Don
Email address: yura (AT) vpcit (DOT) ru
PostgreSQL version: 8.1.3
Operating system: Linux (Debian)
Description: Wrong string comparison
Details:

Looks like string comparison operators ignore spaces isnside of string.
Because of this sorting on text fields is wrong.

mdb=# select 'a z'::text>'ad'::text;
?column?
----------
t

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] BUG #2309: Wrong string comparison - 03-09-2006 , 06:49 PM






"Yury Don" <yura (AT) vpcit (DOT) ru> writes:
Quote:
Looks like string comparison operators ignore spaces isnside of string.
It's not wrong, it's just following the rules of the locale. You should
initdb the database with LANG=C if you want plain ASCII sorting.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq


Reply With Quote
  #3  
Old   
Volkan YAZICI
 
Posts: n/a

Default Re: [BUGS] BUG #2309: Wrong string comparison - 03-10-2006 , 01:47 AM



Hi,

On Mar 09 02:00, Yury Don wrote:
Quote:
Looks like string comparison operators ignore spaces isnside of string.
Because of this sorting on text fields is wrong.

mdb=# select 'a z'::text>'ad'::text;
?column?
----------
t
PostgreSQL relies on your locale for collation. Therefore, first you
need to check if your locale settings are working. For instance:

$ TEXT="a z\nad"
$ echo -e $TEXT | LC_COLLATE=tr_TR.iso88599 sort
ad
a z
$ echo -e $TEXT | LC_COLLATE=C sort
a z
ad


Regards.

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster


Reply With Quote
  #4  
Old   
Yury Don
 
Posts: n/a

Default Re: [BUGS] BUG #2309: Wrong string comparison - 03-10-2006 , 08:15 AM



On Friday 10 March 2006 12:36, Volkan YAZICI wrote:
Quote:
Hi,

On Mar 09 02:00, Yury Don wrote:
Looks like string comparison operators ignore spaces isnside of string.
Because of this sorting on text fields is wrong.

mdb=# select 'a z'::text>'ad'::text;
?column?
----------
t

PostgreSQL relies on your locale for collation. Therefore, first you
need to check if your locale settings are working. For instance:

$ TEXT="a z\nad"
$ echo -e $TEXT | LC_COLLATE=tr_TR.iso88599 sort
ad
a z
$ echo -e $TEXT | LC_COLLATE=C sort
a z
ad


Regards.

My locale is KOI8-R and sorting in PostgreSQL corresponds to sorting in
locale. I just didn't expect that sorting will be this way ...

--
Best regards,
Yury Don

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.