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 AFE0F529E6 for ; Tue, 12 Jul 2005 16:46:06 -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 61811-09 for ; Tue, 12 Jul 2005 19:46:05 +0000 (GMT) Received: from trolak.mydnsbox2.com (ns1.mydnsbox2.com [207.44.142.118]) by svr1.postgresql.org (Postfix) with ESMTP id 2FAE4529DF for ; Tue, 12 Jul 2005 16:46:04 -0300 (ADT) Received: from [192.168.1.103] (cpe-024-211-165-134.nc.res.rr.com [24.211.165.134]) (authenticated (0 bits)) by trolak.mydnsbox2.com (8.11.6/8.11.6) with ESMTP id j6CJ0E625989; Tue, 12 Jul 2005 14:00:14 -0500 Message-ID: <42D41DF3.6050702@dunslane.net> Date: Tue, 12 Jul 2005 15:45:55 -0400 From: Andrew Dunstan User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Fedora/1.7.8-1.3.1 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Alvaro Herrera Cc: Michael Fuhr , pgsql-hackers@postgresql.org Subject: Re: PL/Perl list value return causes segfault References: <20050712130452.GA84564@winnie.fuhr.org> <42D41319.70107@dunslane.net> <20050712193303.GA14060@alvh.no-ip.org> In-Reply-To: <20050712193303.GA14060@alvh.no-ip.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.044 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200507/441 X-Sequence-Number: 70493 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. cheers andrew