Re: '_' < '5' -- different answer on 7.2 and 7.3 - Mailing list pgsql-hackers

From David Blasby
Subject Re: '_' < '5' -- different answer on 7.2 and 7.3
Date
Msg-id 3F060718.3040902@refractions.net
Whole thread Raw
In response to Re: '_' < '5' -- different answer on 7.2 and 7.3  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Responses Re: '_' < '5' -- different answer on 7.2 and 7.3  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-hackers
> My first guess would be that you're not running in "C" locale
> on the 7.3 system.  I get false on my 7.3.1 system in C locale,
> but if I compare the two strings in C using en_US for example I
> seem to get results like the above ('_'<'5' is true).

It turns out our 7.3 database was somehow initd with local "en_US".

I'm trying to get postgresql and a MS vc++ to communicate.

In postgresql 7.3 (en_US):

toponymy=# select '_' < '5';; ?column?
---------- t
(1 row)


toponymy=# select '_5' < '5'; ?column?
---------- f
(1 row)


But in MS vc++:
TRACE("locale set to 'en_US'\n");setlocale( LC_ALL, "English_United States" );if (strcoll("_5","5") <0 )
TRACE("strcoll('_5','5')--  <0 \n");else    TRACE( "strcoll('_5','5') -- >=0\n");
 

returns:
locale set to 'en_US'
strcoll('_5','5') --  <0


Which is to say postgresql thinks "_5" > "5", but
(a bit strangely) "_" < "5" (the '>' and '<' are reversed).

vc++ thinks "_5" < "5" and "_" < "5".

So, which one is correct and why does the other disagree?

dave




pgsql-hackers by date:

Previous
From: Darcy Buskermolen
Date:
Subject: Re: Proof-of-concept for initdb-time shared_buffers selection
Next
From: Stephan Szabo
Date:
Subject: Re: '_' < '5' -- different answer on 7.2 and 7.3