If it helps, from source(backend/parser/parse_relation.c):
"
Search the query's table namespace for an RTE matching the
given unqualified refname. Return the RTE if a unique match, or NULL
if no match. Raise error if multiple matches.
Note: it might seem that we shouldn't have to worry about the possibility
of multiple matches; after all, the SQL standard disallows duplicate table
aliases within a given SELECT level. Historically, however, Postgres has
been laxer than that. For example, we allow
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". However,
if tab3 is a LATERAL subquery, then from within the subquery both "x"es
are visible. Rather than rejecting queries that used to work, we allow
this situation, and complain only if there's actually an ambiguous
reference to "x".
"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…