]> granicus.if.org Git - postgresql/commit
Re-allow duplicate aliases within aliased JOINs.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 11 Nov 2013 15:42:57 +0000 (10:42 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 11 Nov 2013 15:42:57 +0000 (10:42 -0500)
commit648bd05b13b3624e494ae2996c2d2e0241cefe87
treefa49fe965c8c425d69c123a49e34bb55d2fcb2bd
parent705556a631c5908cd3caa0b973be13d994ff63e7
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.
src/backend/parser/parse_clause.c
src/backend/parser/parse_relation.c
src/test/regress/expected/join.out
src/test/regress/sql/join.sql