Re: Remove restrictions in recursive query

David G. Johnston <david.g.johnston@gmail.com>

From: "David G. Johnston" <david.g.johnston@gmail.com>
To: Renan Alves Fonseca <renanfonseca@gmail.com>
Cc: pgsql-hackers@postgresql.org
Date: 2025-03-27T17:00:11Z
Lists: pgsql-hackers
On Thu, Mar 27, 2025 at 9:02 AM Renan Alves Fonseca <renanfonseca@gmail.com>
wrote:

> So, do we support the ORDER BY in a recursive query or not?
>

Apparently we do.  The "in" recurses.

If the answer is yes, I suggest one of the following modifications:
>
1. Change the error message to something like "ORDER BY at the top level of
> a recursive query is not implemented. HINT: wrap the respective statement
> around ()"
>

The error message is now correct but I'd lose the hint.  It assumes a typo
and that the query author meant to sort each iteration of the recursive
term; when maybe they did wish for the final result of the completed
recursive query to then be fed into a sort node and ordered, in which case
the parentheses wouldn't help.

David J.