Re: NULL safe equality operator

From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: Michael Glaesemann <grzm(at)myrealbox(dot)com>
Cc: Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: NULL safe equality operator
Date: 2005-11-25 08:11:40
Message-ID: 4386C73C.2070408@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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;

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Glaesemann 2005-11-25 08:15:30 Re: NULL safe equality operator
Previous Message Christopher Kings-Lynne 2005-11-25 08:06:46 Re: NULL safe equality operator