Minor cleanups after rebase blocked_by_lack_of_per_resultset_storage_attributes/pg_cursors
Peter Rabbitson [Tue, 19 Apr 2011 11:05:37 +0000 (13:05 +0200)]
lib/DBIx/Class/Storage/DBI/Cursor.pm
lib/DBIx/Class/Storage/DBI/Pg/Sth.pm
t/72pg_cursors.t

index bf17e90..bfc31af 100644 (file)
@@ -177,10 +177,14 @@ sub _check_dbh_gen {
 }
 
 sub DESTROY {
-  # None of the reasons this would die matter if we're in DESTROY anyways
   if (my $sth = $_[0]->sth) {
-    local $SIG{__WARN__} = sub {};
-    try { $sth->finish } if $sth->FETCH('Active');
+    # cleanup only core DBI handles, for anything more esoteric we
+    # assume they know how to clean up ater themselves
+    if ($sth->isa('DBI::st')) {
+      local $SIG{__WARN__} = sub {};
+      # None of the reasons this would die matter if we're in DESTROY anyways
+      try { $sth->finish } if $sth->FETCH('Active');
+    }
   }
 }
 
index 40522d8..a77685c 100644 (file)
@@ -112,7 +112,7 @@ sub _prepare_cursor_sth {
 
     return if $self->cursor_sth;
 
-    $self->cursor_sth($self->storage->sth($self->cursor_sql));
+    $self->cursor_sth($self->storage->_sth($self->cursor_sql));
 }
 
 sub _cleanup_sth {
@@ -191,7 +191,7 @@ sub _run_fetch_sth {
     }
 
     $self->fetch_sth->finish if $self->fetch_sth;
-    $self->fetch_sth($self->storage->sth($self->fetch_sql));
+    $self->fetch_sth($self->storage->_sth($self->fetch_sql));
     $self->fetch_sth->execute;
 }
 
index 4141999..cafefc6 100644 (file)
@@ -47,11 +47,14 @@ $schema->storage->set_use_dbms_capability('server_cursors',1);
 drop_test_schema($schema);create_test_schema($schema);
 
 my ($called,$page_size)=(0,0);
-my $old_sth_new=\&DBIx::Class::Storage::DBI::Pg::Sth::new;
-*DBIx::Class::Storage::DBI::Pg::Sth::new=sub {
-    ++$called;$page_size=$_[4];
-    goto &$old_sth_new;
-};
+{
+  no warnings 'redefine';
+  my $old_sth_new=\&DBIx::Class::Storage::DBI::Pg::Sth::new;
+  *DBIx::Class::Storage::DBI::Pg::Sth::new=sub {
+      ++$called;$page_size=$_[4];
+      goto &$old_sth_new;
+  };
+}
 
 END {
     return unless $schema;