Re: comparing NEW and OLD (any good this way?)

From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: comparing NEW and OLD (any good this way?)
Date: 2009-08-12 14:14:31
Message-ID: 572fb76a-e1ef-4c11-951f-0ba49b7dd3f0@mm
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sam Mason wrote:

> Nope, I still don't get it. Why treat rows specially? If this was
> true, then what should:
>
> SELECT a IS NULL, a IS NOT NULL
> FROM (SELECT ARRAY [1,NULL]) x(a);
>
> evaluate to? As "part of it" is NULL and part isn't then, by your
> reasoning, it should return TRUE for both. PG doesn't and I think this
> is much more useful behavior.

But IS NULL applied to an array is useless to test if there are null values
inside, whereas this is apparently the whole point of IS NULL applied to
rows.
I mean:
select a is null from (select array[null]) x(a);
returns false, as well as:
select a is null from (select array[1]) x(a);

When applied to rows, if you consider that:
- is null applied to a row means that all columns are null
- is not null applied to a row means that all columns are not null
which is what the standard seems to dictate, then these operators make sense
and are probably useful in some situations.

Now there is the unfortunate consequence that (r is null) is not equivalent
to (not (r is not null)), yet it's not the standard's fault if "not all
values are null" is not the same as "all values are not null", that's just
set logic.

Maybe they could have made this easier for us by naming the operators
differently, such as "is entirely null" and "is entirely not null"

Best regards,
--
Daniel
PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2009-08-12 14:40:04 Re: comparing NEW and OLD (any good this way?)
Previous Message Tom Lane 2009-08-12 13:48:53 Re: Best way to "mask" password in DBLINK