Cartesian product bug?

Поиск
Список
Период
Сортировка
От Åsmund Kveim Lie
Тема Cartesian product bug?
Дата
Msg-id oprxtejkclemun9e@news.postgresql.org
обсуждение исходный текст
Ответы Re: Cartesian product bug?
Re: Cartesian product bug?
Список 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/

В списке pgsql-general по дате отправления:

Предыдущее
От: tj
Дата:
Сообщение: duplicates rejected by index reports PGSQL_FATAL_ERROR
Следующее
От: swatts@computer-systems.com (Shaun)
Дата:
Сообщение: selecting information from two tables (problem)