Re: Re: Table name scope (was Re: [BUGS] Outer joins aren't working with views) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Re: Table name scope (was Re: [BUGS] Outer joins aren't working with views)
Date
Msg-id 11255.977343134@sss.pgh.pa.us
Whole thread Raw
In response to Re: Re: Table name scope (was Re: [BUGS] Outer joins aren't working with views)  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> ISTM that correlation names aren't allowed after joined tables in the
> first place.

>          <table reference> ::=
>                 <table name> [ [ AS ] <correlation name>
>                     [ <left paren> <derived column list> <right paren> ] ]
>               | <derived table> [ AS ] <correlation name>
>                     [ <left paren> <derived column list> <right paren> ]
>               | <joined table>

>          <joined table> ::=
>                 <cross join>
>               | <qualified join>
>               | <left paren> <joined table> <right paren>

Keep looking:
        <derived table> ::= <table subquery>
        <table subquery> ::= <subquery>
        <subquery> ::= <left paren> <query expression> <right paren>
        <query expression> ::=               <non-join query expression>             | <joined table>

So you can writeSELECT A.* FROM (A NATURAL JOIN B) J
but inSELECT A.* FROM A NATURAL JOIN B J
the J will be taken as an alias for B not for the join.  If they allowed
an alias clause on an unparenthesized <joined table>, the grammar would
be ambiguous...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Who is a maintainer of GiST code ?
Next
From: "Martin A. Marques"
Date:
Subject: problems with query