public inbox for [email protected]
help / color / mirror / Atom feedFrom: Kirill Reshke <[email protected]>
To: Rushabh Lathia <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: ORDER BY ALL
Date: Tue, 24 Mar 2026 13:02:38 +0500
Message-ID: <CALdSSPjTW9N+TVDwUgC+AvsbZdYtwP+O8jKZ=iASHUNHnFPbyA@mail.gmail.com> (raw)
In-Reply-To: <CAGPqQf2_b6FSsGm2TwtUu0pq5ruQpSYqTo4Y8jYMV4DP2E17Ng@mail.gmail.com>
References: <CAGPqQf2_b6FSsGm2TwtUu0pq5ruQpSYqTo4Y8jYMV4DP2E17Ng@mail.gmail.com>
On Tue, 24 Mar 2026 at 11:27, Rushabh Lathia <[email protected]> wrote:
>
> Hi hackers,
>
> Please find the attached patch, to implement the ORDER BY ALL clause.
> Commit ef38a4d97, implemented GROUP BY ALL clause, and this
> feature follows the same pattern.
>
> ORDER BY ALL is a form of ORDER BY that automatically adds all
> non-junk columns from the SELECT target list to the ORDER BY clause.
>
> This implementation supports:
> - ORDER BY ALL (default ascending order)
> - ORDER BY ALL ASC
> - ORDER BY ALL DESC
> - ORDER BY ALL NULLS FIRST/LAST
> - ORDER BY ALL ASC/DESC NULLS FIRST/LAST
>
> The syntax works by creating a marker SortBy node with a NULL
> node pointer that carries the sort direction and nulls ordering.
> During query transformation, this marker is detected and expanded
> to order by all non-junk columns in the target list with the
> specified direction.
>
> Implementation details:
> - gram.y: Added ORDER BY ALL grammar with optional ASC/DESC and NULLS
> in both main sort_clause and PLpgSQL_Expr rules
> - parse_clause.c: Implemented ORDER BY ALL expansion logic that iterates
> over target list columns
> - analyze.c: Updated to pass orderByAll flag through transformation
> - parsenodes.h: Added orderByAll boolean to SelectStmt and Query
> - ruleutils.c: Added deparsing support for ORDER BY ALL that preserves
> sort direction and NULLS ordering in view definitions, including proper
> handling of implicit vs explicit ordering
>
> Please take a look at the attached patch and let me know your thoughts.
>
> Thanks,
> Rushabh Lathia
> www.EnterpriseDB.com
>
Hi! What about SQL standard compatibility? ef38a4d97 was merged only
after the SQL committee accepted GROUP BY ALL, there was discussion a
few years before [0] which ended up in nothing because of SQL
standard... So I wonder what is perspective of this thread
[0] https://www.postgresql.org/message-id/CAAhFRxjyTO5BHn9y1oOSEp0TtpTDTTTb7HJBNhTG%2Bi3-hXC0XQ%40mail.g...
--
Best regards,
Kirill Reshke
view thread (3+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: ORDER BY ALL
In-Reply-To: <CALdSSPjTW9N+TVDwUgC+AvsbZdYtwP+O8jKZ=iASHUNHnFPbyA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox