Re: Making the subquery alias optional in the FROM clause

Поиск
Список
Период
Сортировка
От Dean Rasheed
Тема Re: Making the subquery alias optional in the FROM clause
Дата
Msg-id CAEZATCUaSeAiVfsUxgfMjgjc4cS_cT+-TJNCe+EZqnUtZA_LDQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Making the subquery alias optional in the FROM clause  (Julien Rouhaud <rjuju123@gmail.com>)
Ответы Re: Making the subquery alias optional in the FROM clause  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-hackers
On Mon, 27 Jun 2022 at 16:12, Julien Rouhaud <rjuju123@gmail.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



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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: SYSTEM_USER reserved word implementation
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Making the subquery alias optional in the FROM clause