aboutsummaryrefslogtreecommitdiff
path: root/src/pl/plperl/sql/plperl.sql
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2005-07-10 15:19:43 +0000
committerBruce Momjian <bruce@momjian.us>2005-07-10 15:19:43 +0000
commit6d92f2106fa840a497e3cdc88bb4883e9a4712e8 (patch)
tree47f7140f8dac29dee3a6697563e3297ea5f1b3ef /src/pl/plperl/sql/plperl.sql
parentd1cffe2f779d95ddb9f0607f284e2c6c3a71d566 (diff)
downloadpostgresql-6d92f2106fa840a497e3cdc88bb4883e9a4712e8.tar.gz
postgresql-6d92f2106fa840a497e3cdc88bb4883e9a4712e8.zip
The attached patch implements spi_query() and spi_fetchrow() functions
for PL/Perl, to avoid loading the entire result set into memory as the existing spi_exec_query() function does. Here's how one might use the new functions: $x = spi_query("select ..."); while (defined ($y = spi_fetchrow($x))) { ... return_next(...); } The changes do not affect the spi_exec_query() interface in any way. Abhijit Menon-Sen
Diffstat (limited to 'src/pl/plperl/sql/plperl.sql')
-rw-r--r--src/pl/plperl/sql/plperl.sql13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/pl/plperl/sql/plperl.sql b/src/pl/plperl/sql/plperl.sql
index 3e601173ddf..3cafb590c76 100644
--- a/src/pl/plperl/sql/plperl.sql
+++ b/src/pl/plperl/sql/plperl.sql
@@ -247,3 +247,16 @@ for ("World", "PostgreSQL", "PL/Perl") {
return;
$$ language plperl;
SELECT * from perl_srf_rn() AS (f1 INTEGER, f2 TEXT, f3 TEXT);
+
+--
+-- Test spi_query/spi_fetchrow
+--
+
+CREATE OR REPLACE FUNCTION perl_spi_func() RETURNS SETOF INTEGER AS $$
+$x = spi_query("select 1 as a union select 2 as a");
+while (defined ($y = spi_fetchrow($x))) {
+ return_next($y->{a});
+}
+return;
+$$ LANGUAGE plperl;
+SELECT * from perl_spi_func();