Re: Proposition to use '==' as synonym for 'IS NOT DISTINCT FROM' - Mailing list pgsql-hackers

From Geoff Winkless
Subject Re: Proposition to use '==' as synonym for 'IS NOT DISTINCT FROM'
Date
Msg-id CAEzk6ffDsV04J-OdE0qLLtkfBpNhqp-i1d3vc7E-vj7M8sgA5Q@mail.gmail.com
Whole thread Raw
In response to Re: Proposition to use '==' as synonym for 'IS NOT DISTINCT FROM'  (Andrew Dunstan <andrew.dunstan@2ndquadrant.com>)
List pgsql-hackers
On Mon, 28 Oct 2019 at 13:31, Andrew Dunstan
<andrew.dunstan@2ndquadrant.com> wrote:
> How about instead of new operators we just provide a nice shorthand way
> of saying these? e.g. ARE and AINT :-)

Seems to me like this is something that those users who want it can
implement for themselves with little to no effort without forcing the
change on everyone else.

CREATE OR REPLACE FUNCTION fnnotdistinctfrom(anyelement, anyelement)
RETURNS boolean LANGUAGE SQL AS $_$
  SELECT CASE WHEN $1 IS NOT DISTINCT FROM $2 THEN true ELSE false END;
$_$;
CREATE OR REPLACE FUNCTION fndistinctfrom(anyelement, anyelement)
RETURNS boolean LANGUAGE SQL AS $_$
  SELECT CASE WHEN $1 IS DISTINCT FROM $2 THEN true ELSE false END;
$_$;
CREATE OPERATOR == (
  PROCEDURE = fnnotdistinctfrom,
  LEFTARG=anyelement,
  RIGHTARG=anyelement,
  NEGATOR = =!
);
CREATE OPERATOR =! (
  PROCEDURE = fndistinctfrom,
  LEFTARG = anyelement,
  RIGHTARG = anyelement,
  NEGATOR = ==
);

I'm at a loss to understand why anyone would want to implement what is
basically a personal preference for syntactic sugar at the system
level. There's not even the advantage of other-system-compatibility.

Geoff



pgsql-hackers by date:

Previous
From: Thunder
Date:
Subject: Re:Re:Re: [BUG] standby node can not provide service even itreplays all log files
Next
From: Asif Rehman
Date:
Subject: Re: WIP/PoC for parallel backup