BUG #4076: "IS NOT NULL (IS NULL)" return wrong answer even where all fields are NULL(or NOT NULL).

From: "Tatsuhito Kasahara" <kasahara(dot)tatsuhito(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #4076: "IS NOT NULL (IS NULL)" return wrong answer even where all fields are NULL(or NOT NULL).
Date: 2008-04-01 09:56:55
Message-ID: 200804010956.m319uts5022521@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 4076
Logged by: Tatsuhito Kasahara
Email address: kasahara(dot)tatsuhito(at)oss(dot)ntt(dot)co(dot)jp
PostgreSQL version: 8.1.11
Operating system: Red Hat Enterprise Linux 5.1
Description: "IS NOT NULL (IS NULL)" return wrong answer even where
all fields are NULL(or NOT NULL).
Details:

I noticed that "IS NOT NULL" and "IS NULL" return wrong answer in following
case.

=====================================================
CREATE TABLE tbl (i int, j int);
INSERT INTO tbl VALUES (1, 2);
INSERT INTO tbl VALUES (1, NULL);
INSERT INTO tbl VALUES (NULL, 2);
INSERT INTO tbl VALUES (NULL, NULL);
SELECT * FROM (SELECT * FROM tbl) AS row WHERE row IS NOT NULL;
i | j
---+---
1 | 2
1 |
| 2
|
(4 rows)

SELECT * FROM (SELECT * FROM tbl) AS row WHERE row IS NULL;
i | j
---+---
(0 rows)
=====================================================

Then PostgreSQL used "Filter: (ROW(i, j) IS NOT NULL)" and "Filter: (ROW(i,
j) IS NULL)".

"SELECT * FROM tbl WHERE ROW(i,j) IS NOT NULL;" and "SELECT * FROM tbl WHERE
ROW(i,j) IS NULL" seemed right action.

=====================================================
SELECT * FROM tbl WHERE ROW(i,j) IS NOT NULL;
i | j
---+---
1 | 2
1 |
| 2
(3 rows)

SELECT * FROM tbl WHERE ROW(i,j) IS NULL;
i | j
---+---
|
(1 row)
=====================================================

Is this a bug?

# And 8.2.x and 8.3.x seemed to be all right in the case of action both
"(x)AS row WHERE row IS NOT NULL" and "(x) AS row WHERE row IS NULL". I
think
following fix is related..

http://archives.postgresql.org/pgsql-committers/2006-09/msg00439.php

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Ronald Prins 2008-04-01 10:41:02 BUG #4077: Error 42704
Previous Message uri 2008-04-01 08:47:25 BUG #4075: PostgreSQL Database Server 8.2 failed to start