SQL query syntax question

Поиск
Список
Период
Сортировка
От Alexander Levsha
Тема SQL query syntax question
Дата
Msg-id CA+FA-0pjG4r4WSagO+V3BNyyBeu3fbdc9oKnaqFYDSkXWK+EZA@mail.gmail.com
обсуждение исходный текст
Список pgsql-sql
Hello all.
I'm currently developing an SQL parser/analyzer for internal PostgreSQL tool we use at my workplace.
Naturally, i use psql in conjunction with PostgreSQL documentation to develop and verify my work.

Recently i've noticed the following oddity in query syntax/execution:

select (select c1 from tt) from t1 tt;
--ERROR:  relation "tt" does not exist
--LINE 1: select (select c1 from tt) from t1 tt;

select (select tt.c1 ) from t1 tt;
--c1 
------
--(0 rows)

Why doesn't the first one work when the second one works fine? In other words, why do subquery's traget list and range table list use different namespaces to resolve table references/aliases? Is this an unintended behaviour, implementation detail or is there an actual reason for this? Thanks for your help. Alexander Levsha

В списке pgsql-sql по дате отправления:

Предыдущее
От: Alexander Levsha
Дата:
Сообщение: Re: SQL query syntax question
Следующее
От: Michael Moore
Дата:
Сообщение: Geometry vs Geography (what to use)