From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: pgsql-bugs@postgresql.org
To: rikard.pavelic@zg.htnet.hr
Subject: Re: BUG #6701: IS NOT NULL doesn't work on complex composites
Date: Wed, 20 Jun 2012 14:08:15 -0500
Message-ID: <4FE1D94F0200002500048824@gw.wicourts.gov> (raw)
In-Reply-To: <E1ShNDt-00005k-8t@wrigleys.postgresql.org>
References: <E1ShNDt-00005k-8t@wrigleys.postgresql.org>
<rikard.pavelic@zg.htnet.hr> wrote:
> --This doesn't work as expected
> select * from bad where c is not null;
Are you seeing any behavior which does not match the documentation
and the standard?
http://www.postgresql.org/docs/current/interactive/functions-comparison.html
says:
| Note: If the expression is row-valued, then IS NULL is true when
| the row expression itself is null or when all the row's fields are
| null, while IS NOT NULL is true when the row expression itself is
| non-null and all the row's fields are non-null. Because of this
| behavior, IS NULL and IS NOT NULL do not always return inverse
| results for row-valued expressions, i.e., a row-valued expression
| that contains both NULL and non-null values will return false for
| both tests. This definition conforms to the SQL standard, and is a
| change from the inconsistent behavior exhibited by PostgreSQL
| versions prior to 8.2.
When using a NULL test with a row-value, it can help to imagine the
word "ENTIRELY" right after the word IS. The above query will only
return a row from "bad" if the row value "c" IS [ENTIRELY] NOT NULL
-- in other words, any NULL in the row causes it to be excluded.
Moving the NOT in front of the IS results in a test for rows from
"bad" where it is NOT true that row value "c" IS [ENTIRELY] NULL.
That works for me, anyway. Some find the rules around NULL
illogical and argue for just memorizing them as a set of facts
rather than trying to make sense of them.
-Kevin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: Kevin.Grittner@wicourts.gov, rikard.pavelic@zg.htnet.hr
Subject: Re: BUG #6701: IS NOT NULL doesn't work on complex composites
In-Reply-To: <4FE1D94F0200002500048824@gw.wicourts.gov>
References: <E1ShNDt-00005k-8t@wrigleys.postgresql.org> <4FE1D94F0200002500048824@gw.wicourts.gov>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox