Re: No error when FROM is missing in subquery - Mailing list pgsql-bugs

From Kevin Grittner
Subject Re: No error when FROM is missing in subquery
Date
Msg-id 4587AE9E.EE98.0025.0@wicourts.gov
Whole thread Raw
In response to Re: No error when FROM is missing in subquery  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: No error when FROM is missing in subquery
List pgsql-bugs
>>> On Mon, Dec 18, 2006 at 11:48 PM, in message
<15735.1166507302@sss.pgh.pa.us>,
Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> The reason there's no error thrown is that the reference to mov_id
in
> the sub- SELECT is a perfectly legal outer reference to the mov_id
column
> available from the upper SELECT.  If the column truly did not exist
> anywhere in the tables used in the query, it would have thrown an
error.

It's easy to see how it resolves the column references; but the syntax
is still not compliant with the SQL standard.  The FROM clause is
required.  We could call it a PostgreSQL extension, but I'm curious if
anyone actually finds it useful.  So far it just seems to provide an
opportunity for error.

-Kevin

*scalar_subquery
    :   subquery
    ;

*subquery
    :   LEFT_PAREN query_expression RIGHT_PAREN
    ;

*query_expression
    :   non_join_query_expression
    |   joined_table
    ;

*non_join_query_expression
    :   non_join_query_term
    |   query_expression TK_union [ TK_all ]
        [ corresponding_spec ] query_term
    |   query_expression TK_except [ TK_all ]
        [ corresponding_spec ] query_term
    ;

*non_join_query_term
    :   non_join_query_primary
    |   query_term TK_intersect [ TK_all ]
        [ corresponding_spec ] query_primary
    ;

*non_join_query_primary
    :   simple_table
    |   LEFT_PAREN non_join_query_expression RIGHT_PAREN
    ;

*simple_table
    :   query_specification
    |   table_value_constructor
    |   explicit_table
    ;

*query_specification
    :   TK_select [ set_quantifier ] select_list table_expression
    ;

*select_list
    :   ASTERISK
    |   select_sublist [ { COMMA select_sublist }... ]
    ;

*select_sublist
    :   derived_column
    |   qualifier PERIOD ASTERISK
    ;

*derived_column
    :   value_expression [ as_clause ]
    ;

*as_clause
    :   [ TK_as ] column_name
    ;

*table_expression
    :   from_clause
        [ where_clause ]
        [ group_by_clause ]
        [ having_clause ]
    ;

*from_clause
    :   TK_from table_reference
        [ { COMMA table_reference }... ]
    ;

pgsql-bugs by date:

Previous
From: mike
Date:
Subject: Re: No error when FROM is missing in subquery
Next
From: Tom Lane
Date:
Subject: Re: No error when FROM is missing in subquery