commit ineffective with AutoCommit enabled... MailWatch.pm

ajos1 at onion ajos1 at onion.demon.co.uk
Thu May 29 16:09:36 IST 2008


-

Re: commit ineffective with AutoCommit enabled... MailWatch.pm

Ideas from:  http://search.cpan.org/dist/DBD-mysql/lib/DBD/mysql.pm
Section vw:  TRANSACTION SUPPORT


Old Code - /usr/lib/MailScanner/MailScanner/CustomFunctions/MailWatch.pm
========================================================================
 sub ExitLogging {
   # Server exit - commit changes, close socket, and exit gracefully.
   close(SERVER);
   $dbh->commit;
   $dbh->disconnect;
   exit;
 }


New Code - /usr/lib/MailScanner/MailScanner/CustomFunctions/MailWatch.pm
========================================================================
 sub ExitLogging {
   # Server exit - commit changes, close socket, and exit gracefully.
   close(SERVER);
   if (! $dbh->{'AutoCommit'}) {
      $dbh->commit;
   }
   $dbh->disconnect;
   exit;
 }


My Intepretation... but I could be wrong
========================================
Basically detect if "$dbh->{'AutoCommit'}" is set to 1 or 0...

If it is on (1)... then commits to the database are automatic and should have already happened?
If this is the case... we do not need to do a COMMIT ?


Test Code...
============
#!/usr/bin/perl
use strict;
use DBI();
my $dbh = DBI->connect("DBI:mysql:database=phpmyadmin;host=localhost","USERNAME", "PASSWORD",{'RaiseError' => 1});
if (! $dbh->{'AutoCommit'}) {
   $dbh->commit;
}
$dbh->disconnect();

==
=====================================================================
=
= "What's it called when you put off procrastinating?"
=
=====================================================================
=  Need help with: Parking Tickets, Bailiffs, Capita or HertsGrid???
=  Call...    +44 8457 90 90 90    http://www.samaritans.org/
=====================================================================


More information about the MailScanner mailing list