space required before negative

From: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: space required before negative
Date: 2016-03-03 17:16:24
Message-ID: CAEzk6fcmZeh4c9zK2PW_MpALX0fhaU9Lt7SNOcDJrv3b84V_Wg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

I was surprised to find that whitespace is required between the !=
operator and a negative sign, otherwise postgres believes that I'm
intending !=- as an operator (I get "operator does not exist: integer
!=- integer").

This isn't the case with <>-x.

Is this intentional? I couldn't find reference to it in the
documentation (certainly not in
http://www.postgresql.org/docs/9.5/static/functions-comparison.html)

db=# SELECT 'yes' WHERE 1!=-1;
ERROR: operator does not exist: integer !=- integer
LINE 1: SELECT 'yes' WHERE 1!=-1;
^
HINT: No operator matches the given name and argument type(s). You
might need to add explicit type casts.
Time: 0.608 ms

db=# SELECT 'yes' WHERE 1<>-1;
?column?
----------
yes
(1 row)

I get this with fieldnames too, so it's not just a parsing-literal problem...

This is on 9.5, also on 9.5.1.

Geoff

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2016-03-03 17:30:33 Re: space required before negative
Previous Message Rémi Cura 2016-03-03 17:15:32 Re: bloated postgres data folder, clean up