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-17 13:45:02 |
Message-ID: | edf18cbf-b085-472f-b7dd-36c46bd50bc7@mm |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Greg Stark wrote:
> Why is this thread still going on?
Sorry, it's still going on. Call me a slow learner if you want :)
> What does the spec say we should be
> doing and are we violating it in any of these cases?
After a bit more reading, I believe the bottom line is:
while the spec says that if X is the null value, then "X is null" evaluates
to true,
it doesn't say that if "X is null" is true, then X is the null value. And
that's the catch.
Once digested the (counter-intuitive) rule that "X is null" should never be
confused with "X is the null value", then PG's behavior suddenly feels
consistant.
For example, when evaluating "X is distinct FROM null", the fact that "X is
null" returns true is irrelevant and is not considered. What is tested is
whether X evaluates to null or not.
The spec says "A null value and a non-null value are distinct".
Since "A null value" is NOT equivalent to "an expression on which IS NULL
returns true", the fact that "ROW(null,null) is distinct FROM null" evaluates
to true doesn't violate the spec.
I believe the implication of this weirdness for SQL programmers is that when
we feel like using "IS NULL" and rowtypes are involved, we should think hard
about what we really want to test and possibly use "IS DISTINCT FROM NULL"
rather than "IS NULL".
Best regards,
--
Daniel
PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Verite | 2009-08-17 13:59:36 | Re: comparing NEW and OLD (any good this way?) |
Previous Message | Sam Mason | 2009-08-17 13:11:17 | Re: Generating random unique alphanumeric IDs |