Geoff Winkless <pgsqladmin@geoff.dj> writes:
> 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).
That's a syntax issue, so the place to look is
http://www.postgresql.org/docs/9.5/static/sql-syntax-lexical.html#SQL-SYNTAX-OPERATORS
In general you need whitespace between adjacent operator names, but
we hacked the lexer enough so that you can get away without it
in the single case of a prefix "+" or "-", so long as the previous
operator name contains only characters used in SQL operator names.
It would likely have been cleaner to just disallow operator names
ending in "+" or "-", but we had several long-established names that
failed to conform to that, so this was the best compromise we could
come up with between flexibility and SQL standard compliance.
regards, tom lane