Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id D41E9B5DBE1 for ; Tue, 25 Oct 2011 12:38:01 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 16570-04 for ; Tue, 25 Oct 2011 15:38:01 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id CA604B5DBE0 for ; Tue, 25 Oct 2011 12:38:00 -0300 (ADT) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id p9PFbxEZ000210 for ; Tue, 25 Oct 2011 15:37:59 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p9PFbxVn000209; Tue, 25 Oct 2011 15:37:59 GMT (envelope-from www) Date: Tue, 25 Oct 2011 15:37:59 GMT Message-Id: <201110251537.p9PFbxVn000209@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #6270: Invalid string comparison if the string contains '+' or '-' sign. From: "Evgeniy Galkin" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201110/239 X-Sequence-Number: 31509 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.