From: Rafael Kitover Date: Thu, 10 Sep 2009 00:16:03 +0000 (+0000) Subject: do blob update over _insert_dbh X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=961a138374e56f6089f5fa0eeee7d6251d652311;p=dbsrgits%2FDBIx-Class-Historic.git do blob update over _insert_dbh --- diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index 53b2f50..7fcf001 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -286,7 +286,7 @@ sub insert { || (!$blob_cols && !$dumb_last_insert_id) ) { return $self->_insert ( - $source, $to_insert, $blob_cols, $identity_col, $next + $next, $source, $to_insert, $blob_cols, $identity_col ); } @@ -297,9 +297,6 @@ sub insert { local $self->{_dbh}; - # localize so it appears right if we blow out with an exception - local $self->{transaction_depth} = 0; - $self->_insert_dbh($self->_connect(@{ $self->_dbi_connect_info })) unless $self->_insert_dbh; @@ -311,7 +308,7 @@ sub insert { $self->_insert_dbh($self->_dbh); my $updated_cols = $self->_insert ( - $source, $to_insert, $blob_cols, $identity_col, $next + $next, $source, $to_insert, $blob_cols, $identity_col ); $guard->commit; @@ -321,7 +318,7 @@ sub insert { } sub _insert { - my ($self, $source, $to_insert, $blob_cols, $identity_col, $next) = @_; + my ($self, $next, $source, $to_insert, $blob_cols, $identity_col) = @_; my $updated_cols = $self->$next ($source, $to_insert); @@ -341,11 +338,24 @@ sub update { my ($source, $fields, $where) = @_; my $wantarray = wantarray; - my $blob_cols = $self->_remove_blob_cols($source, $fields); -# update+blob update(s) done atomically - my $guard = $self->txn_scope_guard if $blob_cols; + if (not $blob_cols) { + return $self->next::method(@_); + } + +# update+blob update(s) done atomically on separate connection (see insert) + local $self->{_dbh}; + + $self->_insert_dbh($self->_connect(@{ $self->_dbi_connect_info })) + unless $self->_insert_dbh; + + $self->{_dbh} = $self->_insert_dbh; + my $guard = $self->txn_scope_guard; + + # _dbh_begin_work in the guard may reconnect, + # so we update the accessor just in case + $self->_insert_dbh($self->_dbh); my @res; if ($wantarray) { @@ -358,9 +368,9 @@ sub update { $self->next::method(@_); } - $self->_update_blobs($source, $blob_cols, $where) if $blob_cols; + $self->_update_blobs($source, $blob_cols, $where); - $guard->commit if $guard; + $guard->commit; return $wantarray ? @res : $res[0]; }