pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Clem Dickey <dickeycl@us.ibm.com>
To: pgsql-sql@postgresql.org
Subject: "<query expression body> ::= <joined table>" grammar rule not accepted by Postgres
Date: Wed, 15 Jun 2011 14:50:09 -0700
Message-ID: <OF650DD52B.2DDBF653-ON852578B0.00699C93-882578B0.0077F2AD@us.ibm.com> (raw)


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

view thread (3+ messages)  latest in thread

Message-ID: <OF650DD52B.2DDBF653-ON852578B0.00699C93-882578B0.0077F2AD@us.ibm.com>
Permalink:  ../OF650DD52B.2DDBF653-ON852578B0.00699C93-882578B0.0077F2AD@us.ibm.com/
Also on:    postgresql.org/message-id/OF650DD52B.2DDBF653-ON852578B0.00699C93-882578B0.0077F2AD@us.ibm.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dickeycl@us.ibm.com
  Subject: Re: "<query expression body> ::= <joined table>" grammar rule not accepted by Postgres
  In-Reply-To: <OF650DD52B.2DDBF653-ON852578B0.00699C93-882578B0.0077F2AD@us.ibm.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox