[freeside-commits] branch master updated. 90dd1d7c7a1b1d0c57c05a696f936df6247d98e3

Ivan ivan at 420.am
Tue Mar 25 21:27:43 PDT 2014


The branch, master has been updated
       via  90dd1d7c7a1b1d0c57c05a696f936df6247d98e3 (commit)
      from  4289ed53f86f18d6107339db5b7cee38f64533c0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 90dd1d7c7a1b1d0c57c05a696f936df6247d98e3
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Mar 25 21:27:40 2014 -0700

    close cursors on DESTROY, RT#26262

diff --git a/FS/FS/Cursor.pm b/FS/FS/Cursor.pm
index f3bc1e2..24ebf58 100644
--- 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 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;
+
 # 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};
 
-  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} };
@@ -64,7 +62,7 @@ sub new {
 
   $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;
 }
@@ -101,6 +99,11 @@ sub refill {
   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

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Cursor.pm |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)




More information about the freeside-commits mailing list