From: Peter Rabbitson Date: Sun, 14 Nov 2010 12:37:28 +0000 (+0100) Subject: Fix a forgotten nested try::tiny usage X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=052b8ce2ec154827133b0b08042487c5617300aa;p=dbsrgits%2FDBIx-Class-Historic.git Fix a forgotten nested try::tiny usage --- diff --git a/Changes b/Changes index 0392453..d464eea 100644 --- a/Changes +++ b/Changes @@ -16,16 +16,17 @@ Revision history for DBIx::Class on insert - Fixed incorrect composition of select/as/columns attributes during chaining (RT#61235) + - Proper serialization of resultsets with open cursors - Refactor handling of RDBMS-side values during insert() - fix regression of inserts into a Postgres / ::Replicated combination - Missing dependency check in t/60core.t (RT#62635) - Fix regressions in IC::DT registration logic + - Fix infinite loops on old perls with a recent Try::Tiny + + * Misc - Switch all serialization to use Storable::nfreeze for portable architecture independent ice - * Fixes - - Proper serialization of resultsets with open cursors - 0.08124 2010-10-28 14:23 (UTC) * New Features / Changes - Add new -ident "function" indicating rhs is a column name diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index cd2da9e..c7f0ec8 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1849,15 +1849,14 @@ sub _dbh_execute_inserts_with_no_binds { } catch { $err = shift; + }; + + # Make sure statement is finished even if there was an exception. + try { + $sth->finish } - finally { - # Make sure statement is finished even if there was an exception. - try { - $sth->finish - } - catch { - $err = shift unless defined $err; - }; + catch { + $err = shift unless defined $err; }; $self->throw_exception($err) if defined $err; diff --git a/t/52leaks.t b/t/52leaks.t index 79f6a1c..4f75810 100644 --- a/t/52leaks.t +++ b/t/52leaks.t @@ -97,9 +97,10 @@ unless (DBICTest::RunMode->is_plain) { ok ($storage->connected, 'we are connected'); - my $row_obj = $rs->next; + my $row_obj = $rs->search({}, { rows => 1})->next; # so that commits/rollbacks work ok ($row_obj, 'row from db'); + # txn_do to invoke more codepaths my ($mc_row_obj, $pager, $pager_explicit_count) = $schema->txn_do (sub { my $artist = $rs->create ({ @@ -122,6 +123,25 @@ unless (DBICTest::RunMode->is_plain) { # based on 66 per 10 pages is ($pager_explicit_count->last_page, 7, 'Correct last page'); + # do some population (invokes some extra codepaths) + # also exercise the guard code and the manual txn control + { + my $guard = $schema->txn_scope_guard; + # populate with bindvars + $rs->populate([{ name => 'James Bound' }]); + $guard->commit; + + $schema->txn_begin; + # populate mixed + $rs->populate([{ name => 'James Rebound', rank => \ '11' }]); + $schema->txn_commit; + + $schema->txn_begin; + # and without bindvars + $rs->populate([{ name => \ '"James Unbound"' }]); + $schema->txn_rollback; + } + my $base_collection = { schema => $schema, storage => $storage,