Re: Is "WITH RECURSIVE" limited to the first position of CTEs by design? - Mailing list pgsql-general

From Tom Lane
Subject Re: Is "WITH RECURSIVE" limited to the first position of CTEs by design?
Date
Msg-id 2073791.1699894143@sss.pgh.pa.us
Whole thread Raw
In response to Re: Is "WITH RECURSIVE" limited to the first position of CTEs by design?  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Mon, Nov 13, 2023 at 9:17 AM Kirk Wolak <wolakk@gmail.com> wrote:
>> These are the most trivial examples.  The second one results in a syntax
>> error.  Which implies that:
>> 1) There can only be one recursive CTE at the same level?
>> 2) It must be the FIRST CTE?

> There is only one WITH keyword as well, that doesn't change the fact there
> can be multiple attached queries to it.

Yeah, RECURSIVE is attached to the WITH not to the query.  That's
because it has global implications for the visibility of the CTE
names across all the CTEs in the WITH.

            regards, tom lane



pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Unique Primary Key Linked to Multiple Accounts
Next
From: Tom Lane
Date:
Subject: Re: Issue in compiling postgres on latest macOS 14.1.1