Received: from sss.pgh.pa.us (sss.pgh.pa.us [209.114.132.154]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f03I8r706506 for ; Wed, 3 Jan 2001 13:08:53 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.1/8.11.1) with ESMTP id f03I9PB16777; Wed, 3 Jan 2001 13:09:25 -0500 (EST) To: "Albert REINER" cc: PostgreSQL-SQL Subject: Re: PL/pgSQL: recursion? In-reply-to: <20010102223136.A1265@frithjof> References: <20010102223136.A1265@frithjof> Comments: In-reply-to "Albert REINER" message dated "Tue, 02 Jan 2001 22:31:36 +0100" Date: Wed, 03 Jan 2001 13:09:24 -0500 Message-ID: <16774.978545364@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200101/36 X-Sequence-Number: 697 "Albert REINER" writes: > is there any possibility to do recursion in plpgsql-functions? Recursion works fine ... but an infinite recursion, such as you have here, will quickly overflow the available stack space and cause the backend to crash. You're invoking idPath with the same argument it was passed, no? I changed > | str2 := idPath(r.id); to > | str2 := idPath(r.id-1); and got regression=# select idPath(5); idpath --------- 5:4:3:2 (1 row) which may or may not be the answer you wanted, but it does demonstrate that a plpgsql function can recurse. regards, tom lane