From: | Åsmund Kveim Lie <asmundkl(at)skipthis(dot)ifi(dot)uio(dot)no> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Cartesian product bug? |
Date: | 2003-10-29 17:22:22 |
Message-ID: | oprxtejkclemun9e@news.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
We have found a possible bug in 7.3.1. It seems that using CROSS JOIN and
doing plain Cartesian product, listing to tables in the from clause, gives
different results. According to the documentation this should be
equivalent. The following example should explain the problem:
CREATE TABLE a (a1 text, a2 text);
CREATE TABLE b (b1 text, b2 text);
CREATE TABLE c (a1 text, b1 text, c1 text);
INSERT INTO a VALUES('a1', 'a2');
INSERT INTO b VALUES('b1', 'b2');
INSERT INTO c VALUES('a3', 'b1', 'c1');
SELECT * FROM a,b NATURAL JOIN c;
a1 | a2 | b1 | b2 | a1 | c1
----+----+----+----+----+----
a1 | a2 | b1 | b2 | a3 | c1
(1 row)
SELECT * FROM a CROSS JOIN b NATURAL JOIN c;
a1 | b1 | a2 | b2 | c1
----+----+----+----+----
(0 rows)
These two example queries should give the same result. In the first query,
it seems like it’s doing the natural join between b and c, and then does
the Cartesian product on that result with a. On the second query, it does
as we assume it should, namely does the Cartesian product first.
Is this the correct behavior?
Regards
Åsmund
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2003-10-29 17:38:02 | Re: Performace question |
Previous Message | Tom Lane | 2003-10-29 17:19:51 | Re: Performace question |