[Fwd: Re: plperl, cvs head w/spi patch, return rows on update returns nothing]

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: [Fwd: Re: plperl, cvs head w/spi patch, return rows on update returns nothing]
Date: 2004-07-05 13:22:37
Message-ID: 40E9561D.5090704@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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;
return Dumper($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(at)somewhere(dot)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(at)home');
>
>
>

Browse pgsql-hackers by date

  From Date Subject
Next Message John Hansen 2004-07-05 13:28:45 Re: Relay Access Denied
Previous Message John Hansen 2004-07-05 13:20:38 Relay Access Denied