File Coverage

blib/lib/DBIx/Connector/Driver/Oracle.pm
Criterion Covered Total %
statement 9 19 47.3
branch 0 2 0.0
condition n/a
subroutine 3 7 42.8
pod 4 4 100.0
total 16 32 50.0


line stmt bran cond sub pod time code
1 2     2   2602 use strict; use warnings;
  2     2   5  
  2         76  
  2         9  
  2         4  
  2         69  
2              
3             package DBIx::Connector::Driver::Oracle;
4              
5 2     2   10 use DBIx::Connector::Driver;
  2         4  
  2         491  
6              
7             our $VERSION = '0.59';
8             our @ISA = qw( DBIx::Connector::Driver );
9              
10             # Note from https://rt.cpan.org/Ticket/Display.html?id=47005:
11             # DBD::Oracle has some shutdown state in which it will return 1 on ping as
12             # long as the socket is still open. This however did not guarantee the server
13             # is any longer in a state to execute queries. So what happened was:
14             #
15             # 1) the weird state is reached
16             # 2) a txn_do takes place and fails on the first sql command
17             # 3) the code calls ping() and gets a connected reply
18             # 4) the txn_do is not retried
19             # 5) ...
20             # 6) users lose profit
21              
22             sub ping {
23 0     0 1   my ($self, $dbh) = @_;
24 0           eval {
25 0           local $dbh->{RaiseError} = 1;
26 0           $dbh->do('select 1 from dual');
27             };
28 0 0         return $@ ? 0 : 1;
29             }
30              
31             sub savepoint {
32 0     0 1   my ($self, $dbh, $name) = @_;
33 0           $dbh->do("SAVEPOINT $name");
34             }
35              
36             # Oracle automatically releases a savepoint when you start another one with
37             # the same name.
38 0     0 1   sub release { 1 }
39              
40             sub rollback_to {
41 0     0 1   my ($self, $dbh, $name) = @_;
42 0           $dbh->do("ROLLBACK TO SAVEPOINT $name");
43             }
44              
45             1;
46              
47             __END__