Hi,

Came accross an issue when trying to reduce creation of handles on a site.

Currently Apache::DBI makes the assumption that it AutoCommit => 1 then the handle 
does not need cleaning up. This is not neccessariliy true as begin_work switches of 
the AutoCommit for one transaction.

To be safe the handle should always be cleaned up otherwise next time it is requested 
it may be mid transaction.

Not sure who has access to the CVS tree but here is a patch for that case.

Tested against MP1.

Hope it helps

Paddy


--- DBI/DBI.pm  2003-06-10 12:20:06.000000000 +0000
+++ DBI/DBI.pm  2003-06-10 12:02:07.000000000 +0000
@@ -87,9 +87,10 @@
     }
 
     # this PerlCleanupHandler is supposed to initiate a rollback after the script has 
finished if AutoCommit is off.
-    my $needCleanup = ($Idx =~ /AutoCommit[^\d]+0/) ? 1 : 0;
+    # however cleanup can only be determined at end of handle life as begin_work may 
have been called to temporarily turn off AutoCommit.
+    #
     # TODO - Fix mod_perl 2.0 here
-    if(!$Rollback{$Idx} and $needCleanup and Apache->can('push_handlers')) {
+    if(!$Rollback{$Idx} and Apache->can('push_handlers')) {
         print STDERR "$prefix push PerlCleanupHandler \n" if $Apache::DBI::DEBUG > 1;
         Apache->push_handlers("PerlCleanupHandler", \&cleanup);
         # make sure, that the rollback is called only once for every 

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to