plperl spi_exec_query patch

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Subject: plperl spi_exec_query patch
Date: 2004-07-04 17:56:26
Message-ID: 40E844CA.8000809@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


The following patch applies a change I inadvertantly left out of the
previous patch, and makes spi_exec_query work correctly in the case of a
select query.
Test shows:
CREATE TABLE test (
i int,
v varchar
);
CREATE TABLE

INSERT INTO test (i, v) VALUES (1,'first line');
INSERT 25616 1
INSERT INTO test (i, v) VALUES (2,'second line');
INSERT 25617 1
INSERT INTO test (i, v) VALUES (3,'third line');
INSERT 25618 1
INSERT INTO test (i, v) VALUES (4,'immortal');
INSERT 25619 1
create function test_munge() returns setof test language plperl as $$

my $res = [];
my $rv = spi_exec_query("select i,v from plperltest.test;");
my $status = $rv->{status};
my $rows = @{$rv->{rows}};
my $processed = $rv->{processed};
foreach my $rn (0..$rows-1)
{
my $row = $rv->{rows}[$rn];
$row->{i} += 200 if defined($row->{i});
$row->{v} =~ tr/A-Za-z/a-zA-Z/ if (defined($row->{v}));
push @$res,$row;
}
return $res;
$$;
CREATE FUNCTION
select * from test_munge();
i | v
-----+-------------
201 | FIRST LINE
202 | SECOND LINE
203 | THIRD LINE
204 | IMMORTAL
(4 rows)

cheers

andrew

Attachment Content-Type Size
spi_internal.patch text/x-patch 2.9 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Kris Jurka 2004-07-04 19:16:56 Re: [JDBC] Error in DatabaseMetaData.getColumns() with Views
Previous Message Andrew Dunstan 2004-07-04 13:55:04 Re: [HACKERS] Compile failure in plperl