From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Jitendra Loyal <jitendra.loyal@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: RECURSIVE allowed only ONCE in a CTE
Date: Fri, 22 Feb 2019 10:06:06 +0000
Message-ID: <87pnrkgmxe.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <CAGBkuscXcXtN=1YTjvBKn4qx+ZZ__g3fEdzgRXwu_kVKLJqHbQ@mail.gmail.com>
References: <CAGBkuscXcXtN=1YTjvBKn4qx+ZZ__g3fEdzgRXwu_kVKLJqHbQ@mail.gmail.com>
>>>>> "Jitendra" == Jitendra Loyal <jitendra.loyal@gmail.com> writes:
Jitendra> I find that the RECURSIVE can be used only once in a CTE.
RECURSIVE can be specified only once, but it applies to all CTEs at that
level. That is to say, RECURSIVE qualifies the preceding WITH, _not_ the
following CTE.
Note that just specifying RECURSIVE doesn't mean that any CTE is
recursive, it simply changes the name scoping rules such that CTEs _can_
be recursive. (Without it, a CTE's name is not in scope in its own body
so recursion is impossible.)
--
Andrew (irc:RhodiumToad)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: andrew@tao11.riddles.org.uk, jitendra.loyal@gmail.com
Subject: Re: RECURSIVE allowed only ONCE in a CTE
In-Reply-To: <87pnrkgmxe.fsf@news-spur.riddles.org.uk>
References: <CAGBkuscXcXtN=1YTjvBKn4qx+ZZ__g3fEdzgRXwu_kVKLJqHbQ@mail.gmail.com> <87pnrkgmxe.fsf@news-spur.riddles.org.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox