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 f1A3TOx62403 for ; Fri, 9 Feb 2001 22:29:24 -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 f1A3TJ928786; Fri, 9 Feb 2001 22:29:20 -0500 (EST) To: m.proctor@bigfoot.com cc: pgsql-sql@postgresql.org Subject: Re: Recusrive Functions in 7.0.3 In-reply-to: <01020920225704.05071@localhost.localdomain> References: <01020920225704.05071@localhost.localdomain> Comments: In-reply-to message dated "Fri, 09 Feb 2001 20:22:57 +0000" Date: Fri, 09 Feb 2001 22:29:19 -0500 Message-ID: <28783.981775759@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200102/189 X-Sequence-Number: 1376 writes: > Are recursive functions allowed in in 7.0.3 Sure. play=> create function myfactorial(int) returns int as ' play'> begin play'> if $1 > 1 then play'> return $1 * myfactorial($1 - 1); play'> end if; play'> return $1; play'> end;' language 'plpgsql'; CREATE play=> select myfactorial(1); myfactorial ------------- 1 (1 row) play=> select myfactorial(10); myfactorial ------------- 3628800 (1 row) play=> I get a stack overflow crash at about myfactorial(7500), but that seems like a sufficient level of recursion depth for normal purposes ... > as I seem to be unable to > get them to work in plpgsql, Are you sure you aren't asking for infinite recursion, eg by invoking the same function with the same argument? regards, tom lane