SQL query syntax question - Mailing list pgsql-sql

From Alexander Levsha
Subject SQL query syntax question
Date
Msg-id CALVauw3b4XPEzO0+GB1yjmN3Lm_9d5W_C2gWGcYid65W32Oo7Q@mail.gmail.com
Whole thread Raw
Responses Re: SQL query syntax question  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-sql
<div dir="ltr"><span style="font-size:12.8px">Hello all.</span><div style="font-size:12.8px">I'm currently developing
anSQL parser/analyzer for internal PostgreSQL tool we use at my workplace.</div><div
style="font-size:12.8px">Naturally,i use psql in conjunction with PostgreSQL documentation to develop and verify my
work.</div><divstyle="font-size:12.8px"><br /></div><div style="font-size:12.8px">Recently i've noticed the following
oddityin query syntax/execution:</div><div style="font-size:12.8px"><br /></div><div style="font-size:12.8px"><pre
style="white-space:pre-wrap;color:rgb(0,0,0);word-wrap:break-word">select(select c1 from tt) from t1 tt; 
--ERROR:  relation "tt" does not exist
--LINE 1: select (select c1 from tt) from t1 tt;</pre><pre
style="white-space:pre-wrap;color:rgb(0,0,0);word-wrap:break-word"><br/></pre><pre
style="white-space:pre-wrap;word-wrap:break-word"><pre
style="white-space:pre-wrap;color:rgb(0,0,0);word-wrap:break-word">select(select tt.c1 ) from t1 tt; 
--c1
------
--(0 rows)</pre><pre style="white-space:pre-wrap;color:rgb(0,0,0);word-wrap:break-word"><font face="arial, helvetica,
sans-serif"><br/></font></pre><font face="arial, helvetica, sans-serif">Why doesn't the first one work when the second
oneworks fine? In other words, why do subquery's traget list and range table list use different namespaces to resolve
tablereferences/aliases? 
Is this an unintended behaviour, implementation detail or is there an actual reason for this?

Thanks for your help.
Alexander Levsha</font></pre></div></div>

pgsql-sql by date:

Previous
From: Selina Tech
Date:
Subject: Re: how plsql work on postgresql
Next
From: "David G. Johnston"
Date:
Subject: Re: SQL query syntax question