return next and pl/perl

Started by Eric Ealmost 21 years ago5 messagesgeneral
Jump to latest
#1Eric E
whalesuit@bonbon.net

Hi all,
I'm working on implementing a function in PL/PERL that will ready
many rows. As such I'd like to use return_next to keep memory usage
down. When I call return next, I get the following error message:

ERROR: error from Perl function: Can't call method "return_next" on
unblessed reference at (eval 18) line 25.

likewise if I use spi_return_next:
ERROR: error from Perl function: Can't call method "spi_return_next" on
unblessed reference at (eval 16) line 25.

After some Google and list searching, I inferred that spi_return_next
may not be implemented? Is this correct? If so, is there a workaround?

Thanks,

Eric

#2Sean Davis
sdavis2@mail.nih.gov
In reply to: Eric E (#1)
Re: return next and pl/perl

----- Original Message -----
From: "Eric E" <whalesuit@bonbon.net>
To: <pgsql-general@postgresql.org>
Sent: Friday, June 10, 2005 7:24 PM
Subject: [GENERAL] return next and pl/perl

Hi all,
I'm working on implementing a function in PL/PERL that will ready
many rows. As such I'd like to use return_next to keep memory usage
down. When I call return next, I get the following error message:

ERROR: error from Perl function: Can't call method "return_next" on
unblessed reference at (eval 18) line 25.

likewise if I use spi_return_next:
ERROR: error from Perl function: Can't call method "spi_return_next" on
unblessed reference at (eval 16) line 25.

After some Google and list searching, I inferred that spi_return_next
may not be implemented? Is this correct? If so, is there a workaround?

There is no workaround that I know of. See here:

http://www.postgresql.org/docs/8.0/static/plperl-missing.html

It's a known limitation.

Sean

#3David Fetter
david@fetter.org
In reply to: Eric E (#1)
Re: return next and pl/perl

On Fri, Jun 10, 2005 at 07:24:49PM -0400, Eric E wrote:

Hi all,
I'm working on implementing a function in PL/PERL that will ready
many rows. As such I'd like to use return_next to keep memory usage
down. When I call return next, I get the following error message:

ERROR: error from Perl function: Can't call method "return_next" on
unblessed reference at (eval 18) line 25.

likewise if I use spi_return_next: ERROR: error from Perl function:
Can't call method "spi_return_next" on unblessed reference at (eval
16) line 25.

After some Google and list searching, I inferred that
spi_return_next may not be implemented? Is this correct? If so, is
there a workaround?

For 8.0, not exactly, although you can batch the entire rowset into an
array ref of hash references, then return that.

In the forthcoming 8.1 (CVS TIP), there is a return_next() method.

Cheers,
D
--
David Fetter david@fetter.org http://fetter.org/
phone: +1 510 893 6100 mobile: +1 415 235 3778

Remember to vote!

#4Eric E
whalesuit@bonbon.net
In reply to: David Fetter (#3)
Re: return next and pl/perl

Hi David,
I ended up doing what you suggest, and it seems to work OK right now. I'll definitely look for return_next in 8.1.
On a related subject, is there any interest in eliminating the requirement that types be specified at runtime,
either by the function returning the type, or in the select statement? It would be helpful to me, but it's not a dealkiller.

Anyway, thanks a lot for your help, it's much appreciated.

Eric

On Fri, Jun 10, 2005 at 07:24:49PM -0400, Eric E wrote:

Hi all,
I'm working on implementing a function in PL/PERL that will ready
many rows. As such I'd like to use return_next to keep memory usage
down. When I call return next, I get the following error message:

ERROR: error from Perl function: Can't call method "return_next" on
unblessed reference at (eval 18) line 25.

likewise if I use spi_return_next: ERROR: error from Perl function:
Can't call method "spi_return_next" on unblessed reference at (eval
16) line 25.

After some Google and list searching, I inferred that
spi_return_next may not be implemented? Is this correct? If so, is
there a workaround?

For 8.0, not exactly, although you can batch the entire rowset into an
array ref of hash references, then return that.

In the forthcoming 8.1 (CVS TIP), there is a return_next() method.

Cheers,
D
--
David Fetter david ( at ) fetter ( dot ) org http://fetter.org/
phone: +1 510 893 6100 mobile: +1 415 235 3778

Remember to vote!

#5Sean Davis
sdavis2@mail.nih.gov
In reply to: Eric E (#4)
Re: return next and pl/perl

Eric,

You might check out this thread:

http://archives.postgresql.org/pgsql-general/2005-06/msg00527.php

Someone can almost certainly point to a better thread, but it is a
start....

Sean

On Jun 13, 2005, at 12:41 PM, Eric E wrote:

Show quoted text

Hi David,
I ended up doing what you suggest, and it seems to work OK right now.
I'll definitely look for return_next in 8.1. On a related subject,
is there any interest in eliminating the requirement that types be
specified at runtime, either by the function returning the type, or in
the select statement? It would be helpful to me, but it's not a
dealkiller.

Anyway, thanks a lot for your help, it's much appreciated.

Eric

On Fri, Jun 10, 2005 at 07:24:49PM -0400, Eric E wrote:

Hi all,
I'm working on implementing a function in PL/PERL that will ready
many rows. As such I'd like to use return_next to keep memory usage
down. When I call return next, I get the following error message:
ERROR: error from Perl function: Can't call method "return_next" on
unblessed reference at (eval 18) line 25.
likewise if I use spi_return_next: ERROR: error from Perl function:
Can't call method "spi_return_next" on unblessed reference at (eval
16) line 25.
After some Google and list searching, I inferred that
spi_return_next may not be implemented? Is this correct? If so, is
there a workaround?

For 8.0, not exactly, although you can batch the entire rowset into an
array ref of hash references, then return that.

In the forthcoming 8.1 (CVS TIP), there is a return_next() method.

Cheers,
D
--
David Fetter david ( at ) fetter ( dot ) org http://fetter.org/
phone: +1 510 893 6100 mobile: +1 415 235 3778

Remember to vote!

---------------------------(end of
broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to
majordomo@postgresql.org