Re: PL/Perl list value return causes segfault

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: PL/Perl list value return causes segfault
Date: 2005-07-12 19:45:55
Message-ID: 42D41DF3.6050702@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs pgsql-hackers pgsql-patches

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

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message David Fetter 2005-07-12 20:01:56 Re: [PATCHES] Doc patch: New PL/Perl Features
Previous Message Alvaro Herrera 2005-07-12 19:33:04 Re: PL/Perl list value return causes segfault

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Wong 2005-07-12 19:47:17 dbt2 & opteron performance
Previous Message Alvaro Herrera 2005-07-12 19:33:04 Re: PL/Perl list value return causes segfault

Browse pgsql-patches by date

  From Date Subject
Next Message Marko Kreen 2005-07-12 19:51:58 Re: 4 pgcrypto regressions failures - 1 unsolved
Previous Message Alvaro Herrera 2005-07-12 19:33:04 Re: PL/Perl list value return causes segfault