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:
@ -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();
|
||||
|
Reference in New Issue
Block a user