pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #6270: Invalid string comparison if the string contains '+' or '-' sign.
2+ messages / 2 participants
[nested] [flat]

* BUG #6270: Invalid string comparison if the string contains '+' or '-' sign.
@ 2011-10-25 15:37 Evgeniy Galkin <unikoid@gmail.com>
  2011-10-25 18:13 ` Re: BUG #6270: Invalid string comparison if the string contains '+' or '-' sign. Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Evgeniy Galkin @ 2011-10-25 15:37 UTC (permalink / raw)
  To: pgsql-bugs


The following bug has been logged online:

Bug reference:      6270
Logged by:          Evgeniy Galkin
Email address:      unikoid@gmail.com
PostgreSQL version: 9.0.4
Operating system:   GNU/Linux (Ubuntu 10.10)
Description:        Invalid string comparison if the string contains '+' or
'-' sign.
Details: 

I'm running postgresql 9.0.4 on GNU/Linux system.
I'm trying to compare two strings which are starting with '+' and '-' signs.
And there is some strange behaviour.

Example:
Query "SELECT '+' > '-';" returns t (true), but "SELECT '+1' > '-2';"
returns f (false). And query "SELECT ascii('+') > ascii('-');" returns f as
it should be, so saying that '+' > '-' is true probably is not valid
result.

More complex example:
db=> create table tbl_tmp (a text); insert into tbl_tmp values ('+'), ('-'),
('+1'), ('+2'), ('+3'), ('-1'), ('-2'), ('-3'); select * from tbl_tmp order
by a;
CREATE TABLE
INSERT 0 8
 a  
----
 -
 +
 -1
 +1
 -2
 +2
 -3
 +3
(8 rows)


This behaviour is also appeared on postgresql 9.1.1 on ubuntu 11.10, but the
same version of psql on Mac OS X Lion works as expected ("SELECT '+' > '-';"
returns f and example with order by gives at first values that are starting
with '+' and at last that are starting with '-' sign).

So, I think that it can be GNU/Linux (maybe glibc) related bug.

Sorry for probably ugly English or if it is duplication of well known issue.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #6270: Invalid string comparison if the string contains '+' or '-' sign.
  2011-10-25 15:37 BUG #6270: Invalid string comparison if the string contains '+' or '-' sign. Evgeniy Galkin <unikoid@gmail.com>
@ 2011-10-25 18:13 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2011-10-25 18:13 UTC (permalink / raw)
  To: Evgeniy Galkin <unikoid@gmail.com>; +Cc: pgsql-bugs

"Evgeniy Galkin" <unikoid@gmail.com> writes:
> I'm trying to compare two strings which are starting with '+' and '-' signs.
> And there is some strange behaviour.

This is fairly standard if you're using a non-C locale.  Try creating a
fresh database with LC_COLLATE and LC_CTYPE set to 'C'.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2011-10-25 18:13 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-10-25 15:37 BUG #6270: Invalid string comparison if the string contains '+' or '-' sign. Evgeniy Galkin <unikoid@gmail.com>
2011-10-25 18:13 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox