From: Rafael Kitover Date: Tue, 29 Sep 2009 18:38:14 +0000 (+0000) Subject: make insert_bulk atomic X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9bb9f376db63441e2ee498d0eebee84bf32867be;p=dbsrgits%2FDBIx-Class-Historic.git make insert_bulk atomic --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index f31706d..f1cb9c0 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1393,6 +1393,8 @@ sub insert_bulk { sub _execute_array { my ($self, $source, $sth, $bind, $cols, $data, $after_exec_cb) = @_; + my $guard = $self->txn_scope_guard unless $self->{transaction_depth} != 0; + ## This must be an arrayref, else nothing works! my $tuple_status = []; @@ -1444,11 +1446,16 @@ sub _execute_array { ); } + $guard->commit if $guard; + return $rv; } sub _execute_array_empty { my ($self, $sth, $count) = @_; + + my $guard = $self->txn_scope_guard unless $self->{transaction_depth} != 0; + eval { my $dbh = $self->_get_dbh; local $dbh->{RaiseError} = 1; @@ -1474,6 +1481,8 @@ sub _execute_array_empty { $self->throw_exception($exception) if $exception; + $guard->commit if $guard; + return $count; } diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index 56319ef..f73f634 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -512,15 +512,8 @@ EOF && (not $is_identity_insert) && ($self->_identity_method||'') ne '@@IDENTITY'; - ($self, my ($guard)) = do { - if ($self->{transaction_depth} == 0 && $blob_cols && - $dumb_last_insert_id) { - ($self->_writer_storage, $self->_writer_storage->txn_scope_guard); - } - else { - ($self, undef); - } - }; + $self = $self->_writer_storage; + my $guard = $self->txn_scope_guard; $self->next::method(@_); @@ -548,7 +541,7 @@ EOF } } - $guard->commit if $guard; + $guard->commit; return; }