On Tue, Jul 16, 2019 at 8:58 AM Fabien COELHO <coe...@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


Reply via email to