count() bug in trivial self join - Mailing list pgsql-bugs

From John Foderaro
Subject count() bug in trivial self join
Date
Msg-id 200102261859.KAA17723@tiger.franz.com
Whole thread Raw
Responses Re: count() bug in trivial self join  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
from: john foderaro, jkf@franz.com

platform: x86 running Redhat 6.2 Linux from rpm
          postgresql-server-6.5.3-6

postgresql version: 6.5.3  (my guess based on rpm name).

problem: count() return the wrong result given a very simple join:

sample: we create a table of 3 elements and join it with itself creating
a table of 9 elements.  select shows the correct rows but count(*)
can't count them, it returns 3 rather than 9.


jkf=> drop table foo;
DROP
jkf=> create table foo(a int);
CREATE
jkf=> insert into foo values(1);
INSERT 18729 1
jkf=> insert into foo values(2);
INSERT 18730 1
jkf=> insert into foo values(3);
INSERT 18731 1
jkf=> select * from foo;
a
-
1
2
3
(3 rows)

jkf=> select * from foo aa, foo bb;
a|a
-+-
1|1
2|1
3|1
1|2
2|2
3|2
1|3
2|3
3|3
(9 rows)

jkf=> select count(*) from foo aa, foo bb;
count
-----
    3        <<<<<<<<<<<<<<<<<<< should be 9 .....................
(1 row)

jkf=> \q

pgsql-bugs by date:

Previous
From: "Dmitry G . Mastrukov"
Date:
Subject: postgresql-7.1beta5 with Heimdal-0.3e
Next
From: "And. Andruikhanov"
Date:
Subject: create type and backend terminate