Stas Bekman writes:
 > 
 > I was in the process of updating the Apache::DBI section of the guide with
 > the notes from the latest version of this package, and there is a new
 > section about Transactions. Since I use mysql, it doesn't have
 > transactions so I cannot it's not absolutely clear to me. For example why
 > the script should perform a rollback at the end? Isn't it only for the
 > case where the transaction has failed? Anybody?

The problem is (would be - Apache::DBI does an automatic rollback via
a PerlCleanupHandler) that if your script has started a transaction
but not committed it, then the next script that gets executed using
that particular database connection will continue the same
transaction. This will likely lead to a very bad situation in the
database with transactions spanning various requests, possible
deadlocks, etc.

So for persistent connections it is essential that the transaction
state at the end of each script be "clean" (i.e. either committed or
rolled back) whether the transactions are implicit (i.e. started due
to the AutoCommit flag being off) or explicit (the SQL executed has a
BEGIN TRAN in it somewhere).

Michael
-- 
Michael Peppler - Data Migrations Inc. - [EMAIL PROTECTED]
http://www.mbay.net/~mpeppler - [EMAIL PROTECTED] - AIM MPpplr
International Sybase User Group - http://www.isug.com
Sybase on Linux mailing list: [EMAIL PROTECTED]

Reply via email to