X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI.pm;fp=lib%2FDBIx%2FClass%2FStorage%2FDBI.pm;h=0a3e9c4b63d462191c77d4b2e343772bdf2bf82d;hb=39e45539f3373a1f84da5cbefc5b9919484ee384;hp=657c91923c009799d59f6e5b0faa9ce6c59296ee;hpb=e59c17fe744031457d375cb464250950881f4c56;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 657c919..0a3e9c4 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -303,8 +303,10 @@ sub ensure_connected { sub dbh { my ($self) = @_; - $self->_dbh(undef) - if $self->_connection_pid && $self->_connection_pid != $$; + if($self->_connection_pid && $self->_connection_pid != $$) { + $self->_dbh->{InactiveDestroy} = 1; + $self->_dbh(undef) + } $self->ensure_connected; return $self->_dbh; } @@ -355,11 +357,15 @@ sub _connect { Calls begin_work on the current dbh. +See L for the txn_do() method, which allows for +an entire code block to be executed transactionally. + =cut sub txn_begin { my $self = shift; - $self->dbh->begin_work if $self->{transaction_depth}++ == 0 and $self->dbh->{AutoCommit}; + $self->dbh->begin_work + if $self->{transaction_depth}++ == 0 and $self->dbh->{AutoCommit}; } =head2 txn_commit @@ -380,7 +386,9 @@ sub txn_commit { =head2 txn_rollback -Issues a rollback against the current dbh. +Issues a rollback against the current dbh. A nested rollback will +throw a L exception, +which allows the rollback to propagate to the outermost transaction. =cut @@ -412,8 +420,8 @@ sub _execute { my ($sql, @bind) = $self->sql_maker->$op($ident, @args); unshift(@bind, @$extra_bind) if $extra_bind; if ($self->debug) { - my @debug_bind = map { defined $_ ? $_ : 'NULL' } @bind; - $self->debugfh->print("$sql: @debug_bind\n"); + my @debug_bind = map { defined $_ ? qq{`$_'} : q{`NULL'} } @bind; + $self->debugfh->print("$sql: " . join(', ', @debug_bind) . "\n"); } my $sth = $self->sth($sql,$op); $self->throw_exception("no sth generated via sql: $sql") unless $sth;