commit ineffective with AutoCommit enabled... MailWatch.pm

Leonardo Helman mailscanner at lists.com.ar
Thu May 29 17:53:11 IST 2008


I really don't know what you are talking about (so forgive me
for trying to clarify), 

The general idea is that if you set AutoCommit
the database sends a commit whenever is necesary

If you use AutoCommit there is no need to use $dbh-commit statenment

This is from "man DBI", it explains that there are 3 kind of
 databases and ...

 * Databases which don’t support transactions at all

   For these databases, attempting to turn "AutoCommit" off is a fatal
   error.  "commit" and "rollback" both issue warnings about being inef-
   fective while "AutoCommit" is in effect.

 * Databases in which a transaction is always active

   These are typically mainstream commercial relational databases with
   "ANSI standard" transaction behaviour.  If "AutoCommit" is off, then
   changes to the database won’t have any lasting effect unless "commit"
   is called (but see also "disconnect"). If "rollback" is called then 
   any changes since the last commit are undone.

   If "AutoCommit" is on, then the effect is the same as if the DBI
called
   "commit" automatically after every successful database operation. So
   calling "commit" or "rollback" explicitly while "AutoCommit" is on
   would be ineffective because the changes would have already been com-
   mited.

   Changing "AutoCommit" from off to on will trigger a "commit".
   For databases which don’t support a specific auto-commit mode, the
   driver has to commit each statement automatically using an explicit
   "COMMIT" after it completes successfully (and roll it back using an
   explicit "ROLLBACK" if it fails).  The error information reported to
   the application will correspond to the statement which was executed,
   unless it succeeded and the commit or rollback failed.

 * Databases in which a transaction must be explicitly started

   For these databases, the intention is to have them act like databases
   in which a transaction is always active (as described above).
   To do this, the driver will automatically begin an explicit
transaction
   when "AutoCommit" is turned off, or after a "commit" or
   "rollback" (or
   when the application issues the next database operation after one of
   those events).

   In this way, the application does not have to treat these databases 
   as a special case.



On Thu, 2008-05-29 at 16:27 +0000, ajos1 at onion wrote:
> Re: commit ineffective with AutoCommit enabled... MailWatch.pm
> 
> commit ineffective with AutoCommit enabled... MailWatch.pm
> ==========================================================
> 
> 
> OKAY... MY FIRST SOLUTION IS WRONG!!!  This one works...
> OKAY... MY FIRST SOLUTION IS WRONG!!!  This one works...
> OKAY... MY FIRST SOLUTION IS WRONG!!!  This one works...
> OKAY... MY FIRST SOLUTION IS WRONG!!!  This one works...
> 
> 
> Basically... EVEN with AUTOCOMMIT ... there are times when "$dbh->commit" does work without warnings... so my original solution is not good news... as you could miss out on some crucial commits... if the disconnect statement does not do it for you...
> 
> 
> /DBI-1.604/Driver.xst says: "Some databases will automatically commit on graceful disconnect."  (Ie) Not all do...
> 
> 
> Here is the new solution... it leaves the commit as it was... but just turns off the warning temporarily! (Oh and it works)...
> 
> (ie) $dbh->{Warn} = 0;
> 
> 
> 
> 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);
>    ##### AJOS1 CHANGE #####
>    $dbh->{Warn} = 0;
>    ##### AJOS1 CHANGE #####
>    $dbh->commit;
>    $dbh->disconnect;
>    exit;
>  }
> 
> ==
> =====================================================================
> =
> = "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