Re: Allow an alias to be attached directly to a JOIN ... USING

Поиск
Список
Период
Сортировка
От Thomas Munro
Тема Re: Allow an alias to be attached directly to a JOIN ... USING
Дата
Msg-id CA+hUKGLn84tOodRKbpTTS8uMUpZnt-SpUZXXzG36YysR85kz6A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Allow an alias to be attached directly to a JOIN ... USING  (Fabien COELHO <coelho@cri.ensmp.fr>)
Ответы Re: Allow an alias to be attached directly to a JOIN ... USING  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-hackers
On Tue, Jul 16, 2019 at 8:58 AM Fabien COELHO <coelho@cri.ensmp.fr> wrote:
> About the feature:
>
> When using aliases both on tables and on the unifying using clause, the former
> are hidden from view. I cannot say that I understand why, and this makes it
> impossible to access some columns in some cases if there is an ambiguity, eg:
>
>   postgres=# SELECT t.filler
>              FROM pgbench_tellers AS t
>             JOIN pgbench_branches AS b USING (bid) AS x;
>   ERROR:  invalid reference to FROM-clause entry for table "t"
>   LINE 1: SELECT t.filler FROM pgbench_tellers AS t JOIN pgbench_branc...
>                  ^
>   HINT:  There is an entry for table "t", but it cannot be referenced from this
>          part of the query.
>
> But then:
>
>   postgres=# SELECT x.filler
>              FROM pgbench_tellers AS t
>             JOIN pgbench_branches AS b USING (bid) AS x;
>   ERROR:  column reference "filler" is ambiguous
>   LINE 1: SELECT x.filler FROM pgbench_tellers AS t JOIN pgbench_branc...
>                  ^
>
> Is there a good reason to forbid several aliases covering the same table?
>
> More precisely, is this behavior expected from the spec or a side effect
> of pg implementation?

Indeed, that seems like a problem, and it's a good question.  You can
see this on unpatched master with SELECT x.filler FROM
(pgbench_tellers AS t JOIN b USING (bid)) AS x.

I'm moving this to the next CF.

-- 
Thomas Munro
https://enterprisedb.com



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

Предыдущее
От: Thomas Munro
Дата:
Сообщение: Re: Add client connection check during the execution of the query
Следующее
От: Thomas Munro
Дата:
Сообщение: Re: Avoid full GIN index scan when possible