Re: Remove restrictions in recursive query

Renan Alves Fonseca <renanfonseca@gmail.com>

From: Renan Alves Fonseca <renanfonseca@gmail.com>
To: "David G. Johnston" <david.g.johnston@gmail.com>
Cc: pgsql-hackers@postgresql.org
Date: 2025-03-27T18:21:27Z
Lists: pgsql-hackers
On Thu, Mar 27, 2025 at 7:10 PM David G. Johnston
<david.g.johnston@gmail.com> wrote:
>
> There is distinct behavior between group by and order by here.  You seem to be mixing them up.
>
> From Select:
>
> select_statement is any SELECT statement without an ORDER BY, LIMIT, FOR NO KEY UPDATE, FOR UPDATE, FOR SHARE, or FOR KEY SHARE clause. (ORDER BY and LIMIT can be attached to a subexpression if it is enclosed in parentheses. Without parentheses, these clauses will be taken to apply to the result of the UNION, not to its right-hand input expression.)
>
> This is the exact same parsing precedence order by is being given in the recursive CTE query situation presented earlier.
>
> David J.
>

You're right. I'm really mixing these 2 here. Thanks for the clarification.

I'll assume that the silence about allowing GROUP BY means it is not a
great idea...