Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 696019F9C8F for ; Wed, 29 Aug 2007 21:19:29 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 44943-05 for ; Wed, 29 Aug 2007 21:19:21 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 5381A9F9C85 for ; Wed, 29 Aug 2007 21:19:26 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l7U0JNTX013702; Wed, 29 Aug 2007 20:19:24 -0400 (EDT) To: "Roger Moloney" cc: pgsql-interfaces@postgresql.org Subject: Re: plpgsql: defuault parameters and constant function parameters In-reply-to: References: Comments: In-reply-to "Roger Moloney" message dated "Tue, 28 Aug 2007 12:31:57 -0000" Date: Wed, 29 Aug 2007 20:19:23 -0400 Message-ID: <13701.1188433163@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/24 X-Sequence-Number: 6618 "Roger Moloney" writes: > Having just done the first draft of a large migration from informix to > postgres, I wanted to point out that the migration was hugely complicated by > postgres inability to define default parameters You can get that effect using function name overloading. For instance create function f(x int, y int) ... create function f(x int) ... as 'select f(x, 1)' ... It's easier if the defaultable parameters are at the end, but I rather wonder how your informix system is disambiguating the calls either with a signature like that. If you leave off just one of the two defaultable parameters, how does it know which? > I dont want to make them output parameters as they are not output > parameters. I am returning different output parameters. However it would be > great if I could modify (and not pass back) the value of a input parameter. Just use a differently named local variable, perhaps? Actually, because of the scoping rules it seems to me to work fine even if they have the same name: regression=# create function ff(f1 int) returns int as $$ declare f1 int := coalesce(f1, 1); begin return f1; end$$ language plpgsql; CREATE FUNCTION regression=# select ff(3); ff ---- 3 (1 row) regression=# select ff(null); ff ---- 1 (1 row) > Any chance of allowing input parameters to be modified within the function > body ? That check is there to prevent mistakes, and I think it's a good one. regards, tom lane