Thread: intersect bug

intersect bug

From
Jan Vitek
Date:
Hi,

============================================================================
                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================


Your name        : Jan Vitek
Your email address    : jvit8627@ss1000.ms.mff.cuni.cz


System Configuration
---------------------
  Architecture (example: Intel Pentium)      : AMD Pentium

  Operating System (example: Linux 2.0.26 ELF)     : Linux 2.2.10 ELF

  PostgreSQL version (example: PostgreSQL-6.5.3): PostgreSQL-6.5.3

  Compiler used (example:  gcc 2.8.0)        : gcc 2.7.2.3


Please enter a FULL description of your problem:
------------------------------------------------

Intersect operator doesn't work as it would under some circumstances,
which i describe below.

I have found this simplest example:

$ psql data <<EOF
create table num (n int4);
insert into num values (1);
insert into num values (null);
select * from num intersect select * from num;
select distinct * from num intersect select * from num;
drop table num;
EOF
create table num (n int4);
CREATE
insert into num values (1);
INSERT 448713 1
insert into num values (null);
INSERT 448714 1
select * from num intersect select * from num;
n
-
1

(2 rows)

select distinct * from num intersect select * from num;
n
-
1
(1 row)

drop table num;
DROP
$

I think that the result of the second select is wrong and should be the
same as the result of the first select. This behaviour happens only,
when there is a null in some field.

Jan Vitek <jvit8627@ss1000.ms.mff.cuni.cz>