Re: Handling NULL records in plpgsql

From: "Dave Gudeman" <dave(dot)gudeman(at)gmail(dot)com>
To: "Robert Haas" <robertmhaas(at)gmail(dot)com>
Cc: Decibel! <decibel(at)decibel(dot)org>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Postgres Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Handling NULL records in plpgsql
Date: 2008-10-25 20:35:35
Message-ID: 7b079fba0810251335v724d9e7ejed63053a42b6c95d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Oct 25, 2008 at 11:59 AM, Robert Haas <robertmhaas(at)gmail(dot)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.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Guillaume Lelarge 2008-10-25 21:41:03 Re: WIP : change tablespace for a database
Previous Message Robert Haas 2008-10-25 18:59:07 Re: Handling NULL records in plpgsql