From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
---|---|
To: | Julien Rouhaud <rjuju123(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Making the subquery alias optional in the FROM clause |
Date: | 2022-06-27 18:24:57 |
Message-ID: | CAEZATCUaSeAiVfsUxgfMjgjc4cS_cT+-TJNCe+EZqnUtZA_LDQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, 27 Jun 2022 at 16:12, Julien Rouhaud <rjuju123(at)gmail(dot)com> wrote:
>
> It doesn't play that well if you have something called subquery though:
>
> [example that changes a user-provided alias]
>
> While the output is a valid query, it's not nice that it's replacing a
> user provided alias with another one (or force an alias if you have a
> relation called subquery).
It's already the case that user-provided aliases can get replaced by
new ones in the query-deparsing code, e.g.:
CREATE OR REPLACE VIEW test_view AS
SELECT x.a, y.b
FROM foo AS x,
(SELECT b FROM foo AS x) AS y;
\sv test_view
CREATE OR REPLACE VIEW public.test_view AS
SELECT x.a,
y.b
FROM foo x,
( SELECT x_1.b
FROM foo x_1) y
and similarly it may invent technically unnecessary aliases where
there were none before. The query-deparsing code has never been
alias-preserving, unless you take care to give everything a globally
unique alias.
Regards,
Dean
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2022-06-27 18:43:25 | Re: Making the subquery alias optional in the FROM clause |
Previous Message | Alvaro Herrera | 2022-06-27 17:32:50 | Re: SYSTEM_USER reserved word implementation |