Re: FROM clause before SELECT - Mailing list pgsql-hackers

From Vik Fearing
Subject Re: FROM clause before SELECT
Date
Msg-id d560bf19-0897-41cd-ad92-d0906e8dec3b@postgresfriends.org
Whole thread
Responses Re: FROM clause before SELECT
List 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




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: remove_useless_joins vs. bug #19560
Next
From: Sami Imseih
Date:
Subject: Re: Track skipped tables during autovacuum and autoanalyze