Re: Handling NULL records in plpgsql - Mailing list pgsql-hackers

From Dave Gudeman
Subject Re: Handling NULL records in plpgsql
Date
Msg-id 7b079fba0810251335v724d9e7ejed63053a42b6c95d@mail.gmail.com
Whole thread Raw
In response to Re: Handling NULL records in plpgsql  ("Robert Haas" <robertmhaas@gmail.com>)
List pgsql-hackers
On Sat, Oct 25, 2008 at 11:59 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> I really think we should have a way of telling if a array/row/record
> variable is actually set to something, and I'm pretty sure that should be
> unrelated to whether all the elements in it happen to be null.

+1.  Also, can whatever syntax we introduce by something relatively
concise?  Code that looks nice when you write "=" does not look as
nice when you write "IS NOT DISTINCT FROM".  I'm almost inclined to
suggest using functional notation rather than dreaming up a new "IS
WHATEVER" syntax.

I've always thought that IS should be used for this. That is:

x IS y

is equivalent to

x=y OR (x IS NULL AND y IS NULL)

and

x IS NOT y

is equivalent to

x <> y AND (x IS NOT NULL OR y IS NOT NULL)

If you define the IS operator like this then IS NULL is no longer an operator. It is just the IS operator with the NULL literal as the second operand.

pgsql-hackers by date:

Previous
From: "Robert Haas"
Date:
Subject: Re: Handling NULL records in plpgsql
Next
From: Guillaume Lelarge
Date:
Subject: Re: WIP : change tablespace for a database