From: Peter Rabbitson Date: Mon, 16 Feb 2009 08:48:49 +0000 (+0000) Subject: Some cleanups of oracle patch X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c2d7baefbd8f557d1c0be68776ea47366c2f80dc;p=dbsrgits%2FDBIx-Class-Historic.git Some cleanups of oracle patch --- diff --git a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm index 3ca19d9..d12e3ff 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm @@ -25,7 +25,6 @@ This class implements autoincrements for Oracle. =cut use Carp::Clan qw/^DBIx::Class/; -use Scalar::Util (); use base qw/DBIx::Class::Storage::DBI::MultiDistinctEmulation/; @@ -88,25 +87,22 @@ sub _sequence_fetch { sub connected { my $self = shift; - if ($self->SUPER::connected(@_)) { + if (not $self->SUPER::connected(@_)) { + return 0; + } + else { my $dbh = $self->_dbh; - my $ping_sth = $dbh->prepare_cached("select 1 from dual"); - local $dbh->{RaiseError} = 1; + eval { + my $ping_sth = $dbh->prepare_cached("select 1 from dual"); $ping_sth->execute; $ping_sth->finish; }; - if ($@) { - return 0; - } else { - return 1; - } + return $@ ? 0 : 1; } - - return 0; } sub _dbh_execute { @@ -114,12 +110,10 @@ sub _dbh_execute { my ($dbh, $op, $extra_bind, $ident, $bind_attributes, @args) = @_; my $wantarray = wantarray; - my @res; - my $exception; - my $try = 2; - - while ($try--) { + my (@res, $exception, $retried); + + do { eval { if ($wantarray) { @res = $self->SUPER::_dbh_execute(@_); @@ -129,14 +123,14 @@ sub _dbh_execute { }; $exception = $@; if ($exception =~ /ORA-01003/) { -# ORA-01003: no statement parsed (someone changed the table somehow, -# invalidating your cursor.) + # ORA-01003: no statement parsed (someone changed the table somehow, + # invalidating your cursor.) my ($sql, $bind) = $self->_prep_for_execute($op, $extra_bind, $ident, \@args); delete $dbh->{CachedKids}{$sql}; } else { last; } - } + } while (not $retried++); $self->throw_exception($exception) if $exception;