Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T1gqr-0004C4-1d for pgsql-bugs@postgresql.org; Wed, 15 Aug 2012 16:53:49 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T1gqo-0006rO-IK for pgsql-bugs@postgresql.org; Wed, 15 Aug 2012 16:53:48 +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 q7FGriJf008040; Wed, 15 Aug 2012 12:53:45 -0400 (EDT) From: Tom Lane To: Adam Mackler cc: pgsql-bugs@postgresql.org Subject: Re: Possible Bug in 9.2beta3 In-reply-to: <20120813181700.GA45401@bk.macklerlaw.com> References: <20120813181700.GA45401@bk.macklerlaw.com> Comments: In-reply-to Adam Mackler message dated "Mon, 13 Aug 2012 14:17:00 -0400" Date: Wed, 15 Aug 2012 12:53:44 -0400 Message-ID: <8039.1345049624@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201208/107 X-Sequence-Number: 33831 Adam Mackler writes: > WITH RECURSIVE > tab(id_key,link) AS ( VALUES (1,17), (2,17), (3,17), (4,17), (6,17), (5,17) ), > iter (id_key, row_type, link) AS ( > SELECT 0, 'base', 17 > UNION( > WITH remaining(id_key, row_type, link, min) AS ( > SELECT tab.id_key, 'true'::text, iter.link, MIN(tab.id_key) OVER () > FROM tab INNER JOIN iter USING (link) > WHERE tab.id_key > iter.id_key > ), > first_remaining AS ( > SELECT id_key, row_type, link > FROM remaining > WHERE id_key=min > ), > effect AS ( > SELECT tab.id_key, 'new'::text, tab.link > FROM first_remaining e INNER JOIN tab ON e.id_key=tab.id_key > /* Try changing this WHERE clause to other false expressions */ > WHERE e.row_type='false' > ) > SELECT * FROM first_remaining > /* Try uncommenting the next line */ > --UNION SELECT * FROM effect > ) > ) > SELECT DISTINCT * FROM iter 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? regards, tom lane