aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_clause.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2013-11-11 10:43:00 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2013-11-11 10:43:00 -0500
commit04e6ee40206fa61dc856bf2840ce6bb198d5200c (patch)
tree1b02114159fbb2e889fbaa370dc13d118d159ae4 /src/backend/parser/parse_clause.c
parent8e41c621a625f154e96f40ce688a036520cb59aa (diff)
downloadpostgresql-04e6ee40206fa61dc856bf2840ce6bb198d5200c.tar.gz
postgresql-04e6ee40206fa61dc856bf2840ce6bb198d5200c.zip
Re-allow duplicate aliases within aliased JOINs.
Although the SQL spec forbids duplicate table aliases, historically we've allowed queries like SELECT ... FROM tab1 x CROSS JOIN (tab2 x CROSS JOIN tab3 y) z on the grounds that the aliased join (z) hides the aliases within it, therefore there is no conflict between the two RTEs named "x". The LATERAL patch broke this, on the misguided basis that "x" could be ambiguous if tab3 were a LATERAL subquery. To avoid breaking existing queries, it's better to allow this situation and complain only if tab3 actually does contain an ambiguous reference. We need only remove the check that was throwing an error, because the column lookup code is already prepared to handle ambiguous references. Per bug #8444.
Diffstat (limited to 'src/backend/parser/parse_clause.c')
-rw-r--r--src/backend/parser/parse_clause.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index 64c423c9d0a..a9ecc2399db 100644
--- a/src/backend/parser/parse_clause.c
+++ b/src/backend/parser/parse_clause.c
@@ -721,14 +721,15 @@ transformFromClauseItem(ParseState *pstate, Node *n,
* we always push them into the namespace, but mark them as not
* lateral_ok if the jointype is wrong.
*
+ * Notice that we don't require the merged namespace list to be
+ * conflict-free. See the comments for scanNameSpaceForRefname().
+ *
* NB: this coding relies on the fact that list_concat is not
* destructive to its second argument.
*/
lateral_ok = (j->jointype == JOIN_INNER || j->jointype == JOIN_LEFT);
setNamespaceLateralState(l_namespace, true, lateral_ok);
- checkNameSpaceConflicts(pstate, pstate->p_namespace, l_namespace);
-
sv_namespace_length = list_length(pstate->p_namespace);
pstate->p_namespace = list_concat(pstate->p_namespace, l_namespace);