Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 44CE4B5DBC9 for ; Wed, 15 Jun 2011 19:12:49 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 69663-10 for ; Wed, 15 Jun 2011 22:12:43 +0000 (UTC) X-Greylist: delayed 00:22:28.289531 by SQLgrey-1.7.6 Received: from e8.ny.us.ibm.com (e8.ny.us.ibm.com [32.97.182.138]) by mail.postgresql.org (Postfix) with ESMTP id DF486B5DBC8 for ; Wed, 15 Jun 2011 19:12:42 -0300 (ADT) Received: from d01relay06.pok.ibm.com (d01relay06.pok.ibm.com [9.56.227.116]) by e8.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p5FLcoRa026343 for ; Wed, 15 Jun 2011 17:38:50 -0400 Received: from d01av05.pok.ibm.com (d01av05.pok.ibm.com [9.56.224.195]) by d01relay06.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p5FLoB6a1708160 for ; Wed, 15 Jun 2011 17:50:12 -0400 Received: from d01av05.pok.ibm.com (loopback [127.0.0.1]) by d01av05.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p5FLoBJ3023171 for ; Wed, 15 Jun 2011 17:50:11 -0400 Received: from d01ml605.pok.ibm.com (d01ml605.pok.ibm.com [9.56.227.91]) by d01av05.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p5FLoB2e023168 for ; Wed, 15 Jun 2011 17:50:11 -0400 Subject: " ::= " grammar rule not accepted by Postgres X-KeepSent: 650DD52B:2DDBF653-852578B0:00699C93; type=4; name=$KeepSent To: pgsql-sql@postgresql.org X-Mailer: Lotus Notes Release 8.5.2 August 10, 2010 Message-ID: From: Clem Dickey Date: Wed, 15 Jun 2011 14:50:09 -0700 X-MIMETrack: Serialize by Router on D01ML605/01/M/IBM(Build V853_CD4_03082011|March 08, 2011) at 06/15/2011 17:50:11 MIME-Version: 1.0 Content-type: multipart/alternative; Boundary="0__=0ABBF223DFFA1A038f9e8a93df938690918c0ABBF223DFFA1A03" Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.909 tagged_above=-5 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201106/58 X-Sequence-Number: 35524 --0__=0ABBF223DFFA1A038f9e8a93df938690918c0ABBF223DFFA1A03 Content-type: text/plain; charset=US-ASCII This expression is (I think) a well-formed query, but is rejected by Postgresql 8.4 (t is a table name). t t1 NATURAL JOIN t t2; Here is the relevant parts of grammar (with some optional elements omitted for simplicity): ::= ::= ::= ::= NATURAL JOIN
::=
::=
[ ]
::=
Nor is this use of accepted in the form of a : WITH tw AS ( t t1 NATURAL JOIN t t2 ) TABLE tw; This leads me to believe that the unrecognized grammar rule (in SQL99 standard terms) is ::= There are, of course, other ways to express the operation, including SELECT * FROM (t t1 NATURAL JOIN t t2); But I am curious why the first expression is not accepted, besides the immediately obvious "it's not in the Postgres version of the SQL grammar." Clem Dickey --0__=0ABBF223DFFA1A038f9e8a93df938690918c0ABBF223DFFA1A03 Content-type: text/html; charset=US-ASCII Content-Disposition: inline

This expression is (I think) a well-formed query, but is rejected by Postgresql 8.4 (t is a table name).

t t1 NATURAL JOIN t t2;

Here is the relevant parts of grammar (with some optional elements omitted for simplicity):

<query expression> ::= <query expression body>

<query expression body> ::= <joined table>

<joined table> ::= <natural join>

<natural join> ::= <table reference> NATURAL JOIN <table primary>

<table reference> ::= <table primary>

<table primary> ::= <table or query name> [ <correlation name> ]

<table or query name> ::= <table name>

Nor is this use of <joined table> accepted in the <query expression> form of a <with list element>:

WITH tw AS ( t t1 NATURAL JOIN t t2 ) TABLE tw;

This leads me to believe that the unrecognized grammar rule (in SQL99 standard terms) is

<query expression body> ::= <joined table>

There are, of course, other ways to express the operation, including
SELECT * FROM (t t1 NATURAL JOIN t t2);
But I am curious why the first expression is not accepted, besides the immediately obvious "it's not in the Postgres version of the SQL grammar."

Clem Dickey --0__=0ABBF223DFFA1A038f9e8a93df938690918c0ABBF223DFFA1A03--