Re: possible mis-handling of nulls in views in 7.0.2 - Mailing list pgsql-bugs

From Tom Lane
Subject Re: possible mis-handling of nulls in views in 7.0.2
Date
Msg-id 7856.984442151@sss.pgh.pa.us
Whole thread Raw
In response to possible mis-handling of nulls in views in 7.0.2  (Mark Stosberg <mark@summersault.com>)
List pgsql-bugs
Mark Stosberg <mark@summersault.com> writes:
>    I'm running Postgres 7.0.2 and have run into a curious situation. I
> got a back a null value in a select on VIEW that is defined as not
> allowing that column to be null.

I think this is an artifact of the curious (not to say broken)
implementation of views pre-7.1.  However, it's hard to tell for sure
because I can't reproduce your problem.  Are you sure you are running
7.0.2 and not something older?  Can you provide a self-contained
example?  My test went like this:

play=> select version();
                             version
------------------------------------------------------------------
 PostgreSQL 7.0.2 on hppa2.0-hp-hpux10.20, compiled by gcc 2.95.2
(1 row)

play=> create table foo (f1 int, f2 int);
CREATE
play=> insert into foo values(1,2);
INSERT 873546 1
play=> insert into foo values(1,3);
INSERT 873547 1
play=> insert into foo values(2,4);
INSERT 873548 1
play=> insert into foo values(2,5);
INSERT 873549 1
play=> create view v2 as select f1,sum(f2) from foo where f1 notnull group by f1;
CREATE 873571 1
play=> select * from v2 ;
 f1 | sum
----+-----
  1 |   5
  2 |   9
(2 rows)

play=> select * from v2 where f1 isnull;
 f1 | sum
----+-----
(0 rows)

            regards, tom lane

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: pgDump sequence dump bug
Next
From: Ian Lance Taylor
Date:
Subject: Re: [HACKERS] Re: Depending on system install scripts (was Re: COBOL)