From: | Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: String Comparison / Embedded Spaces |
Date: | 2003-07-23 07:29:05 |
Message-ID: | 1058945344.19042.1048.camel@haggis |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, 2003-07-23 at 00:46, Stephan Szabo wrote:
> On Tue, 22 Jul 2003, Ken Schenke wrote:
>
> > Does the PostgreSQL string comparison operator remove embedded spaces in
> > a string before comparing? Here is a query I'm issuing (notice the
> > space between A and C in the first string):
> >
> > select version();
> > select ('A C' < 'AB') as result;
> >
> > the result that comes back is:
> >
> > version
> >
> > -----------------------------------------------------------------------
> > PostgreSQL 7.3.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.2
> > 20030222 (Red Hat Linux 3.2.2-5)
> >
> > result
> > ------
> > f
> >
> > I searched the list archives and could not find a mention of this.
> > Shouldn't the result of the comparison be true, not false?
>
> That depends on the locale you have set for collation. If it's en_US
> (for example) spaces and some symbols don't act like you'd expect.
> 'AB' < 'A B' < 'AC' < 'A C' I believe.
My system is definitely C locale.
template1=# select version();
version
-------------------------------------------------------------------------
PostgreSQL 7.3.3 on i386-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3
(Debian)
(1 row)
template1=# select ('A C' < 'AB') as result;
result
--------
t
(1 row)
--
+-----------------------------------------------------------------+
| Ron Johnson, Jr. Home: ron(dot)l(dot)johnson(at)cox(dot)net |
| Jefferson, LA USA |
| |
| "I'm not a vegetarian because I love animals, I'm a vegetarian |
| because I hate vegetables!" |
| unknown |
+-----------------------------------------------------------------+
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2003-07-23 07:32:43 | Re: 0/1 vs true/false |
Previous Message | Pavel Stehule | 2003-07-23 07:28:18 | Re: birthday calculation |