X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 49B95529B7 for ; Tue, 12 Jul 2005 18:01:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81648-07 for ; Tue, 12 Jul 2005 21:01:46 +0000 (GMT) Received: from fetter.org (dsl092-188-065.sfo1.dsl.speakeasy.net [66.92.188.65]) by svr1.postgresql.org (Postfix) with ESMTP id 98E1D529B3 for ; Tue, 12 Jul 2005 18:01:44 -0300 (ADT) Received: from fetter.org (localhost.localdomain [127.0.0.1]) by fetter.org (8.13.4/8.12.10) with ESMTP id j6CL1a09022320; Tue, 12 Jul 2005 14:01:36 -0700 Received: (from shackle@localhost) by fetter.org (8.13.4/8.13.4/Submit) id j6CL1axs022319; Tue, 12 Jul 2005 14:01:36 -0700 Date: Tue, 12 Jul 2005 14:01:36 -0700 From: David Fetter To: Andrew Dunstan Cc: Alvaro Herrera , Michael Fuhr , pgsql-hackers@postgresql.org Subject: Re: PL/Perl list value return causes segfault Message-ID: <20050712210136.GA22301@fetter.org> References: <20050712130452.GA84564@winnie.fuhr.org> <42D41319.70107@dunslane.net> <20050712193303.GA14060@alvh.no-ip.org> <42D41DF3.6050702@dunslane.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42D41DF3.6050702@dunslane.net> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200507/447 X-Sequence-Number: 70499 On Tue, Jul 12, 2005 at 03:45:55PM -0400, Andrew Dunstan wrote: > > > Alvaro Herrera wrote: > > >On Tue, Jul 12, 2005 at 02:59:37PM -0400, Andrew Dunstan wrote: > > > > > > > >>Note that all plperl functions are called in scalar context, and > >>it is always wrong to return a list (as opposed to a listref). In > >>fact, the value received might surprise you even if it worked (it > >>would be the value of the last member of the list). > > > >Hmm, I don't know if it's feasible to do in Perl, but maybe check > >whether the function wants to return something in list context and > >throw an appropiate error message? > > In perl, if there is any ambiguity it is the called function that is > responsible for checking, not the caller. See "perldoc -f > wantarray". PLPerl explicitly passed G_SCALAR as a flag on all > calls to plperl routines. So returning a list is a case of pilot > error. Is this a kind of pilot error that documents could help avert in some useful way? Cheers, D -- David Fetter david@fetter.org http://fetter.org/ phone: +1 510 893 6100 mobile: +1 415 235 3778 Remember to vote!