count() bug in trivial self join

From: John Foderaro <jkf(at)franz(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: count() bug in trivial self join
Date: 2001-02-26 18:59:17
Message-ID: 200102261859.KAA17723@tiger.franz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


from: john foderaro, jkf(at)franz(dot)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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Gena Gurchonok 2001-02-26 19:01:37 Re: pg_dump Segmentation fault(core dumped)
Previous Message pgsql-bugs 2001-02-26 18:09:12 Intermittent Regression test failure in create_misc