| 1 | 13 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package DBIx::Connector::Driver; | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 13 | our $VERSION = '0.60'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | DRIVERS: { | ||||||||||||||||||||||||||||
| 8 | 13 | my %DRIVERS; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 32 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||
| 11 | 32 | my ($class, $driver) = @_; | |||||||||||||||||||||||||||
| 12 | 32 | ▶ | return $DRIVERS{$driver} ||= do { | ||||||||||||||||||||||||||
|
Condition66%2/3
$DRIVERS{$driver} ||= do {
my $subclass = 'DBIx::Connector::Driver' . "::$driver";
(my $path = $subclass) =~ s[::][/]g;
local $@;
my $ok = eval "require $subclass";
die $@ unless $ok or $@ =~ /^Can't locate $path\.pm in \@INC \(/;
bless {"driver", $driver}, $ok ? $subclass : $class
}
MC/DC0%0/2
$DRIVERS{$driver} ||= do {
my $subclass = 'DBIx::Connector::Driver' . "::$driver";
(my $path = $subclass) =~ s[::][/]g;
local $@;
my $ok = eval "require $subclass";
die $@ unless $ok or $@ =~ /^Can't locate $path\.pm in \@INC \(/;
bless {"driver", $driver}, $ok ? $subclass : $class
}
$DRIVERS{$driver}
do {
my $subclass = 'DBIx::Connector::Driver' . "::$driver";
(my $path = $subclass) =~ s[::][/]g;
local $@;
my $ok = eval "require $subclass";
die $@ unless $ok or $@ =~ /^Can't locate $path\.pm in \@INC \(/;
bless {"driver", $driver}, $ok ? $subclass : $class
}
Truth table66%2/3
A ||= B
A= $DRIVERS{$driver}B= do {
my $subclass = 'DBIx::Connector::Driver' . "::$driver";
(my $path = $subclass) =~ s[::][/]g;
local $@;
my $ok = eval "require $subclass";
die $@ unless $ok or $@ =~ /^Can't locate $path\.pm in \@INC \(/;
bless {"driver", $driver}, $ok ? $subclass : $class
}
| |||||||||||||||||||||||||||||
| 13 | 12 | my $subclass = __PACKAGE__ . "::$driver"; | |||||||||||||||||||||||||||
| 14 | 12 | ( my $path = $subclass ) =~ s!::!/!g; | |||||||||||||||||||||||||||
| 15 | 12 | local $@; | |||||||||||||||||||||||||||
| 16 | 12 | my $ok = eval "require $subclass"; | |||||||||||||||||||||||||||
| 17 | 12 | ▶ | die $@ unless $ok or $@ =~ /^Can't locate $path\.pm in \@INC \(/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ok or $@ =~ /^Can't locate $path\.pm in \@INC \(/
MC/DC0%0/2
$ok or $@ =~ /^Can't locate $path\.pm in \@INC \(/
$ok
$@ =~ /^Can't locate $path\.pm in \@INC \(/
Truth table66%2/3
A or B
A= $okB= $@ =~ /^Can't locate $path\.pm in \@INC \(/
| |||||||||||||||||||||||||||||
| 18 | 12 | ▶ | bless { driver => $driver } => ( $ok ? $subclass : $class ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | }; | ||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 13 | ▶ | sub _connect { | ||||||||||||||||||||||||||
|
Subroutine
_connect: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 60 | my ($self, $dbh, $dsn, $username, $password, $attrs) = @_; | |||||||||||||||||||||||||||
| 25 | 60 | $dbh; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 60 | ▶ | sub ping { | ||||||||||||||||||||||||||
|
Subroutine
ping: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 29 | 60 | my ($self, $dbh) = @_; | |||||||||||||||||||||||||||
| 30 | 60 | $dbh->ping; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 62 | ▶ | sub begin_work { | ||||||||||||||||||||||||||
|
Subroutine
begin_work: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 34 | 62 | my ($self, $dbh) = @_; | |||||||||||||||||||||||||||
| 35 | 62 | $dbh->begin_work; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 45 | ▶ | sub commit { | ||||||||||||||||||||||||||
|
Subroutine
commit: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 39 | 45 | my ($self, $dbh) = @_; | |||||||||||||||||||||||||||
| 40 | 45 | $dbh->commit; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 3 | ▶ | sub rollback { | ||||||||||||||||||||||||||
|
Subroutine
rollback: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 3 | my ($self, $dbh) = @_; | |||||||||||||||||||||||||||
| 45 | 3 | $dbh->rollback; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 11 | ▶ | sub _rollback { | ||||||||||||||||||||||||||
|
Subroutine
_rollback: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 49 | 11 | my ($self, $dbh, $err) = @_; | |||||||||||||||||||||||||||
| 50 | 11 | local $@; | |||||||||||||||||||||||||||
| 51 | 11 | eval { $dbh->rollback }; | |||||||||||||||||||||||||||
| 52 | 11 | ▶ | return $@ ? DBIx::Connector::TxnRollbackError->new( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | error => $err, | ||||||||||||||||||||||||||||
| 54 | rollback_error => $@, | ||||||||||||||||||||||||||||
| 55 | ) : $err; | ||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 4 | ▶ | sub _rollback_and_release { | ||||||||||||||||||||||||||
|
Subroutine
_rollback_and_release: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||
| 59 | 4 | my ($self, $dbh, $name, $err) = @_; | |||||||||||||||||||||||||||
| 60 | 4 | local $@; | |||||||||||||||||||||||||||
| 61 | 4 | eval { | |||||||||||||||||||||||||||
| 62 | 4 | $self->rollback_to($dbh, $name); | |||||||||||||||||||||||||||
| 63 | 0 | $self->release($dbh, $name); | |||||||||||||||||||||||||||
| 64 | }; | ||||||||||||||||||||||||||||
| 65 | 4 | ▶ | return $@ ? DBIx::Connector::SvpRollbackError->new( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | error => $err, | ||||||||||||||||||||||||||||
| 67 | rollback_error => $@, | ||||||||||||||||||||||||||||
| 68 | ) : $err; | ||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub savepoint { | ||||||||||||||||||||||||||
|
Subroutine
savepoint: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 0 | my ($self, $dbh, $name) = @_; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub release { | ||||||||||||||||||||||||||
|
Subroutine
release: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 76 | 0 | my ($self, $dbh, $name) = @_; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub rollback_to { | ||||||||||||||||||||||||||
|
Subroutine
rollback_to: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 80 | 0 | my ($self, $dbh, $name) = @_; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | ROLLBACKERR: { | ||||||||||||||||||||||||||||
| 84 | package DBIx::Connector::RollbackError; | ||||||||||||||||||||||||||||
| 85 | 13 | our $VERSION = '0.58'; | |||||||||||||||||||||||||||
| 86 | # an exception is always true | ||||||||||||||||||||||||||||
| 87 | 13 | ▶ | use overload bool => sub {1}, '""' => 'as_string', fallback => 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 11 | ▶ | sub new { my $c = shift; bless {@_} => $c; } | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 90 | 27 | ▶ | sub error { shift->{error} } | ||||||||||||||||||||||||||
|
Subroutine
error: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 91 | 24 | ▶ | sub rollback_error { shift->{rollback_error} } | ||||||||||||||||||||||||||
|
Subroutine
rollback_error: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 92 | 15 | ▶ | sub as_string { | ||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 93 | 15 | my $self = shift; | |||||||||||||||||||||||||||
| 94 | 15 | my $label = $self->_label; | |||||||||||||||||||||||||||
| 95 | 15 | return "$label aborted: " . $self->error | |||||||||||||||||||||||||||
| 96 | . "$label rollback failed: " . $self->rollback_error; | ||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | package DBIx::Connector::TxnRollbackError; | ||||||||||||||||||||||||||||
| 100 | 13 | our $VERSION = '0.58'; | |||||||||||||||||||||||||||
| 101 | 13 | our @ISA = qw( DBIx::Connector::RollbackError ); | |||||||||||||||||||||||||||
| 102 | 9 | ▶ | sub _label { 'Transaction' } | ||||||||||||||||||||||||||
|
Subroutine
_label: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | package DBIx::Connector::SvpRollbackError; | ||||||||||||||||||||||||||||
| 105 | 13 | our $VERSION = '0.58'; | |||||||||||||||||||||||||||
| 106 | 13 | our @ISA = qw( DBIx::Connector::RollbackError ); | |||||||||||||||||||||||||||
| 107 | 6 | ▶ | sub _label { 'Savepoint' } | ||||||||||||||||||||||||||
|
Subroutine
_label: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 13 | 1; | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | __END__ | ||||||||||||||||||||||||||||