Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T1mqm-0000S6-Ay for pgsql-bugs@postgresql.org; Wed, 15 Aug 2012 23:18:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T1mqj-00044B-At for pgsql-bugs@postgresql.org; Wed, 15 Aug 2012 23:18:08 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id q7FNI327025079; Wed, 15 Aug 2012 19:18:03 -0400 (EDT) From: Tom Lane To: Adam Mackler cc: pgsql-bugs@postgresql.org Subject: Re: Possible Bug in 9.2beta3 In-reply-to: References: <20120813181700.GA45401@bk.macklerlaw.com> <8039.1345049624@sss.pgh.pa.us> Comments: In-reply-to Adam Mackler message dated "Wed, 15 Aug 2012 15:14:11 -0400" Date: Wed, 15 Aug 2012 19:18:03 -0400 Message-ID: <25078.1345072683@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201208/115 X-Sequence-Number: 33839 Adam Mackler writes: > On Wed, Aug 15, 2012 at 12:53 PM, Tom Lane wrote: >> Right offhand I'm inclined to think that the reference to "iter" >> inside the first sub-WITH ought to be disallowed. I don't recall >> the exact rules about where a recursive reference can appear, but >> it sure doesn't seem like that ought to be OK, does it? > Are you asking me or the other experts? More the latter. The verbiage in SQL:2008 7.13 syntax rule 2) g) is sufficiently dense that it's not easy to tell what they're forbidding, and as usual with the SQL committee, no word of rationale shall escape their lips. So I have no idea whether these restrictions are really logically necessary to ensure a predictable result, or they just represent the lowest common denominator of the implementations written by the companies with seats on the committee. But it sort of looks like subrule iii) 3) restricts the recursive reference to appear in the main body of the subquery, not in a WITH attached to it. Be that as it may, our implementation seems to be able to cope with it; the issue that we had here was pretty easily resolvable once I'd traced through the execution. Patch is committed, though too late for this week's releases. regards, tom lane