| From: | Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com> |
|---|---|
| To: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: ORDER BY ALL |
| Date: | 2026-11-06 12:44:03 |
| Message-ID: | CAGPqQf3NJsSsuEfa9mYY=6S_APaqWz=Fqw0jd7hf-zNs8ea2pA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Peter,
Thanks for your reply.
On Wed, Sep 23, 2026 at 3:00 PM Peter Eisentraut <peter(at)eisentraut(dot)org>
wrote:
> On 24.03.26 07:27, Rushabh Lathia wrote:
> > 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.
>
> I think this is a feature that is worth pursuing. The patch is still a
> bit rough.
>
> In the future, combine the patch with the code and the patch with the
> test and documentation into one patch.
>
Okay, I will work on this.
>
> Find a place to add the regression tests, instead of adding a new file.
> There are probably already places where ORDER BY syntax variants are
> tested. In any case, it shouldn't be its own parallel group.
>
Noted.
>
> The plpgsql_misc fails. Apparently, the expected file is misformatted.
>
> ORDER BY clauses don't only exist in top-level SELECT statements, they
> also appear in aggregate and window functions, for example. This patch
> doesn't handle this correctly. Consider:
>
> select array_agg(a order by all) from t;
> select rank() over (order by all) from t;
> select percentile_disc(0.5) within group (order by all) from t;
>
> These should either be rejected cleanly or do something useful.
> Currently, they either crash and produce an internal error. (Also add
> test cases.)
>
Sure will work on this.
Thanks,
Rushabh Lathia
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Aya Iwata (Fujitsu) | 2026-11-06 12:50:22 | Re: BGWORKER_INTERRUPTIBLE workers are never restarted after DROP/ALTER/CREATE DATABASE |
| Previous Message | Alberto Piai | 2026-11-06 12:36:11 | Re: Adding a stored generated column without long-lived locks |