Re: FROM clause before SELECT

From: Vik Fearing <vik(at)postgresfriends(dot)org>
To: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, pgsql-hackers mailing list <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Andreas Karlsson <andreas(at)proxel(dot)se>
Subject: Re: FROM clause before SELECT
Date: 2026-07-27 19:00:56
Message-ID: d560bf19-0897-41cd-ad92-d0906e8dec3b@postgresfriends.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 27/07/2026 15:30, Andrey Borodin wrote:
> Hi hackers!
>
> At the sessions where I show newcomers around the codebase, we need a
> first patch every time: small enough to finish in an hour, in a part of
> the DBMSs everyone has an opinion about. The one we usually write makes
> this work:
>
> FROM pg_stat_activity SELECT *;

I am generally in favor of this. (Notice: I haven't read the patch)

> What I deliberately did not do: accept the section keywords in any order
> at all (Vik's suggestion),

That wasn't really a serious suggestion.  Allegedly.

> or allow SELECT last after GROUP BY (Andreas
> Karlsson's). Both are defensible, but let's keep the surface minimal
> and tied to the completion argument.

This is a lot more serious, and if we are going to move the SELECT
clause, I agree with Andreas K. that it belongs after HAVING or possibly
even later.

> If the consensus is that our grammar should stay standard-only, that is
> a perfectly good answer, and I will restore the punchline for the next
> session.

The standard is never going to move the SELECT, so we are free to do so
as an extension to the standard.  The main problem is it has become a
mush-mash of random stuff so its proper placement is a bit vague.

--

Vik Fearing

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2026-07-27 19:20:13 Re: Fix race condition in pg_get_publication_tables with concurrent DROP TABLE
Previous Message Tom Lane 2026-07-27 18:21:12 Re: remove_useless_joins vs. bug #19560