[CDBI] Is standard idiom for transactions really safe?

Phil Mitchell phil at 2people.org
Thu Mar 2 06:21:45 GMT 2006

In the standard idiom, you turn off AutoCommit in db_Main, then wrap all
your code in an eval:

   local $class->db_Main->{ AutoCommit };
   eval { $code->() };

Here's what I don't understand:

This works on the assumption that db_Main() always provides the same dbh.
But does it? That is the job of Ima::DBI, which basically uses
DBI->connect_cached(). connect_cached *tries* to return the same dbh, but
afaik can't guarantee it. And in the rare event that dbh changes in the
middle of a transaction, the new dbh will not have AutoCommit turned off.

What am I missing?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digitalcraftsmen.net/mailman/private/classdbi/attachments/20060301/80d5aca3/attachment.htm

More information about the ClassDBI mailing list