Re: rollback ineffective with AutoCommit enabled in do_transaction?

[prev] [thread] [next] [Date index for 2005/05/20]

From: Lonely Rolling Star
Subject: Re: rollback ineffective with AutoCommit enabled in do_transaction?
Date: 15:30 on 20 May 2005
>>Should I just leave out the if ( $@ ) ... part of the 
>>do_transaction because my database is automatically rolling back?
>
>Turn on DBI_TRACE and make sure it really is rolling back.

If I leave the call to dbi_rollback, I see this:

     -> rollback for DBD::Pg::db 
(DBIx::ContextualFetch::db=HASH(0x844c450)~0x8450ecc) thr#814bf18
rollback ineffective with AutoCommit enabled at 
/usr/local/share/perl/5.8.3/Ima/DBI.pm line 590.
  T  <- rollback= ( 1 ) [1 items] at DBI.pm line 590
Can't insert new Foo: DBD::Pg::st execute failed: ERROR:  duplicate 
key violates unique constraint "foo_pkey"


If I comment it out, I don't see anything in the trace about the 
rollback, but the part of that transaction before the error (the 
first create) doesn't happen. The table is empty in either case.


>>The "warn"s tell me that AutoCommit is back at point 4 in the test 
>>code below.
>
>Is it back at that point if no error occurs?  Maybe DBI resets the 
>handles attributes when it encounters an error.

It appears to be only in the error case. In the non-error case, AC is 
false at the end of the do_commit function. In the error case AC is 
true again immediately after the eval.


        -- 
        Aneel Nazareth -- http://eye-of-newt.com/nazareth --

(message missing)

Re: rollback ineffective with AutoCommit enabled in do_transaction?
Lonely Rolling Star 15:30 on 20 May 2005

Generated at 15:51 on 25 May 2005 by mariachi v0.52