Re: Handling NULL records in plpgsql

Поиск
Список
Период
Сортировка
От Dave Gudeman
Тема Re: Handling NULL records in plpgsql
Дата
Msg-id 7b079fba0810251335v724d9e7ejed63053a42b6c95d@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Handling NULL records in plpgsql  ("Robert Haas" <robertmhaas@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: "Robert Haas"
Дата:
Сообщение: Re: Handling NULL records in plpgsql
Следующее
От: Guillaume Lelarge
Дата:
Сообщение: Re: WIP : change tablespace for a database