1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-26 01:22:12 +03:00

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
This commit is contained in:
Bruce Momjian
2005-07-10 15:19:43 +00:00
parent d1cffe2f77
commit 6d92f2106f
5 changed files with 125 additions and 1 deletions

View File

@ -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();