Re: doesn't recognize "!=-" (not equal to a negative value) - Mailing list pgsql-general

From hubert depesz lubaczewski
Subject Re: doesn't recognize "!=-" (not equal to a negative value)
Date
Msg-id 9e4684ce0607130055g612984easaa0535ce4a68e525@mail.gmail.com
Whole thread Raw
In response to Re: doesn't recognize "!=-" (not equal to a negative value)  (Paul Tilles <Paul.Tilles@noaa.gov>)
List pgsql-general
On 7/11/06, Paul Tilles <Paul.Tilles@noaa.gov> wrote:
Yes.  That works.  I think that the parser should work properly either way.

it works properly. just the proper way of functioning is not the one you would like to have.
you can simply add this operator:

CREATE FUNCTION not_equals_minus(int8, int8) RETURNS bool AS $BODY$
    SELECT $1 <> -$2;
$BODY$ LANGUAGE SQL IMMUTABLE STRICT;

CREATE OPERATOR !=- (
     leftarg = int8,
     rightarg = int8,
     procedure = not_equals_minus,
     commutator = !=-
);


and then:
> select 1!=-2;
 ?column?
----------
 t
(1 row)

depesz

pgsql-general by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: Delete Problem
Next
From: Bill Moran
Date:
Subject: Re: db clustering?