projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4289ed5
)
close cursors on DESTROY, RT#26262
author
Ivan Kohler
<ivan@freeside.biz>
Wed, 26 Mar 2014 04:27:40 +0000
(21:27 -0700)
committer
Ivan Kohler
<ivan@freeside.biz>
Wed, 26 Mar 2014 04:27:40 +0000
(21:27 -0700)
FS/FS/Cursor.pm
patch
|
blob
|
history
diff --git
a/FS/FS/Cursor.pm
b/FS/FS/Cursor.pm
index
f3bc1e2
..
24ebf58
100644
(file)
--- a/
FS/FS/Cursor.pm
+++ b/
FS/FS/Cursor.pm
@@
-2,12
+2,11
@@
package FS::Cursor;
use strict;
use vars qw($DEBUG $buffer);
use strict;
use vars qw($DEBUG $buffer);
-use base qw( Exporter );
-use FS::Record qw(qsearch dbdef dbh);
-use Data::Dumper;
+use FS::Record qw(dbh);
use Scalar::Util qw(refaddr);
$DEBUG = 0;
use Scalar::Util qw(refaddr);
$DEBUG = 0;
+
# this might become a parameter at some point, but right now, you can
# "local $FS::Cursor::buffer = X;"
$buffer = 200;
# this might become a parameter at some point, but right now, you can
# "local $FS::Cursor::buffer = X;"
$buffer = 200;
@@
-53,9
+52,8
@@
sub new {
$self->{id} = sprintf('cursor%08x', refaddr($self));
my $statement = "DECLARE ".$self->{id}." CURSOR FOR ".$q->{statement};
$self->{id} = sprintf('cursor%08x', refaddr($self));
my $statement = "DECLARE ".$self->{id}." CURSOR FOR ".$q->{statement};
- my $dbh = dbh;
- my $sth = $dbh->prepare($statement)
- or die $dbh->errstr;
+ my $sth = dbh->prepare($statement)
+ or die dbh->errstr;
my $bind = 0;
foreach my $value ( @{ $q->{value} } ) {
my $bind_type = shift @{ $q->{bind_type} };
my $bind = 0;
foreach my $value ( @{ $q->{value} } ) {
my $bind_type = shift @{ $q->{bind_type} };
@@
-64,7
+62,7
@@
sub new {
$sth->execute or die $sth->errstr;
$sth->execute or die $sth->errstr;
- $self->{fetch} =
$
dbh->prepare("FETCH FORWARD $buffer FROM ".$self->{id});
+ $self->{fetch} = dbh->prepare("FETCH FORWARD $buffer FROM ".$self->{id});
$self;
}
$self;
}
@@
-101,6
+99,11
@@
sub refill {
scalar @$result;
}
scalar @$result;
}
+sub DESTROY {
+ my $self = shift;
+ dbh->do('CLOSE '. $self->{id}) or die dbh->errstr; # clean-up the cursor in Pg
+}
+
=back
=head1 TO DO
=back
=head1 TO DO