ERROR: failed to build any 4-way joins - Mailing list pgsql-bugs

From Teodor Sigaev
Subject ERROR: failed to build any 4-way joins
Date
Msg-id 457EFD03.10903@sigaev.ru
Whole thread Raw
Responses Re: ERROR: failed to build any 4-way joins  (Teodor Sigaev <teodor@sigaev.ru>)
Re: ERROR: failed to build any 4-way joins  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Test suite (as simple as I can produce):
CREATE TABLE foo (a int, b int);

INSERT INTO foo VALUES (1,2);
INSERT INTO foo VALUES (2,3);
INSERT INTO foo VALUES (3,3);

CREATE VIEW fooview AS
     SELECT
             f1.a AS a_for_max_b
     FROM
         ( SELECT MAX(foo.b) AS MaxB FROM foo ) f2
         INNER JOIN foo f1
             ON f2.MaxB = f1.b;


And this query fails:
SELECT
     *
FROM
     fooview fv1
     LEFT OUTER JOIN fooview fv2
         ON TRUE = TRUE;

It also fails with RIGHT join, but it doesn't fail with INNER or FULL joins.

If view is defined (essentially the same) as
CREATE VIEW fooview AS
     SELECT
         f1.a AS a_for_max_b
     FROM
         foo f1
     WHERE
         f1.b = (SELECT MAX(f2.b) FROM foo f2);
then all is ok.


--
Teodor Sigaev                                   E-mail: teodor@sigaev.ru
                                                 WWW: http://www.sigaev.ru/

pgsql-bugs by date:

Previous
From: Danish Siddiqui
Date:
Subject: postgresql installation on centOS not working
Next
From: Teodor Sigaev
Date:
Subject: Re: ERROR: failed to build any 4-way joins