Re: No error when FROM is missing in subquery

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>,"mike" <mike(at)thegodshalls(dot)com>
Cc: "Thomas H(dot)" <me(at)alternize(dot)com>, "Jaime Casanova" <systemguards(at)gmail(dot)com>, <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: No error when FROM is missing in subquery
Date: 2006-12-19 15:19:26
Message-ID: 4587AE9E.EE98.0025.0@wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

>>> On Mon, Dec 18, 2006 at 11:48 PM, in message
<15735(dot)1166507302(at)sss(dot)pgh(dot)pa(dot)us>,
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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 }... ]
;

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2006-12-19 15:23:14 Re: No error when FROM is missing in subquery
Previous Message Kevin Macdonald 2006-12-19 15:17:56 BUG #2842: Installation procedure