Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1a02eda

Browse files
committed
Give a good error message for what's likely to be a common syntax error,
namely omitting the alias clause for a sub-SELECT in FROM.
1 parente832ae3 commit1a02eda

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

‎src/backend/parser/gram.y

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.216 2001/01/17 17:26:45 momjian Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.217 2001/01/20 17:37:52 tgl Exp $
1515
*
1616
* HISTORY
1717
* AUTHORDATEMAJOR EVENT
@@ -3604,10 +3604,6 @@ from_list: from_list ',' table_ref{ $$ = lappend($1, $3); }
36043604
* between table_ref := '(' joined_table ')' alias_clause
36053605
* and joined_table := '(' joined_table ')'. So, we must have the
36063606
* redundant-looking productions here instead.
3607-
*
3608-
* Note that the SQL spec does not permit a subselect (<derived_table>)
3609-
* without an alias clause, so we don't either. This avoids the problem
3610-
* of needing to invent a refname for an unlabeled subselect.
36113607
*/
36123608
table_ref:relation_expr
36133609
{
@@ -3618,6 +3614,23 @@ table_ref: relation_expr
36183614
$1->name =$2;
36193615
$$ = (Node *)$1;
36203616
}
3617+
|select_with_parens
3618+
{
3619+
/*
3620+
* The SQL spec does not permit a subselect
3621+
* (<derived_table>) without an alias clause,
3622+
* so we don't either. This avoids the problem
3623+
* of needing to invent a unique refname for it.
3624+
* That could be surmounted if there's sufficient
3625+
* popular demand, but for now let's just implement
3626+
* the spec and see if anyone complains.
3627+
* However, it does seem like a good idea to emit
3628+
* an error message that's better than "parse error".
3629+
*/
3630+
elog(ERROR,"sub-SELECT in FROM must have an alias"
3631+
"\n\tFor example, FROM (SELECT ...) [AS] foo");
3632+
$$ =NULL;
3633+
}
36213634
|select_with_parensalias_clause
36223635
{
36233636
RangeSubselect *n = makeNode(RangeSubselect);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp