Re: do I need a rollback() after commit that fails?

Поиск
Список
Период
Сортировка
Искать
От
Andy Colson
Тема
Re: do I need a rollback() after commit that fails?
Дата
Msg-id
4AC26674.2030201@squeakycode.net
Ответ на
Список
Дерево обсуждения
do I need a rollback() after commit that fails? Vick Khera <vivek@khera.org>
Re: do I need a rollback() after commit that fails? APseudoUtopia <apseudoutopia@gmail.com>
Re: do I need a rollback() after commit that fails? Andy Colson <andy@squeakycode.net>
Re: do I need a rollback() after commit that fails? Vick Khera <vivek@khera.org>
Re: do I need a rollback() after commit that fails? Alban Hertroys <dalroi@solfertje.student.utwente.nl>
Vick Khera wrote:
> I'm running Pg 8.3.7 on FreeBSD 7.2.
> 
> I have some code in Perl that does a bunch of inserts and updates with
> all constraints deferred.  On occasion, one of the FK's gets violated
> and the transaction commit fails.
> 
> I trap this with code like this:
> 
>     unless ($dbh->commit()) {
>       warn "commit failure ".$dbh->errstr;
>       $dbh->rollback();
>       return 'failed';
>     }
> 
> The DBI is telling me that the rollback() is useless with AutoCommit
> is on (which it is).
> 

Unless I'm mistaken, if AutoCommit is enabled, then each statement will 
be commit for you.  The commit() and the rollback() are both useless.

-Andy
В списке pgsql-general по дате отправления
От: CG
Дата:
От: Tom Lane
Дата:
FAQ