Re: need help to write a function in postgresql - Mailing list pgsql-admin

From Craig Ringer
Subject Re: need help to write a function in postgresql
Date
Msg-id 501B905E.1050706@ringerc.id.au
Whole thread Raw
In response to Re: need help to write a function in postgresql  (Laszlo Nagy <gandalf@shopzeus.com>)
List pgsql-admin
On 08/03/2012 04:37 PM, Laszlo Nagy wrote:
> It is also better because with a view, you can also do " name is null
> ". But you cannot do that with a function (unless you write
> unnecessary circumstancial code.)
>
While I agree with you on the view - among other things, it lets the
query optimiser push conditions down into the view query - there is a
reasonable answer to the problem of comparing to NULL. Just use IS
DISTINCT FROM, eg:

    WHERE name IS DISTINCT FROM _test_variable

"IS DISTINCT FROM" is an equality comparison that treats null as a
comparable value like any other, so "NULL IS DISTINCT FROM NULL" is
false. Very handy.

--
Craig Ringer

pgsql-admin by date:

Previous
From: Laszlo Nagy
Date:
Subject: Re: need help to write a function in postgresql
Next
From: JC de Villa
Date:
Subject: Re: Messed up time zones