Re: PL/Perl: spi_prepare() and RETURNING - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: PL/Perl: spi_prepare() and RETURNING
Date
Msg-id 44EDF4C9.7020208@dunslane.net
Whole thread Raw
In response to Re: PL/Perl: spi_prepare() and RETURNING  (David Fetter <david@fetter.org>)
List pgsql-hackers
David Fetter wrote:
> On Thu, Aug 24, 2006 at 11:31:02AM -0700, David Fetter wrote:
>   
>> Folks,
>>
>> I've found a little lacuna in the RETURNING feature, that being in
>> PL/Perl's spi_prepare()/spi_execute_prepared() as illustrated in the
>> attached file on CVS TIP.
>>
>> I think that fixing this is a matter of post-RETURNING-patch cleanup.
>> What else might not know about RETURNING that needs to?
>>
>> Cheers,
>> D
>>     
>
>
> Oops.  This time, with the actual file attached :P
>
>   
> my $foo_id = spi_exec_prepared(
>     $sth,
>     $_[0],
> )->{rows}->[0]->{foo_id};
>
>   

I am not sure that the 'rows' member is the right place for it, even if 
it were returned. For one thing, it should always be an arrayref, but 
overloading the first row like this is ugly.

Maybe 'returned_value' or some such would be better, e.g. $foo_id = 
$result->{returned_value}->{foo_id}

(We can't just stash it in the result hash with the used name in case 
somebody overrides the preexisiting members)

cheers

andrew



pgsql-hackers by date:

Previous
From: Bernd Helmle
Date:
Subject: Re: [PATCHES] Updatable views
Next
From: Zoltan Boszormenyi
Date:
Subject: Re: [PATCHES] COPY view