Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 9525FAD3D76 for ; Wed, 29 Feb 2012 16:49:04 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S2qSM-0008OO-DS for pgsql-bugs@postgresql.org; Wed, 29 Feb 2012 20:49:03 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id q1TKmmiZ007427; Wed, 29 Feb 2012 15:48:48 -0500 (EST) To: nish2575@gmail.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #6498: with recursive / union all In-reply-to: References: Comments: In-reply-to nish2575@gmail.com message dated "Wed, 29 Feb 2012 18:11:28 +0000" Date: Wed, 29 Feb 2012 15:48:48 -0500 Message-ID: <7426.1330548528@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201202/213 X-Sequence-Number: 32556 nish2575@gmail.com writes: > this doesn't loop infinitely: > insert into acyc values ('a','b') ,('b','c'); > with recursive paths as ( > select frm, too, 1 as lvl from acyc > union all > select fnd.frm, a.too, lvl + 1 from acyc a join paths fnd on fnd.too = > a.frm ) select * from paths; Why would it? You don't have any loops in the data. In particular that means there will be no join matches after a certain number of levels. regards, tom lane