From: Peter Rabbitson Date: Thu, 10 Sep 2015 15:02:09 +0000 (+0100) Subject: Greatly simplify the ::Sybase::ASE::insert() override X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=216f29d9fe6628a4195176f59c0ed6cef6d68af5;p=dbsrgits%2FDBIx-Class.git Greatly simplify the ::Sybase::ASE::insert() override The _insert sub-method actually isn't used by anything else, and as such is not needed. The behavior has been verified to be identical by comparing DBIC_TRACE=1=logfile runs before and after the changes. Still - there may be dragons, if bisecting pay close attention to this fella --- diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm b/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm index 5bf1994..5ec7e79 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm @@ -376,47 +376,27 @@ sub insert { my $blob_cols = $self->_remove_blob_cols($source, $to_insert); - # do we need the horrific SELECT MAX(COL) hack? - my $need_dumb_last_insert_id = ( - $self->_perform_autoinc_retrieval - and - ( ($self->_identity_method||'') ne '@@IDENTITY' ) - ); - - my $next = $self->next::can; - - # we are already in a transaction, or there are no blobs - # and we don't need the PK - just (try to) do it + # if a new txn is needed - it must happen on the _writer/new connection (for now) + my $guard; if ( - ( !$blob_cols and !$need_dumb_last_insert_id ) - or - $self->transaction_depth + ! $self->transaction_depth + and + ( + $blob_cols + or + # do we need the horrific SELECT MAX(COL) hack? + ( + $self->_perform_autoinc_retrieval + and + ( ($self->_identity_method||'') ne '@@IDENTITY' ) + ) + ) ) { - $self->_insert ( - $next, $source, $to_insert, $blob_cols, $identity_col - ); - } - # otherwise use the _writer_storage to do the insert+transaction on another - # connection - else { - my $guard = $self->_writer_storage->txn_scope_guard; - - my $updated_cols = $self->_writer_storage->_insert ( - $next, $source, $to_insert, $blob_cols, $identity_col - ); - - $self->_identity($self->_writer_storage->_identity); - - $guard->commit; - - $updated_cols; + $self = $self->_writer_storage; + $guard = $self->txn_scope_guard; } -} -sub _insert { - my ($self, $next, $source, $to_insert, $blob_cols, $identity_col) = @_; - - my $updated_cols = $self->$next ($source, $to_insert); + my $updated_cols = $self->next::method ($source, $to_insert); $self->_insert_blobs ( $source, @@ -431,6 +411,8 @@ sub _insert { }, ) if $blob_cols; + $guard->commit if $guard; + return $updated_cols; }