From: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
---|---|
To: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
Cc: | Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Allow an alias to be attached directly to a JOIN ... USING |
Date: | 2019-08-01 06:33:50 |
Message-ID: | CA+hUKGLn84tOodRKbpTTS8uMUpZnt-SpUZXXzG36YysR85kz6A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Jul 16, 2019 at 8:58 AM Fabien COELHO <coelho(at)cri(dot)ensmp(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Munro | 2019-08-01 06:42:23 | Re: Avoid full GIN index scan when possible |
Previous Message | Thomas Munro | 2019-08-01 06:23:00 | Re: Add client connection check during the execution of the query |