DB2/Storage/Cursor.pm

filter: Statementstmt 95.6% 44 / 46 Branchbran 56.2% 9 / 16 Conditioncond 31.5% 6 / 19 MC/DCmcdc 9.0% 1 / 11 Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 68.9% 71 / 103 CC 18 SCAR 24.3
CC
18
Cov
73%
all
21.1
decode_rows
9.4
next
2.0
CRAP 11.4
« DB2/Diff/Column.pm ↑ Summary DB2/Storage.pm »
1 package DBIO::DB2::Storage::Cursor;
2 # ABSTRACT: Reads the character columns of a Db2 result as characters
3  
4 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 13 our $VERSION = '0.900004';
8  
9 13 ▶use base 'DBIO::Storage::DBI::Cursor';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 13 ▶use List::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 13 ▶use DBIO::Util qw(shuffle_unordered_resultsets);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 # the TYPE the DBD reports for a character column: SQL_CHAR, SQL_VARCHAR,
16 # SQL_LONGVARCHAR, the wide forms, and the CLI codes of CLOB and DBCLOB
17 13 my %CHARACTER_TYPE = map { $_ => 1 } (1, 12, -1, -8, -9, -10, -99, -350, 40);
18  
19  
20 6 ▶sub decode_rows {
Subroutine decode_rows: called CC=9 SCAR=22.4
Pod documented
21 6 my ($class, $storage, $sth, @rows) = @_;
22 6 ▶ return unless $sth && $storage->_utf8_database;
Branch: 1 branch
BranchTrueFalseTotal
unless $sth and $storage->_utf8_database 2 4 6
Condition66%2/3
$sth and $storage->_utf8_database
!ll&&!rl&&r
024
MC/DC50%1/2
$sth and $storage->_utf8_database
$sth $storage->_utf8_database
Truth table66%2/3
A and B
A= $sthB= $storage->_utf8_database
ABresult
0X0
100
111
23  
24 4 ▶ my $types = $sth->{TYPE} || [];
Condition50%1/2
$sth->{'TYPE'} || []
l!l
40
MC/DC0%0/1
$sth->{'TYPE'} || []
$sth->{'TYPE'}
Truth table50%1/2
A
A= $sth->{'TYPE'}
Aresult
11
00
25 4 ▶ my @chars = grep { $CHARACTER_TYPE{ $types->[$_] // '' } } 0 .. $#$types;
Condition50%1/2
$types->[$_] // ""
l!l
110
MC/DC0%0/1
$types->[$_] // ""
$types->[$_]
Truth table50%1/2
A
A= $types->[$_]
Aresult
11
00
26 4 ▶ return unless @chars;
Branch: 1 branch
BranchTrueFalseTotal
unless @chars 0 4 4
27  
28 4 for my $row (@rows) {
29 5 for my $i (@chars) {
30 9 ▶ utf8::decode($row->[$i]) if defined $row->[$i];
Branch: 1 branch
BranchTrueFalseTotal
if defined $row->[$i] 7 2 9
31 }
32 }
33 4 return;
34 }
35  
36  
37 3 ▶sub next {
Subroutine next: called CC=2 SCAR=7.0
Pod documented
38 3 my $self = shift;
39 3 my @row = $self->next::method(@_);
40 3 ▶ return @row unless @row;
Branch: 1 branch
BranchTrueFalseTotal
unless @row 0 3 3
41 3 $self->decode_rows($self->storage, $self->sth, \@row);
42 3 return @row;
43 }
44  
45  
46 2 ▶sub all {
Subroutine all: called CC=9 SCAR=30.5
Pod documented
47 2 my $self = shift;
48  
49 # with a software limit core's all goes through next
50 return $self->next::method(@_)
51 if $self->{attrs}{software_limit}
52 2 ▶ && ($self->{attrs}{offset} || $self->{attrs}{rows});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"attrs"}{"software_limit"} and $self->{"attrs"}{"offset"} || $self->{"attrs"}{"rows"} 0 2 2
Condition16%1/6
$self->{"attrs"}{"software_limit"} and $self->{"attrs"}{"offset"} || $self->{"attrs"}{"rows"}
!ll&&!rl&&r
200
$self->{"attrs"}{"offset"} or $self->{"attrs"}{"rows"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$self->{"attrs"}{"software_limit"} and $self->{"attrs"}{"offset"} || $self->{"attrs"}{"rows"}
$self->{"attrs"}{"software_limit"} $self->{"attrs"}{"offset"} $self->{"attrs"}{"rows"}
Truth table25%1/4
A and B or C
A= $self->{"attrs"}{"software_limit"}B= $self->{"attrs"}{"offset"}C= $self->{"attrs"}{"rows"}
ABCresult
0XX0
1000
11X1
1011
53  
54 2 my $sth;
55 2 ▶ if ($sth = $self->sth) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sth = $self->sth) 0 2 2
56 0 ▶ $sth->finish if ( ! $self->{_done} and $sth->FETCH('Active') );
Branch: 1 branch
BranchTrueFalseTotal
if not $self->{"_done"} and $sth->FETCH("Active") 0 0 0
Condition0%0/3
not $self->{"_done"} and $sth->FETCH("Active")
!ll&&!rl&&r
000
MC/DC0%0/2
not $self->{"_done"} and $sth->FETCH("Active")
not $self->{"_done"} $sth->FETCH("Active")
Truth table0%0/3
not(A) and B
A= not $self->{"_done"}B= $sth->FETCH("Active")
ABresult
0X0
100
111
57 0 $self->sth(undef);
58 }
59  
60 2 (undef, $sth) = $self->storage->_select( @{$self->{args}} );
61  
62 2 my @rows = @{ $sth->fetchall_arrayref };
63 2 $self->decode_rows($self->storage, $sth, @rows);
64 return (shuffle_unordered_resultsets and ! $self->{attrs}{order_by})
65 2 ▶ ? List::Util::shuffle(@rows)
Branch: 1 branch
BranchTrueFalseTotal
&shuffle_unordered_resultsets() && !$self->{'attrs'}{'order_by'} ? : 0 2 2
Condition33%1/3
&shuffle_unordered_resultsets() and not $self->{"attrs"}{"order_by"}
!ll&&!rl&&r
200
MC/DC0%0/2
&shuffle_unordered_resultsets() and not $self->{"attrs"}{"order_by"}
&shuffle_unordered_resultsets() not $self->{"attrs"}{"order_by"}
Truth table33%1/3
A and not(B)
A= &shuffle_unordered_resultsets()B= not $self->{"attrs"}{"order_by"}
ABresult
0X0
100
111
66 : @rows;
67 }
68  
69 13 1;
70  
71 __END__
« DB2/Diff/Column.pm ↑ Summary DB2/Storage.pm »