[Jifty-commit] r5050 - in Jifty-DBI/branches/tisql: lib/Jifty/DBI
Jifty commits
jifty-commit at lists.jifty.org
Tue Feb 5 21:19:39 EST 2008
Author: ruz
Date: Tue Feb 5 21:19:38 2008
New Revision: 5050
Modified:
Jifty-DBI/branches/tisql/ (props changed)
Jifty-DBI/branches/tisql/lib/Jifty/DBI/Handle.pm
Log:
r4983 at cubic-pc (orig r4982): audreyt | 2008-02-02 08:56:25 +0300
* Jifty::DBI::Handle - When "begin_transaction", "commit" and "rollback"
did not succeed, the internal $TRANSDEPTH should be left unchanged.
(Otherwise, a failed ->commit will cause future transactions to never
really take place.)
Modified: Jifty-DBI/branches/tisql/lib/Jifty/DBI/Handle.pm
==============================================================================
--- Jifty-DBI/branches/tisql/lib/Jifty/DBI/Handle.pm (original)
+++ Jifty-DBI/branches/tisql/lib/Jifty/DBI/Handle.pm Tue Feb 5 21:19:38 2008
@@ -731,12 +731,18 @@
sub begin_transaction {
my $self = shift;
- $TRANSDEPTH++;
- if ( $TRANSDEPTH > 1 ) {
- return ($TRANSDEPTH);
- } else {
- return ( $self->dbh->begin_work );
+
+ if ( $TRANSDEPTH > 0 ) {
+ # We're inside a transaction.
+ $TRANSDEPTH++;
+ return $TRANSDEPTH;
}
+
+ my $rv = $self->dbh->begin_work;
+ if ($rv) {
+ $TRANSDEPTH++;
+ }
+ return $rv;
}
=head2 commit
@@ -752,13 +758,18 @@
Carp::confess(
"Attempted to commit a transaction with none in progress");
}
- $TRANSDEPTH--;
- if ( $TRANSDEPTH == 0 ) {
- return ( $self->dbh->commit );
- } else { #we're inside a transaction
- return ($TRANSDEPTH);
+ if ($TRANSDEPTH > 1) {
+ # We're inside a nested transaction.
+ $TRANSDEPTH--;
+ return $TRANSDEPTH;
+ }
+
+ my $rv = $self->dbh->commit;
+ if ($rv) {
+ $TRANSDEPTH--;
}
+ return $rv;
}
=head2 rollback [FORCE]
@@ -786,13 +797,22 @@
return ( $dbh->rollback );
}
- $TRANSDEPTH-- if ( $TRANSDEPTH >= 1 );
- if ( $TRANSDEPTH == 0 ) {
- return ( $dbh->rollback );
- } else { #we're inside a transaction
- return ($TRANSDEPTH);
+ if ($TRANSDEPTH == 0) {
+ # We're not actually in a transaction.
+ return 1;
}
+ if ($TRANSDEPTH > 1) {
+ # We're inside a nested transaction.
+ $TRANSDEPTH--;
+ return $TRANSDEPTH;
+ }
+
+ my $rv = $self->dbh->rollback;
+ if ($rv) {
+ $TRANSDEPTH--;
+ }
+ return $rv;
}
=head2 force_rollback
More information about the Jifty-commit
mailing list