Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XqmaX-0003gm-V2 for pgsql-bugs@arkaria.postgresql.org; Tue, 18 Nov 2014 17:29:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XqmaX-0008FR-FM for pgsql-bugs@arkaria.postgresql.org; Tue, 18 Nov 2014 17:29:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XqmaW-0008FL-My for pgsql-bugs@postgresql.org; Tue, 18 Nov 2014 17:29:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XqmaR-0001ju-Jk for pgsql-bugs@postgresql.org; Tue, 18 Nov 2014 17:29:09 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id sAIHT3iP002469; Tue, 18 Nov 2014 12:29:03 -0500 From: Tom Lane To: kunert@cms.hu-berlin.de cc: pgsql-bugs@postgresql.org Subject: Re: BUG #12000: "CROSS JOIN" not equivalent to "," In-reply-to: <20141118171126.2479.55006@wrigleys.postgresql.org> References: <20141118171126.2479.55006@wrigleys.postgresql.org> Comments: In-reply-to kunert@cms.hu-berlin.de message dated "Tue, 18 Nov 2014 17:11:26 +0000" Date: Tue, 18 Nov 2014 12:29:03 -0500 Message-ID: <2468.1416331743@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org kunert@cms.hu-berlin.de writes: > Still not sure if this is really a bug, but I could not find a good > explanation for the following behaviour: > According to the documentation > http://www.postgresql.org/docs/9.3/static/queries-table-expressions.html > (7.2.1.1): > "FROM T1 CROSS JOIN T2 is equivalent to FROM T1, T2" > However, in the following example the SQL-Query using "CROSS JOIN" works, > while the usage of "," results in an invalid reference: It's not a bug. The quoted statement is correct as far as it goes, but what it fails to point out is that CROSS JOIN has a different syntactic priority from ",", which matters when you have more than two tables. Fully parenthesized, your examples would look like > from > ((table1 a cross join table1 b) > left outer join table2 c on a.x = y and b.x = z); > from > table1 a > , (table1 b left outer join table2 c on a.x = y and b.x = z); so that table "a" is within the scope of the ON clause in the first case but not the second. I'm not sure we ought to dive into these syntactic details right at that point in the manual, though; it's not really on point for what we're trying to explain there, and could easily make the text less comprehensible not more so. A simple "fix" would be to remove the claim about "," and just compare CROSS JOIN to INNER JOIN ON TRUE. I'm not really convinced that's an improvement ... regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs