[Fwd: Re: plperl, cvs head w/spi patch, return rows on update returns nothing] - Mailing list pgsql-hackers

From Andrew Dunstan
Subject [Fwd: Re: plperl, cvs head w/spi patch, return rows on update returns nothing]
Date
Msg-id 40E9561D.5090704@dunslane.net
Whole thread Raw
List pgsql-hackers
Yes, The API is changed slightly, which I should have made clear.

The number of rows is reported in a member called 'processed'. If actual 
data is returned (i.e. from a select), then that data is returned in the 
'rows' member (it will be a ref to an array of refs to hash.

Run this sample script (requires plperlu) and you will see what's happening:

create function showme(text) returns text language plperlu as $$my $query = shift;my $rv = spi_exec_query($query);use
Data::Dumper;returnDumper($rv);
 
$$;
create table tst(i int, v text);
insert into tst values(2,'two');
select showme('select * from tst');
select showme($$insert into tst values(3,'three')$$);
select showme($$create table tst2(q int, r text)$$);
select * from tst;
select showme($$update tst set i = i + 1$$);
select * from tst;


cheers

andrew


elein wrote:

>The README said that $rv->{rows} should return the number of
>rows affected for INSERT, UPDATE & DELETE.  It seems to return NULL.
>@{$rv->{rows}} also returns NULL.
>
>
>-- drop table users ( email text, who text );
>create table users ( email text, who text );
>insert into users values ('someone@somewhere.com', USER);
>
>create or replace function upd_user( text )
>returns integer as
>'
>my $email = $_[0];
>my $qry = "update users set email=''".$email."'' where who = USER ; ";
>my $rv = spi_exec_query( $qry );
>elog NOTICE, $qry;
>elog NOTICE, $rv->{status};
>elog NOTICE, $rv->{rows};
>return $rv->{rows};
>' language 'plperl';
>
>select val_user('me@home');
>
>  
>



pgsql-hackers by date:

Previous
From: "John Hansen"
Date:
Subject: Relay Access Denied
Next
From: "John Hansen"
Date:
Subject: Re: Relay Access Denied