Skip to content

Commit

Permalink
Greatly simplify the ::Sybase::ASE::insert() override
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ribasushi committed Sep 10, 2015
1 parent 7e01774 commit 216f29d
Showing 1 changed file with 19 additions and 37 deletions.
56 changes: 19 additions & 37 deletions lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm
Expand Up @@ -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,
Expand All @@ -431,6 +411,8 @@ sub _insert {
},
) if $blob_cols;

$guard->commit if $guard;

return $updated_cols;
}

Expand Down

0 comments on commit 216f29d

Please sign in to comment.