Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gx7ih-0004Dj-Ff for pgsql-general@arkaria.postgresql.org; Fri, 22 Feb 2019 10:06:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gx7ig-0001UC-4d for pgsql-general@arkaria.postgresql.org; Fri, 22 Feb 2019 10:06:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gx7if-0001NV-NQ for pgsql-general@lists.postgresql.org; Fri, 22 Feb 2019 10:06:13 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gx7ic-0007i6-SM for pgsql-general@lists.postgresql.org; Fri, 22 Feb 2019 10:06:12 +0000 Received: from [192.168.127.1] (port=37253 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1gx7iZ-000Gwf-E6; Fri, 22 Feb 2019 10:06:07 +0000 Received: from [127.0.0.1] (port=32395 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1gx7iY-0001tC-Ob; Fri, 22 Feb 2019 10:06:06 +0000 From: Andrew Gierth To: Jitendra Loyal Cc: pgsql-general@lists.postgresql.org Subject: Re: RECURSIVE allowed only ONCE in a CTE In-Reply-To: (Jitendra Loyal's message of "Fri, 22 Feb 2019 13:23:11 +0530") Message-ID: <87pnrkgmxe.fsf@news-spur.riddles.org.uk> References: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Fri, 22 Feb 2019 10:06:06 +0000 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Jitendra" == Jitendra Loyal 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)