From: Rafael Kitover Date: Sun, 30 Aug 2009 16:19:46 +0000 (+0000) Subject: added txn_scope_guards for blob operations X-Git-Tag: v0.08112~14^2~35 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=aee988d2051f998d1a0d2a2621ee49f49ce87aa1;p=dbsrgits%2FDBIx-Class.git added txn_scope_guards for blob operations --- diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index 43b6e6c..46915ba 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -289,13 +289,16 @@ sub _execute { sub last_insert_id { shift->_identity } -# override to handle TEXT/IMAGE and to do a transaction if necessary +# handles TEXT/IMAGE and transaction for last_insert_id sub insert { my $self = shift; my ($source, $to_insert) = @_; my $blob_cols = $self->_remove_blob_cols($source, $to_insert); +# insert+blob insert done atomically + my $guard = $self->txn_scope_guard if %$blob_cols; + my $need_last_insert_id = 0; my ($identity_col) = @@ -324,6 +327,8 @@ sub insert { $self->_insert_blobs($source, $blob_cols, $to_insert) if %$blob_cols; + $guard->commit if $guard; + return $updated_cols; } @@ -335,6 +340,9 @@ sub update { my $blob_cols = $self->_remove_blob_cols($source, $fields); +# update+blob update(s) done atomically + my $guard = $self->txn_scope_guard if %$blob_cols; + my @res; if ($wantarray) { @res = $self->next::method(@_); @@ -348,6 +356,8 @@ sub update { $self->_update_blobs($source, $blob_cols, $where) if %$blob_cols; + $guard->commit if %$blob_cols; + return $wantarray ? @res : $res[0]; }