blib/lib/DBIO/Replicated/DebugProxy.pm

filter: Statementstmt 75.0% 39 / 52 Branchbran 33.3% 2 / 6 Conditioncond 50.0% 5 / 10 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 52.3% 11 / 21 Podpod 100% 15 / 15 totaltotal 66.0% 72 / 109 CC 8 SCAR 14.4
CC
8
Cov
68%
_decorate_sql
11.1
callback
2.0
debugfh
2.0
CRAP 4.2
« blib/lib/DBIO/Storage/Statistics.pm ↑ Summary blib/lib/DBIO/DeploymentHandler.pm »
1 package DBIO::Replicated::DebugProxy;
2 # ABSTRACT: Prefix trace output with replicated backend identity
3  
4 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 18 our $VERSION = '0.900007';
8  
9 18 ▶use Scalar::Util 'reftype';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 18 ▶use DBIO::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 18 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 106 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
15 106 my ($class, %args) = @_;
16 return bless {
17 backend => $args{backend},
18 target => $args{target},
19 106 }, $class;
20 }
21  
22 168 ▶sub backend { $_[0]->{backend} }
Subroutine backend: called CC=1 SCAR=0.0
Pod documented
23 116 ▶sub target { $_[0]->{target} }
Subroutine target: called CC=1 SCAR=0.0
Pod documented
24  
25  
26 0 ▶sub callback { shift->target->callback(@_) }
Subroutine callback: not called CC=1 SCAR=6.9
Pod documented
27 0 ▶sub debugfh { shift->target->debugfh(@_) }
Subroutine debugfh: not called CC=1 SCAR=6.9
Pod documented
28 0 ▶sub silence { shift->target->silence(@_) }
Subroutine silence: not called CC=1 SCAR=6.9
Pod documented
29 0 ▶sub print { shift->target->print(@_) }
Subroutine print: not called CC=1 SCAR=6.9
Pod documented
30 0 ▶sub txn_begin { shift->target->txn_begin(@_) }
Subroutine txn_begin: not called CC=1 SCAR=6.9
Pod documented
31 0 ▶sub txn_commit { shift->target->txn_commit(@_) }
Subroutine txn_commit: not called CC=1 SCAR=6.9
Pod documented
32 0 ▶sub txn_rollback { shift->target->txn_rollback(@_) }
Subroutine txn_rollback: not called CC=1 SCAR=6.9
Pod documented
33 0 ▶sub svp_begin { shift->target->svp_begin(@_) }
Subroutine svp_begin: not called CC=1 SCAR=6.9
Pod documented
34 0 ▶sub svp_release { shift->target->svp_release(@_) }
Subroutine svp_release: not called CC=1 SCAR=6.9
Pod documented
35 0 ▶sub svp_rollback { shift->target->svp_rollback(@_) }
Subroutine svp_rollback: not called CC=1 SCAR=6.9
Pod documented
36  
37  
38 29 ▶sub query_start {
Subroutine query_start: called CC=1 SCAR=0.0
Pod documented
39 29 my ($self, $sql, @bind) = @_;
40 29 return $self->target->query_start($self->_decorate_sql($sql), @bind);
41 }
42  
43 27 ▶sub query_end {
Subroutine query_end: called CC=1 SCAR=0.0
Pod documented
44 27 my ($self, $sql, @bind) = @_;
45 27 return $self->target->query_end($self->_decorate_sql($sql), @bind);
46 }
47  
48 56 ▶sub _decorate_sql {
Subroutine _decorate_sql: called CC=8 SCAR=24.0
49 56 my ($self, $sql) = @_;
50  
51 56 my $info = eval { $self->backend->storage->_dbi_connect_info };
52 56 ▶ $info = [] unless ref $info eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $info eq "ARRAY" 0 56 56
53 56 my $dsn = eval { $self->backend->dsn };
54 56 ▶ $dsn ||= $info->[0];
Condition66%2/3
$dsn ||= $info->[0]
l!l&&r!l&&!r
23330
MC/DC0%0/2
$dsn ||= $info->[0]
$dsn $info->[0]
Truth table66%2/3
A ||= B
A= $dsnB= $info->[0]
ABresult
1X1
011
000
55  
56 # the backend is named by its DSN: never the password in it (karr k297)
57 56 $dsn = DBIO::Util::mask_connect_secrets($dsn, [ $dsn, @{$info}[1 .. $#$info] ]);
58  
59 56 ▶ my $kind = uc($self->backend->kind || 'backend');
Condition50%1/2
$self->backend->kind || 'backend'
l!l
560
MC/DC0%0/1
$self->backend->kind || 'backend'
$self->backend->kind
Truth table50%1/2
A
A= $self->backend->kind
Aresult
11
00
60 56 my ($op, $rest) = (($sql =~ m/^(\w+)(.+)$/), 'NOP', ' NO SQL');
61  
62 56 return do {
63 56 ▶ if ((reftype($dsn) || '') ne 'CODE' && defined $dsn) {
Branch: 2 branches
BranchTrueFalseTotal
if ((builtin::reftype($dsn) || '') ne 'CODE' and defined $dsn) { } 56 0 56
elsif (my $id = eval { do { $self->backend->id } }) { } 0 0 0
Condition40%2/5
(builtin::reftype($dsn) || "") ne "CODE" and defined $dsn
!ll&&!rl&&r
0056
builtin::reftype($dsn) || ''
l!l
056
MC/DC0%0/2
(builtin::reftype($dsn) || "") ne "CODE" and defined $dsn
builtin::reftype($dsn) defined $dsn
Truth table0%0/3
A and B
A= builtin::reftype($dsn)B= defined $dsn
ABresult
0X0
100
111
64 56 "$op [DSN_$kind=$dsn]$rest";
65 }
66 0 elsif (my $id = eval { $self->backend->id }) {
67 0 "$op [$kind=$id]$rest";
68 }
69 else {
70 0 "$op [$kind]$rest";
71 }
72 };
73 }
74  
75 18 1;
76  
77 __END__
« blib/lib/DBIO/Storage/Statistics.pm ↑ Summary blib/lib/DBIO/DeploymentHandler.pm »