Re: NULL safe equality operator - Mailing list pgsql-hackers

From Christopher Kings-Lynne
Subject Re: NULL safe equality operator
Date
Msg-id 4386C73C.2070408@familyhealth.com.au
Whole thread Raw
In response to Re: NULL safe equality operator  (Michael Glaesemann <grzm@myrealbox.com>)
List pgsql-hackers
> CREATE OR REPLACE FUNCTION null_safe_cmp (ANYELEMENT, ANYELEMENT)
> RETURNS INTEGER IMMUTABLE
> LANGUAGE SQL AS $$
> SELECT CASE
>     WHEN NOT ($1 IS DISTINCT FROM $2) THEN 1
>     ELSE 0
> END;
> $$;

Even cooler:

CREATE OR REPLACE FUNCTION null_safe_cmp(anyelement, anyelement)
RETURNS integer AS '  SELECT (NOT ($1 IS DISTINCT FROM $2))::integer
' IMMUTABLE LANGUAGE SQL;



pgsql-hackers by date:

Previous
From: Christopher Kings-Lynne
Date:
Subject: Re: NULL safe equality operator
Next
From: Michael Glaesemann
Date:
Subject: Re: NULL safe equality operator