blib/lib/DBI/PurePerl.pm

filter: Statementstmt 81.3% 664 / 816 Branchbran 63.4% 246 / 388 Conditioncond 61.7% 105 / 170 MC/DCmcdc 38.7% 38 / 98 Subroutinesub 88.2% 128 / 145 Podpod 71.4% 10 / 14 totaltotal 73.0% 1191 / 1631 CC 411 SCAR 31.9
CC
411
Cov
74%
_install_method
121.1
_install_method
121.1
_setup_handle
76.3
CRAP 24.2
« blib/lib/DBD/DBM.pm ↑ Summary blib/lib/DBI/ProxyServer.pm »
1 ########################################################################
2 package # hide from PAUSE
3 DBI;
4 # vim: ts=8:sw=4
5 ########################################################################
6 #
7 # Copyright (c) 2002,2003 Tim Bunce Ireland.
8 #
9 # See COPYRIGHT section in DBI.pm for usage and distribution rights.
10 #
11 ########################################################################
12 #
13 # Please send patches and bug reports to
14 #
15 # Jeff Zucker <jeff@vpservices.com> with cc to <dbi-dev@perl.org>
16 #
17 ########################################################################
18  
19 107 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 107 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 107 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 107 require Symbol;
23  
24 107 ▶$DBI::PurePerl = $ENV{DBI_PUREPERL} || 1;
Condition50%1/2
$ENV{'DBI_PUREPERL'} || 1
l!l
1070
MC/DC0%0/1
$ENV{'DBI_PUREPERL'} || 1
$ENV{'DBI_PUREPERL'}
Truth table50%1/2
A
A= $ENV{'DBI_PUREPERL'}
Aresult
11
00
25 107 $DBI::PurePerl::VERSION = "2.014286";
26  
27 107 ▶$DBI::neat_maxlen ||= 400;
Condition50%1/2
$DBI::neat_maxlen ||= 400
l!l
1070
MC/DC0%0/1
$DBI::neat_maxlen ||= 400
$DBI::neat_maxlen
Truth table50%1/2
A
A= $DBI::neat_maxlen
Aresult
11
00
28  
29 107 $DBI::tfh = Symbol::gensym();
30 107 ▶open $DBI::tfh, ">&STDERR" or warn "Can't dup STDERR: $!";
Branch: 1 branch
BranchTrueFalseTotal
open $DBI::tfh, ">&STDERR" or warn "Can't dup STDERR: $!" 107 0 107
31 107 select( (select($DBI::tfh), $| = 1)[0] ); # autoflush
32  
33 # check for weaken support, used by ChildHandles
34 107 my $HAS_WEAKEN = eval {
35 107 require Scalar::Util;
36 # this will croak() if this Scalar::Util doesn't have a working weaken().
37 107 Scalar::Util::weaken( my $test = [] );
38 107 1;
39 };
40  
41 107 %DBI::last_method_except = map { $_=>1 } qw(DESTROY _set_fbav set_err);
42  
43 107 ▶use constant SQL_ALL_TYPES => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 107 ▶use constant SQL_ARRAY => 50;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 107 ▶use constant SQL_ARRAY_LOCATOR => 51;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 107 ▶use constant SQL_BIGINT => (-5);
Subroutine BEGIN: called CC=1 SCAR=0.0
47 107 ▶use constant SQL_BINARY => (-2);
Subroutine BEGIN: called CC=1 SCAR=0.0
48 107 ▶use constant SQL_BIT => (-7);
Subroutine BEGIN: called CC=1 SCAR=0.0
49 107 ▶use constant SQL_BLOB => 30;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 107 ▶use constant SQL_BLOB_LOCATOR => 31;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 107 ▶use constant SQL_BOOLEAN => 16;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 107 ▶use constant SQL_CHAR => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 107 ▶use constant SQL_CLOB => 40;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 107 ▶use constant SQL_CLOB_LOCATOR => 41;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 107 ▶use constant SQL_DATE => 9;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 107 ▶use constant SQL_DATETIME => 9;
Subroutine BEGIN: called CC=1 SCAR=0.0
57 107 ▶use constant SQL_DECIMAL => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
58 107 ▶use constant SQL_DOUBLE => 8;
Subroutine BEGIN: called CC=1 SCAR=0.0
59 107 ▶use constant SQL_FLOAT => 6;
Subroutine BEGIN: called CC=1 SCAR=0.0
60 107 ▶use constant SQL_GUID => (-11);
Subroutine BEGIN: called CC=1 SCAR=0.0
61 107 ▶use constant SQL_INTEGER => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 107 ▶use constant SQL_INTERVAL => 10;
Subroutine BEGIN: called CC=1 SCAR=0.0
63 107 ▶use constant SQL_INTERVAL_DAY => 103;
Subroutine BEGIN: called CC=1 SCAR=0.0
64 107 ▶use constant SQL_INTERVAL_DAY_TO_HOUR => 108;
Subroutine BEGIN: called CC=1 SCAR=0.0
65 107 ▶use constant SQL_INTERVAL_DAY_TO_MINUTE => 109;
Subroutine BEGIN: called CC=1 SCAR=0.0
66 107 ▶use constant SQL_INTERVAL_DAY_TO_SECOND => 110;
Subroutine BEGIN: called CC=1 SCAR=0.0
67 107 ▶use constant SQL_INTERVAL_HOUR => 104;
Subroutine BEGIN: called CC=1 SCAR=0.0
68 107 ▶use constant SQL_INTERVAL_HOUR_TO_MINUTE => 111;
Subroutine BEGIN: called CC=1 SCAR=0.0
69 107 ▶use constant SQL_INTERVAL_HOUR_TO_SECOND => 112;
Subroutine BEGIN: called CC=1 SCAR=0.0
70 107 ▶use constant SQL_INTERVAL_MINUTE => 105;
Subroutine BEGIN: called CC=1 SCAR=0.0
71 107 ▶use constant SQL_INTERVAL_MINUTE_TO_SECOND => 113;
Subroutine BEGIN: called CC=1 SCAR=0.0
72 107 ▶use constant SQL_INTERVAL_MONTH => 102;
Subroutine BEGIN: called CC=1 SCAR=0.0
73 107 ▶use constant SQL_INTERVAL_SECOND => 106;
Subroutine BEGIN: called CC=1 SCAR=0.0
74 107 ▶use constant SQL_INTERVAL_YEAR => 101;
Subroutine BEGIN: called CC=1 SCAR=0.0
75 107 ▶use constant SQL_INTERVAL_YEAR_TO_MONTH => 107;
Subroutine BEGIN: called CC=1 SCAR=0.0
76 107 ▶use constant SQL_LONGVARBINARY => (-4);
Subroutine BEGIN: called CC=1 SCAR=0.0
77 107 ▶use constant SQL_LONGVARCHAR => (-1);
Subroutine BEGIN: called CC=1 SCAR=0.0
78 107 ▶use constant SQL_MULTISET => 55;
Subroutine BEGIN: called CC=1 SCAR=0.0
79 107 ▶use constant SQL_MULTISET_LOCATOR => 56;
Subroutine BEGIN: called CC=1 SCAR=0.0
80 107 ▶use constant SQL_NUMERIC => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
81 107 ▶use constant SQL_REAL => 7;
Subroutine BEGIN: called CC=1 SCAR=0.0
82 107 ▶use constant SQL_REF => 20;
Subroutine BEGIN: called CC=1 SCAR=0.0
83 107 ▶use constant SQL_ROW => 19;
Subroutine BEGIN: called CC=1 SCAR=0.0
84 107 ▶use constant SQL_SMALLINT => 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
85 107 ▶use constant SQL_TIME => 10;
Subroutine BEGIN: called CC=1 SCAR=0.0
86 107 ▶use constant SQL_TIMESTAMP => 11;
Subroutine BEGIN: called CC=1 SCAR=0.0
87 107 ▶use constant SQL_TINYINT => (-6);
Subroutine BEGIN: called CC=1 SCAR=0.0
88 107 ▶use constant SQL_TYPE_DATE => 91;
Subroutine BEGIN: called CC=1 SCAR=0.0
89 107 ▶use constant SQL_TYPE_TIME => 92;
Subroutine BEGIN: called CC=1 SCAR=0.0
90 107 ▶use constant SQL_TYPE_TIMESTAMP => 93;
Subroutine BEGIN: called CC=1 SCAR=0.0
91 107 ▶use constant SQL_TYPE_TIMESTAMP_WITH_TIMEZONE => 95;
Subroutine BEGIN: called CC=1 SCAR=0.0
92 107 ▶use constant SQL_TYPE_TIME_WITH_TIMEZONE => 94;
Subroutine BEGIN: called CC=1 SCAR=0.0
93 107 ▶use constant SQL_UDT => 17;
Subroutine BEGIN: called CC=1 SCAR=0.0
94 107 ▶use constant SQL_UDT_LOCATOR => 18;
Subroutine BEGIN: called CC=1 SCAR=0.0
95 107 ▶use constant SQL_UNKNOWN_TYPE => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
96 107 ▶use constant SQL_VARBINARY => (-3);
Subroutine BEGIN: called CC=1 SCAR=0.0
97 107 ▶use constant SQL_VARCHAR => 12;
Subroutine BEGIN: called CC=1 SCAR=0.0
98 107 ▶use constant SQL_WCHAR => (-8);
Subroutine BEGIN: called CC=1 SCAR=0.0
99 107 ▶use constant SQL_WLONGVARCHAR => (-10);
Subroutine BEGIN: called CC=1 SCAR=0.0
100 107 ▶use constant SQL_WVARCHAR => (-9);
Subroutine BEGIN: called CC=1 SCAR=0.0
101  
102 # for Cursor types
103 107 ▶use constant SQL_CURSOR_FORWARD_ONLY => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
104 107 ▶use constant SQL_CURSOR_KEYSET_DRIVEN => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
105 107 ▶use constant SQL_CURSOR_DYNAMIC => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
106 107 ▶use constant SQL_CURSOR_STATIC => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
107 107 ▶use constant SQL_CURSOR_TYPE_DEFAULT => SQL_CURSOR_FORWARD_ONLY;
Subroutine BEGIN: called CC=1 SCAR=0.0
108  
109 107 ▶use constant IMA_HAS_USAGE => 0x0001; #/* check parameter usage */
Subroutine BEGIN: called CC=1 SCAR=0.0
110 107 ▶use constant IMA_FUNC_REDIRECT => 0x0002; #/* is $h->func(..., "method")*/
Subroutine BEGIN: called CC=1 SCAR=0.0
111 107 ▶use constant IMA_KEEP_ERR => 0x0004; #/* don't reset err & errstr */
Subroutine BEGIN: called CC=1 SCAR=0.0
112 107 ▶use constant IMA_KEEP_ERR_SUB => 0x0008; #/* '' if in nested call */
Subroutine BEGIN: called CC=1 SCAR=0.0
113 107 ▶use constant IMA_NO_TAINT_IN => 0x0010; #/* don't check for tainted args*/
Subroutine BEGIN: called CC=1 SCAR=0.0
114 107 ▶use constant IMA_NO_TAINT_OUT => 0x0020; #/* don't taint results */
Subroutine BEGIN: called CC=1 SCAR=0.0
115 107 ▶use constant IMA_COPY_UP_STMT => 0x0040; #/* copy sth Statement to dbh */
Subroutine BEGIN: called CC=1 SCAR=0.0
116 107 ▶use constant IMA_END_WORK => 0x0080; #/* set on commit & rollback */
Subroutine BEGIN: called CC=1 SCAR=0.0
117 107 ▶use constant IMA_STUB => 0x0100; #/* do nothing eg $dbh->connected */
Subroutine BEGIN: called CC=1 SCAR=0.0
118 107 ▶use constant IMA_CLEAR_STMT => 0x0200; #/* clear Statement before call */
Subroutine BEGIN: called CC=1 SCAR=0.0
119 107 ▶use constant IMA_UNRELATED_TO_STMT=> 0x0400; #/* profile as empty Statement */
Subroutine BEGIN: called CC=1 SCAR=0.0
120 107 ▶use constant IMA_NOT_FOUND_OKAY => 0x0800; #/* not error if not found */
Subroutine BEGIN: called CC=1 SCAR=0.0
121 107 ▶use constant IMA_EXECUTE => 0x1000; #/* do/execute: DBIcf_Executed */
Subroutine BEGIN: called CC=1 SCAR=0.0
122 107 ▶use constant IMA_SHOW_ERR_STMT => 0x2000; #/* dbh meth relates to Statement*/
Subroutine BEGIN: called CC=1 SCAR=0.0
123 107 ▶use constant IMA_HIDE_ERR_PARAMVALUES => 0x4000; #/* ParamValues are not relevant */
Subroutine BEGIN: called CC=1 SCAR=0.0
124 107 ▶use constant IMA_IS_FACTORY => 0x8000; #/* new h ie connect & prepare */
Subroutine BEGIN: called CC=1 SCAR=0.0
125 107 ▶use constant IMA_CLEAR_CACHED_KIDS => 0x10000; #/* clear CachedKids before call */
Subroutine BEGIN: called CC=1 SCAR=0.0
126  
127 107 ▶use constant DBIstcf_STRICT => 0x0001;
Subroutine BEGIN: called CC=1 SCAR=0.0
128 107 ▶use constant DBIstcf_DISCARD_STRING => 0x0002;
Subroutine BEGIN: called CC=1 SCAR=0.0
129  
130 107 my %is_flag_attribute = map {$_ =>1 } qw(
131 Active
132 AutoCommit
133 ChopBlanks
134 CompatMode
135 Executed
136 Taint
137 TaintIn
138 TaintOut
139 InactiveDestroy
140 AutoInactiveDestroy
141 LongTruncOk
142 MultiThread
143 PrintError
144 PrintWarn
145 RaiseError
146 RaiseWarn
147 ShowErrorStatement
148 Warn
149 );
150 107 my %is_valid_attribute = map {$_ =>1 } (keys %is_flag_attribute, qw(
151 ActiveKids
152 Attribution
153 BegunWork
154 CachedKids
155 Callbacks
156 ChildHandles
157 CursorName
158 Database
159 DebugDispatch
160 Driver
161 Err
162 Errstr
163 ErrCount
164 FetchHashKeyName
165 HandleError
166 HandleSetErr
167 ImplementorClass
168 Kids
169 LongReadLen
170 NAME NAME_uc NAME_lc NAME_uc_hash NAME_lc_hash
171 NULLABLE
172 NUM_OF_FIELDS
173 NUM_OF_PARAMS
174 Name
175 PRECISION
176 ParamValues
177 Profile
178 Provider
179 ReadOnly
180 RootClass
181 RowCacheSize
182 RowsInCache
183 SCALE
184 State
185 Statement
186 TYPE
187 Type
188 TraceLevel
189 Username
190 Version
191 ));
192  
193 0 ▶sub valid_attribute {
Subroutine valid_attribute: not called CC=3 SCAR=24.8
Pod undocumented
194 0 ▶ my $attr = shift;
Subroutine valid_attribute: not called CC=3 SCAR=24.8
Pod undocumented
195 0 ▶ return 1 if $is_valid_attribute{$attr};
Branch: 2 branches
BranchTrueFalseTotal
if $is_valid_attribute{$attr} 0 0 0
if $is_valid_attribute{$attr} 0 0 0
196 0 ▶ return 1 if $attr =~ m/^[a-z]/; # starts with lowercase letter
Branch: 2 branches
BranchTrueFalseTotal
if $attr =~ /^[a-z]/ 0 0 0
if $attr =~ /^[a-z]/ 0 0 0
197 0 return 0
198 }
199  
200 107 my $initial_setup;
201 107 ▶sub initial_setup {
Subroutine initial_setup: called CC=2 SCAR=10.0
Pod undocumented
202 0 ▶ $initial_setup = 1;
Subroutine initial_setup: not called CC=2 SCAR=10.0
Pod undocumented
203 0 ▶ print $DBI::tfh __FILE__ . " version " . $DBI::PurePerl::VERSION . "\n"
Branch: 2 branches
BranchTrueFalseTotal
if $DBI::dbi_debug & 15 0 107 107
if $DBI::dbi_debug & 15 0 0 0
204 if $DBI::dbi_debug & 0xF;
205 0 untie $DBI::err;
206 0 untie $DBI::errstr;
207 0 untie $DBI::state;
208 0 untie $DBI::rows;
209 #tie $DBI::lasth, 'DBI::var', '!lasth'; # special case: return boolean
210 }
211  
212 10076 ▶sub _install_method {
Subroutine _install_method: called CC=26 SCAR=48.0
213 0 ▶ my ( $caller, $method, $from, $param_hash ) = @_;
Subroutine _install_method: not called CC=26 SCAR=48.0
214 0 ▶ initial_setup() unless $initial_setup;
Branch: 2 branches
BranchTrueFalseTotal
unless $initial_setup 107 9969 10076
unless $initial_setup 0 0 0
215  
216 0 my ($class, $method_name) = $method =~ /^[^:]+::(.+)::(.+)$/;
217 0 ▶ my $bitmask = $param_hash->{'O'} || 0;
Condition50%2/4
$param_hash->{'O'} || 0
l!l
71972879
$param_hash->{'O'} || 0
l!l
00
MC/DC100%1/1
$param_hash->{'O'} || 0
$param_hash->{'O'}
MC/DC0%0/1
$param_hash->{'O'} || 0
$param_hash->{'O'}
Truth table100%2/2
A
A= $param_hash->{'O'}
Aresult
11
00
Truth table0%0/2
A
A= $param_hash->{'O'}
Aresult
11
00
218 0 my @pre_call_frag;
219  
220 0 ▶ return if $method_name eq 'can';
Branch: 2 branches
BranchTrueFalseTotal
if $method_name eq "can" 107 9969 10076
if $method_name eq "can" 0 0 0
221  
222 0 ▶ push @pre_call_frag, q{
Branch: 2 branches
BranchTrueFalseTotal
if $method_name eq "DESTROY" 107 9862 9969
if $method_name eq "DESTROY" 0 0 0
223 delete $h->{CachedKids};
224 # ignore DESTROY for outer handle (DESTROY for inner likely to follow soon)
225 return if $h_inner;
226 # handle AutoInactiveDestroy and InactiveDestroy
227 $h->{InactiveDestroy} = 1
228 if $h->{AutoInactiveDestroy} and $$ != $h->{dbi_pp_pid};
229 $h->{Active} = 0
230 if $h->{InactiveDestroy};
231 # copy err/errstr/state up to driver so $DBI::err etc still work
232 if ($h->{err} and my $drh = $h->{Driver}) {
233 $drh->{$_} = $h->{$_} for ('err','errstr','state');
234 }
235 } if $method_name eq 'DESTROY';
236  
237 push @pre_call_frag, q{
238 return $h->{$_[0]} if exists $h->{$_[0]};
239 0 ▶ } if $method_name eq 'FETCH' && !exists $ENV{DBI_TRACE}; # XXX ?
Branch: 2 branches
BranchTrueFalseTotal
if $method_name eq "FETCH" and not exists $ENV{"DBI_TRACE"} 105 9864 9969
if $method_name eq "FETCH" and not exists $ENV{"DBI_TRACE"} 0 0 0
Condition50%3/6
$method_name eq "FETCH" and not exists $ENV{"DBI_TRACE"}
!ll&&!rl&&r
98622105
$method_name eq "FETCH" and not exists $ENV{"DBI_TRACE"}
!ll&&!rl&&r
000
MC/DC100%2/2
$method_name eq "FETCH" and not exists $ENV{"DBI_TRACE"}
$method_name eq "FETCH" not exists $ENV{"DBI_TRACE"}
MC/DC0%0/2
$method_name eq "FETCH" and not exists $ENV{"DBI_TRACE"}
$method_name eq "FETCH" not exists $ENV{"DBI_TRACE"}
Truth table100%3/3
A and not(B)
A= $method_name eq "FETCH"B= not exists $ENV{"DBI_TRACE"}
ABresult
0X0
100
111
Truth table0%0/3
A and not(B)
A= $method_name eq "FETCH"B= not exists $ENV{"DBI_TRACE"}
ABresult
0X0
100
111
240  
241 0 ▶ push @pre_call_frag, "return;"
Branch: 2 branches
BranchTrueFalseTotal
if 256 & $bitmask 0 9969 9969
if 256 & $bitmask 0 0 0
242 if IMA_STUB & $bitmask;
243  
244 0 ▶ push @pre_call_frag, q{
Branch: 2 branches
BranchTrueFalseTotal
if 2 & $bitmask 107 9862 9969
if 2 & $bitmask 0 0 0
245 $method_name = pop @_;
246 } if IMA_FUNC_REDIRECT & $bitmask;
247  
248 0 ▶ push @pre_call_frag, q{
Branch: 2 branches
BranchTrueFalseTotal
if 4160 & $bitmask 428 9541 9969
if 4160 & $bitmask 0 0 0
249 my $parent_dbh = $h->{Database};
250 } if (IMA_COPY_UP_STMT|IMA_EXECUTE) & $bitmask;
251  
252 0 ▶ push @pre_call_frag, q{
Branch: 2 branches
BranchTrueFalseTotal
if 64 & $bitmask 321 9648 9969
if 64 & $bitmask 0 0 0
253 warn "No Database set for $h on $method_name!" unless $parent_dbh; # eg proxy problems
254 $parent_dbh->{Statement} = $h->{Statement} if $parent_dbh;
255 } if IMA_COPY_UP_STMT & $bitmask;
256  
257 0 ▶ push @pre_call_frag, q{
Branch: 2 branches
BranchTrueFalseTotal
if 4096 & $bitmask 428 9541 9969
if 4096 & $bitmask 0 0 0
258 $h->{Executed} = 1;
259 $parent_dbh->{Executed} = 1 if $parent_dbh;
260 } if IMA_EXECUTE & $bitmask;
261  
262 0 ▶ push @pre_call_frag, q{
Branch: 2 branches
BranchTrueFalseTotal
if 65536 & $bitmask 321 9648 9969
if 65536 & $bitmask 0 0 0
263 %{ $h->{CachedKids} } = () if $h->{CachedKids};
264 } if IMA_CLEAR_CACHED_KIDS & $bitmask;
265  
266 0 ▶ if (IMA_KEEP_ERR & $bitmask) {
Branch: 2 branches
BranchTrueFalseTotal
if (4 & $bitmask) { } 2917 7052 9969
if (4 & $bitmask) { } 0 0 0
267 0 push @pre_call_frag, q{
268 my $keep_error = DBI::_err_hash($h);
269 };
270 }
271 else {
272 0 ▶ my $ke_init = (IMA_KEEP_ERR_SUB & $bitmask)
Branch: 2 branches
BranchTrueFalseTotal
8 & $bitmask ? : 0 7052 7052
8 & $bitmask ? : 0 0 0
273 ? q{= ($h->{dbi_pp_parent}->{dbi_pp_call_depth} && DBI::_err_hash($h)) }
274 : "";
275 0 push @pre_call_frag, qq{
276 my \$keep_error $ke_init;
277 };
278 0 my $clear_error_code = q{
279 #warn "$method_name cleared err";
280 $h->{err} = $DBI::err = undef;
281 $h->{errstr} = $DBI::errstr = undef;
282 $h->{state} = $DBI::state = '';
283 };
284 $clear_error_code = q{
285 printf $DBI::tfh " !! %s: %s CLEARED by call to }.$method_name.q{ method\n".
286 $h->{err}, $h->{err}
287 if defined $h->{err} && $DBI::dbi_debug & 0xF;
288 }. $clear_error_code
289 0 ▶ if exists $ENV{DBI_TRACE};
Branch: 2 branches
BranchTrueFalseTotal
if exists $ENV{"DBI_TRACE"} 128 6924 7052
if exists $ENV{"DBI_TRACE"} 0 0 0
290 0 ▶ push @pre_call_frag, ($ke_init)
Branch: 4 branches
BranchTrueFalseTotal
unless $method_name eq "set_err" 6945 107 7052
$ke_init ? : 0 6945 6945
unless $method_name eq "set_err" 0 0 0
$ke_init ? : 0 0 0
291 ? qq{ unless (\$keep_error) { $clear_error_code }}
292 : $clear_error_code
293 unless $method_name eq 'set_err';
294 }
295  
296 0 push @pre_call_frag, q{
297 my $ErrCount = $h->{ErrCount};
298 };
299  
300 push @pre_call_frag, q{
301 if (($DBI::dbi_debug & 0xF) >= 2) {
302 no warnings;
303 my $args = join " ", map { DBI::neat($_) } ($h, @_);
304 printf $DBI::tfh " > $method_name in $imp ($args) [$@]\n";
305 }
306 0 ▶ } if exists $ENV{DBI_TRACE}; # note use of 'exists'
Branch: 2 branches
BranchTrueFalseTotal
if exists $ENV{"DBI_TRACE"} 185 9784 9969
if exists $ENV{"DBI_TRACE"} 0 0 0
307  
308 push @pre_call_frag, q{
309 $h->{'dbi_pp_last_method'} = $method_name;
310 0 ▶ } unless exists $DBI::last_method_except{$method_name};
Branch: 2 branches
BranchTrueFalseTotal
unless exists $DBI::last_method_except{$method_name} 9648 321 9969
unless exists $DBI::last_method_except{$method_name} 0 0 0
311  
312 # --- post method call code fragments ---
313 0 my @post_call_frag;
314  
315 push @post_call_frag, q{
316 if (my $trace_level = ($DBI::dbi_debug & 0xF)) {
317 if ($h->{err}) {
318 printf $DBI::tfh " !! ERROR: %s %s\n", $h->{err}, $h->{errstr};
319 }
320 my $ret = join " ", map { DBI::neat($_) } @ret;
321 my $msg = " < $method_name= $ret";
322 $msg = ($trace_level >= 2) ? Carp::shortmess($msg) : "$msg\n";
323 print $DBI::tfh $msg;
324 }
325 0 ▶ } if exists $ENV{DBI_TRACE}; # note use of exists
Branch: 2 branches
BranchTrueFalseTotal
if exists $ENV{"DBI_TRACE"} 185 9784 9969
if exists $ENV{"DBI_TRACE"} 0 0 0
326  
327 0 ▶ push @post_call_frag, q{
Branch: 2 branches
BranchTrueFalseTotal
if 128 & $bitmask 214 9755 9969
if 128 & $bitmask 0 0 0
328 $h->{Executed} = 0;
329 if ($h->{BegunWork}) {
330 $h->{BegunWork} = 0;
331 $h->{AutoCommit} = 1;
332 }
333 } if IMA_END_WORK & $bitmask;
334  
335 0 ▶ push @post_call_frag, q{
Branch: 2 branches
BranchTrueFalseTotal
if 32768 & $bitmask 963 9006 9969
if 32768 & $bitmask 0 0 0
336 if ( ref $ret[0] and
337 UNIVERSAL::isa($ret[0], 'DBI::_::common') and
338 defined( (my $h_new = tied(%{$ret[0]})||$ret[0])->{err} )
339 ) {
340 # copy up info/warn to drh so PrintWarn on connect is triggered
341 $h->set_err($h_new->{err}, $h_new->{errstr}, $h_new->{state})
342 }
343 } if IMA_IS_FACTORY & $bitmask;
344  
345 0 push @post_call_frag, q{
346 if ($keep_error) {
347 $keep_error = 0
348 if $h->{ErrCount} > $ErrCount
349 or DBI::_err_hash($h) ne $keep_error;
350 }
351  
352 $DBI::err = $h->{err};
353 $DBI::errstr = $h->{errstr};
354 $DBI::state = $h->{state};
355  
356 if ( !$keep_error
357 && defined(my $err = $h->{err})
358 && ($call_depth <= 1 && !$h->{dbi_pp_parent}{dbi_pp_call_depth})
359 ) {
360  
361 my($pe,$pw,$re,$rw,$he) = @{$h}{qw(PrintError PrintWarn RaiseError RaiseWarn HandleError)};
362 my $msg;
363  
364 if ($err && ($pe || $re || $he) # error
365 or (!$err && length($err) && ($pw || $rw)) # warning
366 ) {
367 my $last = ($DBI::last_method_except{$method_name})
368 ? ($h->{'dbi_pp_last_method'}||$method_name) : $method_name;
369 my $errstr = $h->{errstr} || $DBI::errstr || $err || '';
370 my $msg = sprintf "%s %s %s: %s", $imp, $last,
371 ($err eq "0") ? "warning" : "failed", $errstr;
372  
373 if ($h->{'ShowErrorStatement'} and my $Statement = $h->{Statement}) {
374 $msg .= ' [for Statement "' . $Statement;
375 if (my $ParamValues = $h->FETCH('ParamValues')) {
376 $msg .= '" with ParamValues: ';
377 $msg .= DBI::_concat_hash_sorted($ParamValues, "=", ", ", 1, undef);
378 $msg .= "]";
379 }
380 else {
381 $msg .= '"]';
382 }
383 }
384 if ($err eq "0") { # is 'warning' (not info)
385 carp $msg if $pw;
386 my $do_croak = $rw;
387 if ((my $subsub = $h->{'HandleError'}) && $do_croak) {
388 $do_croak = 0 if &$subsub($msg,$h,$ret[0]);
389 }
390 die $msg if $do_croak;
391 }
392 else {
393 my $do_croak = 1;
394 if (my $subsub = $h->{'HandleError'}) {
395 $do_croak = 0 if &$subsub($msg,$h,$ret[0]);
396 }
397 if ($do_croak) {
398 printf $DBI::tfh " $method_name has failed ($h->{PrintError},$h->{RaiseError})\n"
399 if ($DBI::dbi_debug & 0xF) >= 4;
400 carp $msg if $pe;
401 die $msg if $h->{RaiseError};
402 }
403 }
404 }
405 }
406 };
407  
408  
409 0 ▶ my $method_code = q[
Branch: 2 branches
BranchTrueFalseTotal
2048 & $bitmask ? : 1605 8364 9969
2048 & $bitmask ? : 0 0 0
410 sub {
411 my $h = shift;
412 my $h_inner = tied(%$h);
413 $h = $h_inner if $h_inner;
414  
415 my $imp;
416 if ($method_name eq 'DESTROY') {
417 # during global destruction, $h->{...} can trigger "Can't call FETCH on an undef value"
418 # implying that tied() above lied to us, so we need to use eval
419 local $@; # protect $@
420 $imp = eval { $h->{"ImplementorClass"} } or return; # probably global destruction
421 }
422 else {
423 $imp = $h->{"ImplementorClass"} or do {
424 warn "Can't call $method_name method on handle $h after take_imp_data()\n"
425 if not exists $h->{Active};
426 return; # or, more likely, global destruction
427 };
428 }
429  
430 ] . join("\n", '', @pre_call_frag, '') . q[
431  
432 my $call_depth = $h->{'dbi_pp_call_depth'} + 1;
433 local ($h->{'dbi_pp_call_depth'}) = $call_depth;
434  
435 my @ret;
436 my $sub = $imp->can($method_name);
437 if (!$sub and IMA_FUNC_REDIRECT & $bitmask and $sub = $imp->can('func')) {
438 push @_, $method_name;
439 }
440 if ($sub) {
441 (wantarray) ? (@ret = &$sub($h,@_)) : (@ret = scalar &$sub($h,@_));
442 }
443 else {
444 # XXX could try explicit fallback to $imp->can('AUTOLOAD') etc
445 # which would then let Multiplex pass PurePerl tests, but some
446 # hook into install_method may be better.
447 croak "Can't locate DBI object method \"$method_name\" via package \"$imp\""
448 if ] . ((IMA_NOT_FOUND_OKAY & $bitmask) ? 0 : 1) . q[;
449 }
450  
451 ] . join("\n", '', @post_call_frag, '') . q[
452  
453 return (wantarray) ? @ret : $ret[0];
454 }
455 ];
456 107 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
457 0 my $code_ref = eval qq{#line 1 "DBI::PurePerl $method"\n$method_code};
458 0 ▶ warn "$@\n$method_code\n" if $@;
Branch: 2 branches
BranchTrueFalseTotal
if $@ 0 9969 9969
if $@ 0 0 0
459 0 ▶ die "$@\n$method_code\n" if $@;
Branch: 2 branches
BranchTrueFalseTotal
if $@ 0 9969 9969
if $@ 0 0 0
460 0 *$method = $code_ref;
461 0 if (0 && $method =~ /\b(connect|FETCH)\b/) { # debuging tool
462 my $l=0; # show line-numbered code for method
463 warn "*$method code:\n".join("\n", map { ++$l.": $_" } split/\n/,$method_code);
464 }
465 }
466  
467  
468 3226 ▶sub _new_handle {
Subroutine _new_handle: called CC=5 SCAR=21.6
469 0 ▶ my ($class, $parent, $attr, $imp_data, $imp_class) = @_;
Subroutine _new_handle: not called CC=5 SCAR=21.6
470  
471 0 ▶ DBI->trace_msg(" New $class (for $imp_class, parent=$parent, id=".($imp_data||'').")\n")
Branch: 2 branches
BranchTrueFalseTotal
if $DBI::dbi_debug >= 3 31 3195 3226
if $DBI::dbi_debug >= 3 0 0 0
Condition50%2/4
$imp_data || ''
l!l
427
$imp_data || ''
l!l
00
MC/DC100%1/1
$imp_data || ''
$imp_data
MC/DC0%0/1
$imp_data || ''
$imp_data
Truth table100%2/2
A
A= $imp_data
Aresult
11
00
Truth table0%0/2
A
A= $imp_data
Aresult
11
00
472 if $DBI::dbi_debug >= 3;
473  
474 0 ▶ $attr->{ImplementorClass} = $imp_class
Branch: 2 branches
BranchTrueFalseTotal
$attr->{"ImplementorClass"} = $imp_class or Carp::croak("_new_handle($class): 'ImplementorClass' attribute not given") 3226 0 3226
$attr->{"ImplementorClass"} = $imp_class or Carp::croak("_new_handle($class): 'ImplementorClass' attribute not given") 0 0 0
475 or Carp::croak("_new_handle($class): 'ImplementorClass' attribute not given");
476  
477 # This is how we create a DBI style Object:
478 # %outer gets tied to %$attr (which becomes the 'inner' handle)
479 0 my (%outer, $i, $h);
480 0 $i = tie %outer, $class, $attr; # ref to inner hash (for driver)
481 0 $h = bless \%outer, $class; # ref to outer hash (for application)
482 # The above tie and bless may migrate down into _setup_handle()...
483 # Now add magic so DBI method dispatch works
484 0 DBI::_setup_handle($h, $imp_class, $parent, $imp_data);
485 0 ▶ return $h unless wantarray;
Branch: 2 branches
BranchTrueFalseTotal
unless wantarray 806 2420 3226
unless wantarray 0 0 0
486 0 return ($h, $i);
487 }
488  
489 3226 ▶sub _setup_handle {
Subroutine _setup_handle: called CC=18 SCAR=43.3
490 0 ▶ my($h, $imp_class, $parent, $imp_data) = @_;
Subroutine _setup_handle: not called CC=18 SCAR=43.3
491 0 ▶ my $h_inner = tied(%$h) || $h;
Condition16%1/6
tied %$h || $h
l!l&&r!l&&!r
322600
tied %$h || $h
l!l&&r!l&&!r
000
MC/DC0%0/2
tied %$h || $h
tied %$h $h
MC/DC0%0/2
tied %$h || $h
tied %$h $h
Truth table33%1/3
A || B
A= tied %$hB= $h
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= tied %$hB= $h
ABresult
1X1
011
000
492 0 ▶ if (($DBI::dbi_debug & 0xF) >= 4) {
Branch: 2 branches
BranchTrueFalseTotal
if (($DBI::dbi_debug & 15) >= 4) 3 3223 3226
if (($DBI::dbi_debug & 15) >= 4) 0 0 0
493 107 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
494 0 print $DBI::tfh " _setup_handle(@_)\n";
495 }
496 0 $h_inner->{"imp_data"} = $imp_data;
497 0 $h_inner->{"ImplementorClass"} = $imp_class;
498 0 $h_inner->{"Kids"} = $h_inner->{"ActiveKids"} = 0; # XXX not maintained
499 0 ▶ if ($parent) {
Branch: 2 branches
BranchTrueFalseTotal
if ($parent) { } 3108 118 3226
if ($parent) { } 0 0 0
500 0 foreach (qw(
501 RaiseError PrintError RaiseWarn PrintWarn HandleError HandleSetErr
502 Warn LongTruncOk ChopBlanks AutoCommit ReadOnly
503 ShowErrorStatement FetchHashKeyName LongReadLen CompatMode
504 )) {
505 $h_inner->{$_} = $parent->{$_}
506 0 ▶ if exists $parent->{$_} && !exists $h_inner->{$_};
Branch: 2 branches
BranchTrueFalseTotal
if exists $parent->{$_} and not exists $h_inner->{$_} 25156 21464 46620
if exists $parent->{$_} and not exists $h_inner->{$_} 0 0 0
Condition33%2/6
exists $parent->{$_} and not exists $h_inner->{$_}
!ll&&!rl&&r
21464025156
exists $parent->{$_} and not exists $h_inner->{$_}
!ll&&!rl&&r
000
MC/DC50%1/2
exists $parent->{$_} and not exists $h_inner->{$_}
exists $parent->{$_} not exists $h_inner->{$_}
MC/DC0%0/2
exists $parent->{$_} and not exists $h_inner->{$_}
exists $parent->{$_} not exists $h_inner->{$_}
Truth table66%2/3
A and not(B)
A= exists $parent->{$_}B= not exists $h_inner->{$_}
ABresult
0X0
100
111
Truth table0%0/3
A and not(B)
A= exists $parent->{$_}B= not exists $h_inner->{$_}
ABresult
0X0
100
111
507 }
508 0 ▶ if (ref($parent) =~ /::db$/) { # is sth
Branch: 4 branches
BranchTrueFalseTotal
if (ref($parent) =~ /::db$/) { } 2133 975 3108
elsif (ref($parent) =~ /::dr$/) { } 975 0 975
if (ref($parent) =~ /::db$/) { } 0 0 0
elsif (ref($parent) =~ /::dr$/) { } 0 0 0
509 0 $h_inner->{Database} = $parent;
510 0 $parent->{Statement} = $h_inner->{Statement};
511 0 $h_inner->{NUM_OF_PARAMS} = 0;
512 0 $h_inner->{Active} = 0; # driver sets true when there's data to fetch
513 }
514 elsif (ref($parent) =~ /::dr$/){ # is dbh
515 0 $h_inner->{Driver} = $parent;
516 0 $h_inner->{Active} = 0;
517 }
518 else {
519 0 warn "panic: ".ref($parent); # should never happen
520 }
521 0 $h_inner->{dbi_pp_parent} = $parent;
522  
523 # add to the parent's ChildHandles
524 0 ▶ if ($HAS_WEAKEN) {
Branch: 2 branches
BranchTrueFalseTotal
if ($HAS_WEAKEN) 3108 0 3108
if ($HAS_WEAKEN) 0 0 0
525 0 ▶ my $handles = $parent->{ChildHandles} ||= [];
Condition50%2/4
$parent->{"ChildHandles"} ||= []
l!l
2499609
$parent->{"ChildHandles"} ||= []
l!l
00
MC/DC100%1/1
$parent->{"ChildHandles"} ||= []
$parent->{"ChildHandles"}
MC/DC0%0/1
$parent->{"ChildHandles"} ||= []
$parent->{"ChildHandles"}
Truth table100%2/2
A
A= $parent->{"ChildHandles"}
Aresult
11
00
Truth table0%0/2
A
A= $parent->{"ChildHandles"}
Aresult
11
00
526 0 push @$handles, $h;
527 0 Scalar::Util::weaken($handles->[-1]);
528 # purge destroyed handles occasionally
529 0 ▶ if (@$handles % 120 == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (@$handles % 120 == 0) 10 3098 3108
if (@$handles % 120 == 0) 0 0 0
530 0 @$handles = grep { defined } @$handles;
531 0 Scalar::Util::weaken($_) for @$handles; # re-weaken after grep
532 }
533 }
534 }
535 else { # setting up a driver handle
536 0 $h_inner->{Warn} = 1;
537 0 $h_inner->{PrintWarn} = 1;
538 0 $h_inner->{AutoCommit} = 1;
539 0 $h_inner->{TraceLevel} = 0;
540 0 $h_inner->{CompatMode} = (1==0);
541 0 ▶ $h_inner->{FetchHashKeyName} ||= 'NAME';
Condition25%1/4
$h_inner->{"FetchHashKeyName"} ||= "NAME"
l!l
1180
$h_inner->{"FetchHashKeyName"} ||= "NAME"
l!l
00
MC/DC0%0/1
$h_inner->{"FetchHashKeyName"} ||= "NAME"
$h_inner->{"FetchHashKeyName"}
MC/DC0%0/1
$h_inner->{"FetchHashKeyName"} ||= "NAME"
$h_inner->{"FetchHashKeyName"}
Truth table50%1/2
A
A= $h_inner->{"FetchHashKeyName"}
Aresult
11
00
Truth table0%0/2
A
A= $h_inner->{"FetchHashKeyName"}
Aresult
11
00
542 0 ▶ $h_inner->{LongReadLen} ||= 80;
Condition25%1/4
$h_inner->{"LongReadLen"} ||= 80
l!l
0118
$h_inner->{"LongReadLen"} ||= 80
l!l
00
MC/DC0%0/1
$h_inner->{"LongReadLen"} ||= 80
$h_inner->{"LongReadLen"}
MC/DC0%0/1
$h_inner->{"LongReadLen"} ||= 80
$h_inner->{"LongReadLen"}
Truth table50%1/2
A
A= $h_inner->{"LongReadLen"}
Aresult
11
00
Truth table0%0/2
A
A= $h_inner->{"LongReadLen"}
Aresult
11
00
543 0 ▶ $h_inner->{ChildHandles} ||= [] if $HAS_WEAKEN;
Branch: 2 branches
BranchTrueFalseTotal
if $HAS_WEAKEN 118 0 118
if $HAS_WEAKEN 0 0 0
Condition25%1/4
$h_inner->{"ChildHandles"} ||= []
l!l
0118
$h_inner->{"ChildHandles"} ||= []
l!l
00
MC/DC0%0/1
$h_inner->{"ChildHandles"} ||= []
$h_inner->{"ChildHandles"}
MC/DC0%0/1
$h_inner->{"ChildHandles"} ||= []
$h_inner->{"ChildHandles"}
Truth table50%1/2
A
A= $h_inner->{"ChildHandles"}
Aresult
11
00
Truth table0%0/2
A
A= $h_inner->{"ChildHandles"}
Aresult
11
00
544 0 ▶ $h_inner->{Type} ||= 'dr';
Condition25%1/4
$h_inner->{"Type"} ||= "dr"
l!l
0118
$h_inner->{"Type"} ||= "dr"
l!l
00
MC/DC0%0/1
$h_inner->{"Type"} ||= "dr"
$h_inner->{"Type"}
MC/DC0%0/1
$h_inner->{"Type"} ||= "dr"
$h_inner->{"Type"}
Truth table50%1/2
A
A= $h_inner->{"Type"}
Aresult
11
00
Truth table0%0/2
A
A= $h_inner->{"Type"}
Aresult
11
00
545 0 $h_inner->{Active} = 1;
546 }
547 0 $h_inner->{"dbi_pp_call_depth"} = 0;
548 0 $h_inner->{"dbi_pp_pid"} = $$;
549 0 $h_inner->{ErrCount} = 0;
550 }
551  
552 0 ▶sub constant {
Subroutine constant: not called CC=1 SCAR=6.9
Pod documented
553 0 ▶ warn "constant(@_) called unexpectedly"; return undef;
Subroutine constant: not called CC=1 SCAR=6.9
Pod documented
554 }
555  
556 18 ▶sub trace {
Subroutine trace: called CC=7 SCAR=27.0
Pod documented
557 0 ▶ my ($h, $level, $file) = @_;
Subroutine trace: not called CC=7 SCAR=27.0
Pod documented
558 0 ▶ $level = $h->parse_trace_flags($level)
Branch: 2 branches
BranchTrueFalseTotal
if defined $level and not looks_like_number($level) 0 18 18
if defined $level and not looks_like_number($level) 0 0 0
Condition33%2/6
defined $level and not looks_like_number($level)
!ll&&!rl&&r
2160
defined $level and not looks_like_number($level)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $level and not looks_like_number($level)
defined $level not looks_like_number($level)
MC/DC0%0/2
defined $level and not looks_like_number($level)
defined $level not looks_like_number($level)
Truth table66%2/3
A and not(B)
A= defined $levelB= not looks_like_number($level)
ABresult
0X0
100
111
Truth table0%0/3
A and not(B)
A= defined $levelB= not looks_like_number($level)
ABresult
0X0
100
111
559 if defined $level and !DBI::looks_like_number($level);
560 0 my $old_level = $DBI::dbi_debug;
561 0 ▶ _set_trace_file($file) if $level;
Branch: 2 branches
BranchTrueFalseTotal
if $level 6 12 18
if $level 0 0 0
562 0 ▶ if (defined $level) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $level) 16 2 18
if (defined $level) 0 0 0
563 0 $DBI::dbi_debug = $level;
564 0 ▶ print $DBI::tfh " DBI $DBI::VERSION (PurePerl) "
Branch: 2 branches
BranchTrueFalseTotal
if $DBI::dbi_debug & 15 6 10 16
if $DBI::dbi_debug & 15 0 0 0
565 . "dispatch trace level set to $DBI::dbi_debug\n"
566 if $DBI::dbi_debug & 0xF;
567 }
568 0 ▶ _set_trace_file($file) if !$level;
Branch: 2 branches
BranchTrueFalseTotal
unless $level 12 6 18
unless $level 0 0 0
569 0 return $old_level;
570 }
571  
572 38 ▶sub _set_trace_file {
Subroutine _set_trace_file: called CC=11 SCAR=33.9
573 0 ▶ my ($file) = @_;
Subroutine _set_trace_file: not called CC=11 SCAR=33.9
574 #
575 # DAA add support for filehandle inputs
576 #
577 # DAA required to avoid closing a prior fh trace()
578 0 ▶ $DBI::tfh = undef unless $DBI::tfh_needs_close;
Branch: 2 branches
BranchTrueFalseTotal
unless $DBI::tfh_needs_close 18 20 38
unless $DBI::tfh_needs_close 0 0 0
579  
580 0 ▶ if (ref $file eq 'GLOB') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $file eq "GLOB") 8 30 38
if (ref $file eq "GLOB") 0 0 0
581 0 $DBI::tfh = $file;
582 0 select((select($DBI::tfh), $| = 1)[0]);
583 0 $DBI::tfh_needs_close = 0;
584 0 return 1;
585 }
586 0 ▶ if ($file && ref \$file eq 'GLOB') {
Branch: 2 branches
BranchTrueFalseTotal
if ($file and ref \$file eq "GLOB") 4 26 30
if ($file and ref \$file eq "GLOB") 0 0 0
Condition50%3/6
$file and ref \$file eq "GLOB"
!ll&&!rl&&r
10164
$file and ref \$file eq "GLOB"
!ll&&!rl&&r
000
MC/DC100%2/2
$file and ref \$file eq "GLOB"
$file ref \$file eq "GLOB"
MC/DC0%0/2
$file and ref \$file eq "GLOB"
$file ref \$file eq "GLOB"
Truth table100%3/3
A and B
A= $fileB= ref \$file eq "GLOB"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $fileB= ref \$file eq "GLOB"
ABresult
0X0
100
111
587 0 $DBI::tfh = *{$file}{IO};
588 0 select((select($DBI::tfh), $| = 1)[0]);
589 0 $DBI::tfh_needs_close = 0;
590 0 return 1;
591 }
592 0 $DBI::tfh_needs_close = 1;
593 0 ▶ if (!$file || $file eq 'STDERR') {
Branch: 4 branches
BranchTrueFalseTotal
if (not $file or $file eq 'STDERR') { } 12 14 26
elsif ($file eq 'STDOUT') { } 8 6 14
if (not $file or $file eq 'STDERR') { } 0 0 0
elsif ($file eq 'STDOUT') { } 0 0 0
Condition50%3/6
not $file or $file eq "STDERR"
l!l&&r!l&&!r
10214
not $file or $file eq "STDERR"
l!l&&r!l&&!r
000
MC/DC100%2/2
not $file or $file eq "STDERR"
not $file $file eq "STDERR"
MC/DC0%0/2
not $file or $file eq "STDERR"
not $file $file eq "STDERR"
Truth table100%3/3
not(A) or B
A= not $fileB= $file eq "STDERR"
ABresult
1X1
011
000
Truth table0%0/3
not(A) or B
A= not $fileB= $file eq "STDERR"
ABresult
1X1
011
000
594 0 ▶ open $DBI::tfh, ">&STDERR" or carp "Can't dup STDERR: $!";
Branch: 2 branches
BranchTrueFalseTotal
open $DBI::tfh, ">&STDERR" or carp("Can't dup STDERR: $!") 12 0 12
open $DBI::tfh, ">&STDERR" or carp("Can't dup STDERR: $!") 0 0 0
595 }
596 elsif ($file eq 'STDOUT') {
597 0 ▶ open $DBI::tfh, ">&STDOUT" or carp "Can't dup STDOUT: $!";
Branch: 2 branches
BranchTrueFalseTotal
open $DBI::tfh, ">&STDOUT" or carp("Can't dup STDOUT: $!") 8 0 8
open $DBI::tfh, ">&STDOUT" or carp("Can't dup STDOUT: $!") 0 0 0
598 }
599 else {
600 0 ▶ open $DBI::tfh, ">>$file" or carp "Can't open $file: $!";
Branch: 2 branches
BranchTrueFalseTotal
open $DBI::tfh, ">>$file" or carp("Can't open ${file}: $!") 6 0 6
open $DBI::tfh, ">>$file" or carp("Can't open ${file}: $!") 0 0 0
601 }
602 0 select((select($DBI::tfh), $| = 1)[0]);
603 0 return 1;
604 }
605 2 ▶sub _get_imp_data { shift->{"imp_data"}; }
Subroutine _get_imp_data: called CC=1 SCAR=0.0
606 0 ▶sub _svdump { }
Subroutine _svdump: not called CC=1 SCAR=0.0
607 4 ▶sub dump_handle {
Subroutine dump_handle: called CC=3 SCAR=11.1
Pod documented
608 4 my ($h,$msg,$level) = @_;
609 4 ▶ $msg||="dump_handle $h";
Condition50%1/2
$msg ||= "dump_handle $h"
l!l
40
MC/DC0%0/1
$msg ||= "dump_handle $h"
$msg
Truth table50%1/2
A
A= $msg
Aresult
11
00
610 4 print $DBI::tfh "$msg:\n";
611 4 for my $attrib (sort keys %$h) {
612 136 print $DBI::tfh "\t$attrib => ".DBI::neat($h->{$attrib})."\n";
613 }
614 }
615  
616 14 ▶sub _handles {
Subroutine _handles: called CC=4 SCAR=17.9
617 14 my $h = shift;
618 14 my $h_inner = tied %$h;
619 14 ▶ if ($h_inner) { # this is okay
Branch: 1 branch
BranchTrueFalseTotal
if ($h_inner) 14 0 14
620 14 ▶ return $h unless wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 0 14 14
621 14 return ($h, $h_inner);
622 }
623 # XXX this isn't okay... we have an inner handle but
624 # currently have no way to get at its outer handle,
625 # so we just warn and return the inner one for both...
626 0 Carp::carp("Can't return outer handle from inner handle using DBI::PurePerl");
627 0 ▶ return $h unless wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 0 0 0
628 0 return ($h,$h);
629 }
630  
631 8 ▶sub hash {
Subroutine hash: called CC=7 SCAR=19.9
Pod documented
632 8 my ($key, $type) = @_;
633 8 my ($hash);
634 8 ▶ if (!$type) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $type) { } 6 2 8
elsif ($type == 1) { } 2 0 2
635 6 $hash = 0;
636 # XXX The C version uses the "char" type, which could be either
637 # signed or unsigned. I use signed because so do the two
638 # compilers on my system.
639 6 for my $char (unpack ("c*", $key)) {
640 24 $hash = $hash * 33 + $char;
641 }
642 6 $hash &= 0x7FFFFFFF; # limit to 31 bits
643 6 $hash |= 0x40000000; # set bit 31
644 6 return -$hash; # return negative int
645 }
646 elsif ($type == 1) { # Fowler/Noll/Vo hash
647 # see http://www.isthe.com/chongo/tech/comp/fnv/
648 2 require Math::BigInt; # feel free to reimplement w/o BigInt!
649 2 ▶ (my $version = $Math::BigInt::VERSION || 0) =~ s/_.*//; # eg "1.70_01"
Condition50%1/2
$Math::BigInt::VERSION || 0
l!l
20
MC/DC0%0/1
$Math::BigInt::VERSION || 0
$Math::BigInt::VERSION
Truth table50%1/2
A
A= $Math::BigInt::VERSION
Aresult
11
00
650 2 ▶ if ($version >= 1.56) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version >= "1.56") 2 0 2
651 2 $hash = Math::BigInt->new(0x811c9dc5);
652 2 for my $uchar (unpack ("C*", $key)) {
653 # multiply by the 32 bit FNV magic prime mod 2^64
654 10 $hash = ($hash * 0x01000193) & 0xffffffff;
655 # xor the bottom with the current octet
656 10 $hash ^= $uchar;
657 }
658 # cast to int
659 2 return unpack "i", pack "i", $hash;
660 }
661 0 croak("DBI::PurePerl doesn't support hash type 1 without Math::BigInt >= 1.56 (available on CPAN)");
662 }
663 else {
664 0 croak("bad hash type $type");
665 }
666 }
667  
668 5002 ▶sub looks_like_number {
Subroutine looks_like_number: called CC=6 SCAR=17.9
Pod documented
669 5002 my @new = ();
670 5002 for my $thing(@_) {
671 5014 ▶ if (!defined $thing or $thing eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $thing or $thing eq '') { } 20 4994 5014
Condition100%3/3
not defined $thing or $thing eq ""
l!l&&r!l&&!r
2184994
MC/DC100%2/2
not defined $thing or $thing eq ""
not defined $thing $thing eq ""
Truth table100%3/3
not(A) or B
A= not defined $thingB= $thing eq ""
ABresult
1X1
011
000
672 20 push @new, undef;
673 }
674 else {
675 4994 ▶ push @new, ($thing =~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$thing =~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/ ? : 4691 303 4994
676 }
677 }
678 5002 ▶ return (@_ >1) ? @new : $new[0];
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 2 5000 5002
679 }
680  
681 5613 ▶sub neat {
Subroutine neat: called CC=7 SCAR=19.6
Pod documented
682 5613 my $v = shift;
683 5613 ▶ return "undef" unless defined $v;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 4382 1231 5613
684 1231 my $quote = q{"};
685 1231 ▶ if (not utf8::is_utf8($v)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (utf8::is_utf8($v)) 1231 0 1231
686 1231 ▶ return $v if (($v & ~ $v) eq "0"); # is SvNIOK
Branch: 1 branch
BranchTrueFalseTotal
if ($v & ~$v) eq 0 613 618 1231
687 618 $quote = q{'};
688 }
689 618 ▶ my $maxlen = shift || $DBI::neat_maxlen;
Condition66%2/3
shift() || $DBI::neat_maxlen
l!l&&r!l&&!r
1075110
MC/DC0%0/2
shift() || $DBI::neat_maxlen
shift() $DBI::neat_maxlen
Truth table66%2/3
A || B
A= shift()B= $DBI::neat_maxlen
ABresult
1X1
011
000
690 618 ▶ if ($maxlen && $maxlen < length($v) + 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($maxlen and $maxlen < length($v) + 2) 10 608 618
Condition66%2/3
$maxlen and $maxlen < length($v) + 2
!ll&&!rl&&r
060810
MC/DC50%1/2
$maxlen and $maxlen < length($v) + 2
$maxlen $maxlen < length($v) + 2
Truth table66%2/3
A and B
A= $maxlenB= $maxlen < length($v) + 2
ABresult
0X0
100
111
691 10 $v = substr($v,0,$maxlen-5);
692 10 $v .= '...';
693 }
694 618 $v =~ s/[^[:print:]]/./g;
695 618 return "$quote$v$quote";
696 }
697  
698 42 ▶sub sql_type_cast {
Subroutine sql_type_cast: called CC=12 SCAR=24.9
Pod documented
699 42 my (undef, $sql_type, $flags) = @_;
700  
701 42 ▶ return -1 unless defined $_[0];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[0] 2 40 42
702  
703 40 my $cast_ok = 1;
704  
705 40 ▶ my $evalret = eval {
Branch: 1 branch
BranchTrueFalseTotal
my $evalret = eval { do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x5d\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} if ($sql_type == 4) { my $dummy = $_[0] + 0; return 1; } elsif ($sql_type == 8) { my $dummy = $_[0] + 0; return 1; } elsif ($sql_type == 2) { my $dummy = $_[0] + 0; return 1; } else { return -2; } } } or $^W and warn $@ 28 12 40
Condition66%2/3
(my $evalret = eval { do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x5d\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} if ($sql_type == 4) { my $dummy = $_[0] + 0; return 1; } elsif ($sql_type == 8) { my $dummy = $_[0] + 0.0; return 1; } elsif ($sql_type == 2) { my $dummy = $_[0] + 0.0; return 1; } else { return -2; } } }) || $^W && warn($@)
l!l&&r!l&&!r
28120
MC/DC0%0/2
(my $evalret = eval { do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x5d\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} if ($sql_type == 4) { my $dummy = $_[0] + 0; return 1; } elsif ($sql_type == 8) { my $dummy = $_[0] + 0.0; return 1; } elsif ($sql_type == 2) { my $dummy = $_[0] + 0.0; return 1; } else { return -2; } } }) || $^W && warn($@)
(my $evalret = eval { do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x5d\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} if ($sql_type == 4) { my $dummy = $_[0] + 0; return 1; } elsif ($sql_type == 8) { my $dummy = $_[0] + 0.0; return 1; } elsif ($sql_type == 2) { my $dummy = $_[0] + 0.0; return 1; } else { return -2; } } }) $^W && warn($@)
Truth table66%2/3
A || B
A= (my $evalret = eval { do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x5d\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} if ($sql_type == 4) { my $dummy = $_[0] + 0; return 1; } elsif ($sql_type == 8) { my $dummy = $_[0] + 0.0; return 1; } elsif ($sql_type == 2) { my $dummy = $_[0] + 0.0; return 1; } else { return -2; } } })B= $^W && warn($@)
ABresult
1X1
011
000
706 107 ▶ use warnings FATAL => qw(numeric);
Subroutine BEGIN: called CC=1 SCAR=0.0
707 40 ▶ if ($sql_type == SQL_INTEGER) {
Branch: 3 branches
BranchTrueFalseTotal
if ($sql_type == 4) { } 28 12 40
elsif ($sql_type == 8) { } 4 8 12
elsif ($sql_type == 2) { } 4 4 8
708 28 my $dummy = $_[0] + 0;
709 24 return 1;
710 }
711 elsif ($sql_type == SQL_DOUBLE) {
712 4 my $dummy = $_[0] + 0.0;
713 0 return 1;
714 }
715 elsif ($sql_type == SQL_NUMERIC) {
716 4 my $dummy = $_[0] + 0.0;
717 0 return 1;
718 }
719 else {
720 4 ▶ return -2;
Condition50%1/2
$^W and warn $@
!ll
120
MC/DC0%0/1
$^W and warn $@
$^W
Truth table50%1/2
A
A= $^W
Aresult
00
11
721 }
722 } or $^W && warn $@; # XXX warnings::warnif("numeric", $@) ?
723  
724 40 ▶ return $evalret if defined($evalret) && ($evalret == -2);
Branch: 1 branch
BranchTrueFalseTotal
if defined $evalret and $evalret == -2 4 36 40
Condition100%3/3
defined $evalret and $evalret == -2
!ll&&!rl&&r
12244
MC/DC100%2/2
defined $evalret and $evalret == -2
defined $evalret $evalret == -2
Truth table100%3/3
A and B
A= defined $evalretB= $evalret == -2
ABresult
0X0
100
111
725 36 ▶ $cast_ok = 0 unless $evalret;
Branch: 1 branch
BranchTrueFalseTotal
unless $evalret 12 24 36
726  
727 # DBIstcf_DISCARD_STRING not supported for PurePerl currently
728  
729 36 ▶ return 2 if $cast_ok;
Branch: 1 branch
BranchTrueFalseTotal
if $cast_ok 24 12 36
730 12 ▶ return 0 if $flags & DBIstcf_STRICT;
Branch: 1 branch
BranchTrueFalseTotal
if $flags & 1 6 6 12
731 6 return 1;
732 }
733  
734 0 ▶sub dbi_time {
Subroutine dbi_time: not called CC=1 SCAR=6.9
Pod documented
735 0 return time();
736 }
737  
738 3226 ▶sub DBI::st::TIEHASH { bless $_[1] => $_[0] };
Subroutine TIEHASH: called CC=1 SCAR=0.0
739  
740 228 ▶sub _concat_hash_sorted {
Subroutine _concat_hash_sorted: called CC=7 SCAR=19.5
741 228 my ( $hash_ref, $kv_separator, $pair_separator, $use_neat, $num_sort ) = @_;
742 # $num_sort: 0=lexical, 1=numeric, undef=try to guess
743  
744 228 ▶ return undef unless defined $hash_ref;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $hash_ref 15 213 228
745 213 ▶ die "hash is not a hash reference" unless ref $hash_ref eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $hash_ref eq "HASH" 2 211 213
746 211 my $keys = _get_sorted_hash_keys($hash_ref, $num_sort);
747 211 my $string = '';
748 211 for my $key (@$keys) {
749 5632 ▶ $string .= $pair_separator if length $string > 0;
Branch: 1 branch
BranchTrueFalseTotal
if length $string > 0 5429 203 5632
750 5632 my $value = $hash_ref->{$key};
751 5632 ▶ if ($use_neat) {
Branch: 1 branch
BranchTrueFalseTotal
if ($use_neat) { } 4412 1220 5632
752 4412 $value = DBI::neat($value, 0);
753 }
754 else {
755 1220 ▶ $value = (defined $value) ? "'$value'" : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $value ? : 865 355 1220
756 }
757 5632 $string .= $key . $kv_separator . $value;
758 }
759 211 return $string;
760 }
761  
762 211 ▶sub _get_sorted_hash_keys {
Subroutine _get_sorted_hash_keys: called CC=6 SCAR=17.9
763 211 my ($hash_ref, $num_sort) = @_;
764 211 ▶ if (not defined $num_sort) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num_sort) 50 161 211
765 50 my $sort_guess = 1;
766 $sort_guess = (not looks_like_number($_)) ? 0 : $sort_guess
767 50 ▶ for keys %$hash_ref;
Branch: 1 branch
BranchTrueFalseTotal
!looks_like_number($_) ? : 40 4336 4376
768 50 $num_sort = $sort_guess;
769 }
770  
771 211 my @keys = keys %$hash_ref;
772 107 ▶ no warnings 'numeric';
Subroutine BEGIN: called CC=1 SCAR=0.0
773 my @sorted = ($num_sort)
774 211 ▶ ? sort { $a <=> $b or $a cmp $b } @keys
Branch: 1 branch
BranchTrueFalseTotal
$num_sort ? : 54 157 211
Condition66%2/3
$a <=> $b || $a cmp $b
l!l&&r!l&&!r
36399360
MC/DC0%0/2
$a <=> $b || $a cmp $b
$a <=> $b $a cmp $b
Truth table66%2/3
A || B
A= $a <=> $bB= $a cmp $b
ABresult
1X1
011
000
775 : sort @keys;
776 211 return \@sorted;
777 }
778  
779 78594 ▶sub _err_hash {
Subroutine _err_hash: called CC=3 SCAR=11.1
780 78594 ▶ return 1 unless defined $_[0]->{err};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[0]{"err"} 77477 1117 78594
781 1117 ▶ return join " " => $_[0]->{err}, $_[0]->{errstr} // "?";
Condition50%1/2
$_[0]{"errstr"} // "?"
l!l
11170
MC/DC0%0/1
$_[0]{"errstr"} // "?"
$_[0]{"errstr"}
Truth table50%1/2
A
A= $_[0]{"errstr"}
Aresult
11
00
782 }
783  
784  
785 package
786 DBI::var;
787  
788 0 ▶sub FETCH {
Subroutine FETCH: not called CC=3 SCAR=24.8
789 0 my($key)=shift;
790 0 ▶ return $DBI::err if $$key eq '*err';
Branch: 1 branch
BranchTrueFalseTotal
if $$key eq "*err" 0 0 0
791 0 ▶ return $DBI::errstr if $$key eq '&errstr';
Branch: 1 branch
BranchTrueFalseTotal
if $$key eq "&errstr" 0 0 0
792 0 Carp::confess("FETCH $key not supported when using DBI::PurePerl");
793 }
794  
795 package
796 DBD::_::common;
797  
798 0 ▶sub swap_inner_handle {
Subroutine swap_inner_handle: not called CC=1 SCAR=6.9
799 0 my ($h1, $h2) = @_;
800 # can't make this work till we can get the outer handle from the inner one
801 # probably via a WeakRef
802 0 return $h1->set_err($DBI::stderr, "swap_inner_handle not currently supported by DBI::PurePerl");
803 }
804  
805 160 ▶sub trace { # XXX should set per-handle level, not global
Subroutine trace: called CC=7 SCAR=19.5
806 160 my ($h, $level, $file) = @_;
807 160 ▶ $level = $h->parse_trace_flags($level)
Branch: 1 branch
BranchTrueFalseTotal
if defined $level and not DBI::looks_like_number($level) 26 134 160
Condition100%3/3
defined $level and not DBI::looks_like_number($level)
!ll&&!rl&&r
449026
MC/DC100%2/2
defined $level and not DBI::looks_like_number($level)
defined $level not DBI::looks_like_number($level)
Truth table100%3/3
A and not(B)
A= defined $levelB= not DBI::looks_like_number($level)
ABresult
0X0
100
111
808 if defined $level and !DBI::looks_like_number($level);
809 160 my $old_level = $DBI::dbi_debug;
810 160 ▶ DBI::_set_trace_file($file) if defined $file;
Branch: 1 branch
BranchTrueFalseTotal
if defined $file 20 140 160
811 160 ▶ if (defined $level) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $level) 116 44 160
812 116 $DBI::dbi_debug = $level;
813 116 ▶ if ($DBI::dbi_debug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($DBI::dbi_debug) 78 38 116
814 78 printf $DBI::tfh
815 " %s trace level set to %d in DBI $DBI::VERSION (PurePerl)\n",
816 $h, $DBI::dbi_debug;
817 print $DBI::tfh " Full trace not available because DBI_TRACE is not in environment\n"
818 78 ▶ unless exists $ENV{DBI_TRACE};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $ENV{"DBI_TRACE"} 14 64 78
819 }
820 }
821 160 return $old_level;
822 }
823 107 *debug = \&trace; *debug = \&trace; # twice to avoid typo warning
824  
825 4743 ▶sub FETCH {
Subroutine FETCH: called CC=21 SCAR=30.7
826 4743 my($h,$key)= @_;
827 4743 my $v = $h->{$key};
828 #warn ((exists $h->{$key}) ? "$key=$v\n" : "$key NONEXISTANT\n");
829 4743 ▶ return $v if defined $v;
Branch: 1 branch
BranchTrueFalseTotal
if defined $v 741 4002 4743
830 4002 ▶ if ($key =~ /^NAME_.c$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key =~ /^NAME_.c$/) 111 3891 4002
831 111 my $cols = $h->FETCH('NAME');
832 111 ▶ return undef unless $cols;
Branch: 1 branch
BranchTrueFalseTotal
unless $cols 4 107 111
833 107 my @lcols = map { lc $_ } @$cols;
834 107 $h->{NAME_lc} = \@lcols;
835 107 my @ucols = map { uc $_ } @$cols;
836 107 $h->{NAME_uc} = \@ucols;
837 107 return $h->FETCH($key);
838 }
839 3891 ▶ if ($key =~ /^NAME.*_hash$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key =~ /^NAME.*_hash$/) 60 3831 3891
840 60 my $i=0;
841 60 ▶ for my $c(@{$h->FETCH('NAME')||[]}) {
Condition100%2/2
$h->FETCH('NAME') || []
l!l
546
MC/DC100%1/1
$h->FETCH('NAME') || []
$h->FETCH('NAME')
Truth table100%2/2
A
A= $h->FETCH('NAME')
Aresult
11
00
842 124 $h->{'NAME_hash'}->{$c} = $i;
843 124 $h->{'NAME_lc_hash'}->{"\L$c"} = $i;
844 124 $h->{'NAME_uc_hash'}->{"\U$c"} = $i;
845 124 $i++;
846 }
847 60 return $h->{$key};
848 }
849 3831 ▶ if (!defined $v && !exists $h->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $v or exists $h->{$key}) 3831 0 3831
Condition33%1/3
defined $v or exists $h->{$key}
l!l&&r!l&&!r
003831
MC/DC0%0/2
defined $v or exists $h->{$key}
defined $v exists $h->{$key}
Truth table33%1/3
A or B
A= defined $vB= exists $h->{$key}
ABresult
1X1
011
000
850 3831 ▶ return ($h->FETCH('TaintIn') && $h->FETCH('TaintOut')) if $key eq'Taint';
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "Taint" 8 3823 3831
Condition33%1/3
$h->FETCH('TaintIn') && $h->FETCH('TaintOut')
!ll&&!rl&&r
800
MC/DC0%0/2
$h->FETCH('TaintIn') && $h->FETCH('TaintOut')
$h->FETCH('TaintIn') $h->FETCH('TaintOut')
Truth table33%1/3
A && B
A= $h->FETCH('TaintIn')B= $h->FETCH('TaintOut')
ABresult
0X0
100
111
851 3823 ▶ return (1==0) if $is_flag_attribute{$key}; # return perl-style sv_no, not undef
Branch: 1 branch
BranchTrueFalseTotal
if $is_flag_attribute{$key} 1296 2527 3823
852 2527 ▶ return $DBI::dbi_debug if $key eq 'TraceLevel';
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "TraceLevel" 98 2429 2527
853 2429 ▶ return [] if $key eq 'ChildHandles' && $HAS_WEAKEN;
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "ChildHandles" and $HAS_WEAKEN 42 2387 2429
Condition66%2/3
$key eq "ChildHandles" and $HAS_WEAKEN
!ll&&!rl&&r
2387042
MC/DC50%1/2
$key eq "ChildHandles" and $HAS_WEAKEN
$key eq "ChildHandles" $HAS_WEAKEN
Truth table66%2/3
A and B
A= $key eq "ChildHandles"B= $HAS_WEAKEN
ABresult
0X0
100
111
854 2387 ▶ if ($key eq 'Type') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "Type") 50 2337 2387
855 50 ▶ return "dr" if $h->isa('DBI::dr');
Branch: 1 branch
BranchTrueFalseTotal
if $h->isa("DBI::dr") 0 50 50
856 50 ▶ return "db" if $h->isa('DBI::db');
Branch: 1 branch
BranchTrueFalseTotal
if $h->isa("DBI::db") 6 44 50
857 44 ▶ return "st" if $h->isa('DBI::st');
Branch: 1 branch
BranchTrueFalseTotal
if $h->isa("DBI::st") 44 0 44
858 0 Carp::carp( sprintf "Can't determine Type for %s",$h );
859 }
860 2337 ▶ if (!$is_valid_attribute{$key} and $key =~ m/^[A-Z]/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $is_valid_attribute{$key} and $key =~ /^[A-Z]/) 2 2335 2337
Condition100%3/3
not $is_valid_attribute{$key} and $key =~ /^[A-Z]/
!ll&&!rl&&r
19783572
MC/DC100%2/2
not $is_valid_attribute{$key} and $key =~ /^[A-Z]/
not $is_valid_attribute{$key} $key =~ /^[A-Z]/
Truth table100%3/3
not(A) and B
A= not $is_valid_attribute{$key}B= $key =~ /^[A-Z]/
ABresult
0X0
100
111
861 107 ▶ no warnings; # hide undef warnings
Subroutine BEGIN: called CC=1 SCAR=0.0
862 2 Carp::carp( sprintf "Can't get %s->{%s}: unrecognised attribute (@{[ %$h ]})",$h,$key )
863 }
864 }
865 2337 return $v;
866 }
867 14435 ▶sub STORE {
Subroutine STORE: called CC=15 SCAR=27.1
868 14435 my ($h,$key,$value) = @_;
869 14435 ▶ if ($key eq 'AutoCommit') {
Branch: 5 branches
BranchTrueFalseTotal
if ($key eq 'AutoCommit') { } 584 13851 14435
elsif ($key =~ /^Taint/) { } 24 13827 13851
elsif ($key eq 'TraceLevel') { } 94 13733 13827
elsif ($key eq 'NUM_OF_FIELDS') { } 2246 11487 13733
elsif (not $is_valid_attribute{$key} and $key =~ /^[A-Z]/ and not exists $h->{$key}) { } 2 22969 22971
870 584 ▶ Carp::croak("DBD driver has not implemented the AutoCommit attribute")
Branch: 1 branch
BranchTrueFalseTotal
unless $value == -900 or $value == -901 0 584 584
Condition66%2/3
$value == -900 or $value == -901
l!l&&r!l&&!r
25820
MC/DC0%0/2
$value == -900 or $value == -901
$value == -900 $value == -901
Truth table66%2/3
A or B
A= $value == -900B= $value == -901
ABresult
1X1
011
000
871 unless $value == -900 || $value == -901;
872 584 $value = ($value == -901);
873 }
874 elsif ($key =~ /^Taint/ ) {
875 24 ▶ Carp::croak(sprintf "Can't set %s->{%s}: Taint mode not supported by DBI::PurePerl",$h,$key)
Branch: 1 branch
BranchTrueFalseTotal
if $value 0 24 24
876 if $value;
877 }
878 elsif ($key eq 'TraceLevel') {
879 94 $h->trace($value);
880 94 return 1;
881 }
882 elsif ($key eq 'NUM_OF_FIELDS') {
883 2246 $h->{$key} = $value;
884 2246 ▶ if ($value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value) 1691 555 2246
885 1691 my $fbav = DBD::_::st::dbih_setup_fbav($h);
886 1691 ▶ @$fbav = (undef) x $value if @$fbav != $value;
Branch: 1 branch
BranchTrueFalseTotal
if @$fbav != $value 4 1687 1691
887 }
888 2246 return 1;
889 }
890 ▶ elsif (!$is_valid_attribute{$key} && $key =~ /^[A-Z]/ && !exists $h->{$key}) {
Condition100%6/6
not $is_valid_attribute{$key} and $key =~ /^[A-Z]/ and not exists $h->{$key}
!ll&&!rl&&r
1148412
not $is_valid_attribute{$key} and $key =~ /^[A-Z]/
!ll&&!rl&&r
1033311513
MC/DC100%3/3
not $is_valid_attribute{$key} and $key =~ /^[A-Z]/ and not exists $h->{$key}
not $is_valid_attribute{$key} $key =~ /^[A-Z]/ not exists $h->{$key}
Truth table100%4/4
not(A) and B and not(C)
A= not $is_valid_attribute{$key}B= $key =~ /^[A-Z]/C= not exists $h->{$key}
ABCresult
0XX0
10X0
1100
1111
891 2 Carp::carp(sprintf "Can't set %s->{%s}: unrecognised attribute or invalid value %s",
892 $h,$key,$value);
893 }
894 12095 ▶ $h->{$key} = $is_flag_attribute{$key} ? !!$value : $value;
Branch: 1 branch
BranchTrueFalseTotal
$is_flag_attribute{$key} ? : 8191 3904 12095
895 12095 ▶ Scalar::Util::weaken($h->{$key}) if $key eq 'CachedKids';
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "CachedKids" 5 12090 12095
896 12095 return 1;
897 }
898 4 ▶sub DELETE {
Subroutine DELETE: called CC=2 SCAR=6.9
899 4 my ($h, $key) = @_;
900 4 ▶ return $h->FETCH($key) unless $key =~ /^private_/;
Branch: 1 branch
BranchTrueFalseTotal
unless $key =~ /^private_/ 2 2 4
901 2 return delete $h->{$key};
902 }
903 101 ▶sub err { return shift->{err} }
Subroutine err: called CC=1 SCAR=0.0
904 114 ▶sub errstr { return shift->{errstr} }
Subroutine errstr: called CC=1 SCAR=0.0
905 10 ▶sub state { return shift->{state} }
Subroutine state: called CC=1 SCAR=0.0
906 1328 ▶sub set_err {
Subroutine set_err: called CC=25 SCAR=32.2
907 1328 my ($h, $errnum,$msg,$state, $method, $rv) = @_;
908 1328 ▶ $h = tied(%$h) || $h;
Condition33%1/3
tied %$h || $h
l!l&&r!l&&!r
013280
MC/DC0%0/2
tied %$h || $h
tied %$h $h
Truth table33%1/3
A || B
A= tied %$hB= $h
ABresult
1X1
011
000
909  
910 1328 ▶ if (my $hss = $h->{HandleSetErr}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $hss = $h->{"HandleSetErr"}) 38 1290 1328
911 38 ▶ return if $hss->($h, $errnum, $msg, $state, $method);
Branch: 1 branch
BranchTrueFalseTotal
if &$hss($h, $errnum, $msg, $state, $method) 2 36 38
912 }
913  
914 1326 ▶ if (!defined $errnum) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $errnum) 894 432 1326
915 894 $h->{err} = $DBI::err = undef;
916 894 $h->{errstr} = $DBI::errstr = undef;
917 894 $h->{state} = $DBI::state = '';
918 894 return;
919 }
920  
921 432 ▶ if ($h->{errstr}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h->{'errstr'}) { } 27 405 432
922 $h->{errstr} .= sprintf " [err was %s now %s]", $h->{err}, $errnum
923 27 ▶ if $h->{err} && $errnum && $h->{err} ne $errnum;
Branch: 1 branch
BranchTrueFalseTotal
if $h->{"err"} and $errnum and $h->{"err"} ne $errnum 10 17 27
Condition100%6/6
$h->{"err"} and $errnum and $h->{"err"} ne $errnum
!ll&&!rl&&r
13410
$h->{"err"} and $errnum
!ll&&!rl&&r
6714
MC/DC100%3/3
$h->{"err"} and $errnum and $h->{"err"} ne $errnum
$h->{"err"} $errnum $h->{"err"} ne $errnum
Truth table100%4/4
A and B and C
A= $h->{"err"}B= $errnumC= $h->{"err"} ne $errnum
ABCresult
0XX0
10X0
1100
1111
924 $h->{errstr} .= sprintf " [state was %s now %s]", $h->{state}, $state
925 27 ▶ if $h->{state} and $h->{state} ne "S1000" && $state && $h->{state} ne $state;
Branch: 1 branch
BranchTrueFalseTotal
if $h->{"state"} and ($h->{"state"} ne "S1000" and $state and $h->{"state"} ne $state) 4 23 27
Condition100%9/9
$h->{"state"} and ($h->{"state"} ne "S1000" and $state and $h->{"state"} ne $state)
!ll&&!rl&&r
4194
$h->{"state"} ne "S1000" and $state and $h->{"state"} ne $state
!ll&&!rl&&r
1724
$h->{"state"} ne "S1000" and $state
!ll&&!rl&&r
1166
MC/DC100%4/4
$h->{"state"} and ($h->{"state"} ne "S1000" and $state and $h->{"state"} ne $state)
$h->{"state"} $h->{"state"} ne "S1000" $state $h->{"state"} ne $state
Truth table100%5/5
A and B and C and D
A= $h->{"state"}B= $h->{"state"} ne "S1000"C= $stateD= $h->{"state"} ne $state
ABCDresult
0XXX0
10XX0
110X0
11100
11111
926 27 ▶ $h->{errstr} .= "\n$msg" if $h->{errstr} ne $msg;
Branch: 1 branch
BranchTrueFalseTotal
if $h->{"errstr"} ne $msg 25 2 27
927 27 $DBI::errstr = $h->{errstr};
928 }
929 else {
930 405 $h->{errstr} = $DBI::errstr = $msg;
931 }
932  
933 # assign if higher priority: err > "0" > "" > undef
934 432 my $err_changed;
935 432 ▶ if ($errnum # new error: so assign
Branch: 1 branch
BranchTrueFalseTotal
if ($errnum or not defined $h->{"err"} or defined $errnum and length $errnum > length $h->{"err"}) 423 9 432
Condition88%8/9
$errnum or not defined $h->{"err"} or defined $errnum and length $errnum > length $h->{"err"}
l!l&&r!l&&!r
42039
$errnum or not defined $h->{"err"}
l!l&&r!l&&!r
3833712
defined $errnum and length $errnum > length $h->{"err"}
!ll&&!rl&&r
093
MC/DC75%3/4
$errnum or not defined $h->{"err"} or defined $errnum and length $errnum > length $h->{"err"}
$errnum not defined $h->{"err"} defined $errnum length $errnum > length $h->{"err"}
Truth table80%4/5
A or not(B) or C and D
A= $errnumB= not defined $h->{"err"}C= defined $errnumD= length $errnum > length $h->{"err"}
ABCDresult
1XXX1
01XX1
00111
000X0
00100
936 or !defined $h->{err} # no existing warn/info: so assign
937 # new warn ("0" len 1) > info ("" len 0): so assign
938 or defined $errnum && length($errnum) > length($h->{err})
939 ) {
940 423 $h->{err} = $DBI::err = $errnum;
941 423 ▶ ++$h->{ErrCount} if $errnum;
Branch: 1 branch
BranchTrueFalseTotal
if $errnum 383 40 423
942 423 ++$err_changed;
943 }
944  
945 432 ▶ if ($err_changed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($err_changed) 423 9 432
946 423 ▶ $state ||= "S1000" if $DBI::err;
Branch: 1 branch
BranchTrueFalseTotal
if $DBI::err 383 40 423
Condition100%2/2
$state ||= "S1000"
l!l
101282
MC/DC100%1/1
$state ||= "S1000"
$state
Truth table100%2/2
A
A= $state
Aresult
11
00
947 423 ▶ $h->{state} = $DBI::state = ($state eq "00000") ? "" : $state
Branch: 2 branches
BranchTrueFalseTotal
if $state 385 38 423
$state eq '00000' ? : 2 383 385
948 if $state;
949 }
950  
951 432 ▶ if (my $p = $h->{Database}) { # just sth->dbh, not dbh->drh (see ::db::DESTROY)
Branch: 1 branch
BranchTrueFalseTotal
if (my $p = $h->{"Database"}) 224 208 432
952 224 $p->{err} = $DBI::err;
953 224 $p->{errstr} = $DBI::errstr;
954 224 $p->{state} = $DBI::state;
955 }
956  
957 432 $h->{'dbi_pp_last_method'} = $method;
958 432 return $rv; # usually undef
959 }
960 4714 ▶sub trace_msg {
Subroutine trace_msg: called CC=3 SCAR=11.0
961 4714 my ($h, $msg, $minlevel)=@_;
962 4714 ▶ $minlevel //= 1;
Condition100%2/2
$minlevel //= 1
l!l
16613053
MC/DC100%1/1
$minlevel //= 1
$minlevel
Truth table100%2/2
A
A= $minlevel
Aresult
11
00
963 4714 ▶ return unless $minlevel <= ($DBI::dbi_debug & 0xF);
Branch: 1 branch
BranchTrueFalseTotal
unless $minlevel <= ($DBI::dbi_debug & 15) 4641 73 4714
964 73 print $DBI::tfh $msg;
965 73 return 1;
966 }
967 0 ▶sub private_data {
Subroutine private_data: not called CC=1 SCAR=6.9
968 0 warn "private_data @_";
969 }
970 1 ▶sub take_imp_data {
Subroutine take_imp_data: called CC=8 SCAR=20.9
971 1 my $dbh = shift;
972 # A reasonable default implementation based on the one in DBI.xs.
973 # Typically a pure-perl driver would have their own take_imp_data method
974 # that would delete all but the essential items in the hash before ending with:
975 # return $dbh->SUPER::take_imp_data();
976 # Of course it's useless if the driver doesn't also implement support for
977 # the dbi_imp_data attribute to the connect() method.
978 1 require Storable;
979 croak("Can't take_imp_data from handle that's not Active")
980 1 ▶ unless $dbh->{Active};
Branch: 1 branch
BranchTrueFalseTotal
unless $dbh->{"Active"} 0 1 1
981 1 ▶ for my $sth (@{ $dbh->{ChildHandles} || [] }) {
Condition50%1/2
$dbh->{'ChildHandles'} || []
l!l
10
MC/DC0%0/1
$dbh->{'ChildHandles'} || []
$dbh->{'ChildHandles'}
Truth table50%1/2
A
A= $dbh->{'ChildHandles'}
Aresult
11
00
982 3 ▶ next unless $sth;
Branch: 1 branch
BranchTrueFalseTotal
unless $sth 1 2 3
983 2 ▶ $sth->finish if $sth->{Active};
Branch: 1 branch
BranchTrueFalseTotal
if $sth->{"Active"} 1 1 2
984 2 bless $sth, 'DBI::zombie';
985 }
986 1 delete $dbh->{$_} for (keys %is_valid_attribute);
987 1 delete $dbh->{$_} for grep { m/^dbi_/ } keys %$dbh;
988 # warn "@{[ %$dbh ]}";
989 1 local $Storable::forgive_me = 1; # in case there are some CODE refs
990 1 my $imp_data = Storable::freeze($dbh);
991 # XXX um, should probably untie here - need to check dispatch behaviour
992 1 return $imp_data;
993 }
994 0 ▶sub rows {
Subroutine rows: not called CC=1 SCAR=6.9
995 0 return -1; # always returns -1 here, see DBD::_::st::rows below
996 }
997 2060 ▶sub DESTROY {
Subroutine DESTROY: called CC=1 SCAR=0.0
998 }
999  
1000 package
1001 DBD::_::dr;
1002  
1003 4 ▶sub dbixs_revision {
Subroutine dbixs_revision: called CC=1 SCAR=0.0
1004 4 return 0;
1005 }
1006  
1007 package
1008 DBD::_::db;
1009  
1010 711 ▶sub connected {
Subroutine connected: called CC=1 SCAR=0.0
1011 }
1012  
1013  
1014 package
1015 DBD::_::st;
1016  
1017 0 ▶sub fetchrow_arrayref {
Subroutine fetchrow_arrayref: not called CC=2 SCAR=17.9
1018 0 my $h = shift;
1019 # if we're here then driver hasn't implemented fetch/fetchrow_arrayref
1020 # so we assume they've implemented fetchrow_array and call that instead
1021 0 ▶ my @row = $h->fetchrow_array or return;
Branch: 1 branch
BranchTrueFalseTotal
my(@row) = $h->fetchrow_array or return 0 0 0
1022 0 return $h->_set_fbav(\@row);
1023 }
1024 # twice to avoid typo warning
1025 107 *fetch = \&fetchrow_arrayref; *fetch = \&fetchrow_arrayref;
1026  
1027 4 ▶sub fetchrow_array {
Subroutine fetchrow_array: called CC=2 SCAR=7.1
1028 4 my $h = shift;
1029 # if we're here then driver hasn't implemented fetchrow_array
1030 # so we assume they've implemented fetch/fetchrow_arrayref
1031 4 ▶ my $row = $h->fetch or return;
Branch: 1 branch
BranchTrueFalseTotal
my $row = $h->fetch or return 4 0 4
1032 4 return @$row;
1033 }
1034 107 *fetchrow = \&fetchrow_array; *fetchrow = \&fetchrow_array;
1035  
1036 28 ▶sub fetchrow_hashref {
Subroutine fetchrow_hashref: called CC=4 SCAR=14.0
1037 28 my $h = shift;
1038 28 ▶ my $row = $h->fetch or return;
Branch: 1 branch
BranchTrueFalseTotal
my $row = $h->fetch or return 26 2 28
1039 26 my $FetchCase = shift;
1040 26 ▶ my $FetchHashKeyName = $FetchCase || $h->{'FetchHashKeyName'} || 'NAME';
Condition60%3/5
$FetchCase || $h->{'FetchHashKeyName'} || 'NAME'
l!l
260
$FetchCase or $h->{"FetchHashKeyName"}
l!l&&r!l&&!r
4220
MC/DC0%0/2
$FetchCase || $h->{'FetchHashKeyName'} || 'NAME'
$FetchCase $h->{"FetchHashKeyName"}
Truth table66%2/3
A or B
A= $FetchCaseB= $h->{"FetchHashKeyName"}
ABresult
1X1
011
000
1041 26 my $FetchHashKeys = $h->FETCH($FetchHashKeyName);
1042 26 my %rowhash;
1043 26 @rowhash{ @$FetchHashKeys } = @$row;
1044 22 return \%rowhash;
1045 }
1046 1923 ▶sub dbih_setup_fbav {
Subroutine dbih_setup_fbav: called CC=3 SCAR=11.2
1047 1923 my $h = shift;
1048 1923 ▶ return $h->{'_fbav'} || do {
Condition66%2/3
$h->{'_fbav'} || do { $DBI::rows = $h->{'_rows'} = 0; my $fields = $h->{'NUM_OF_FIELDS'} or DBI::croak('NUM_OF_FIELDS not set'); my(@row) = (undef) x $fields; \@row }
l!l&&r!l&&!r
419190
MC/DC0%0/2
$h->{'_fbav'} || do { $DBI::rows = $h->{'_rows'} = 0; my $fields = $h->{'NUM_OF_FIELDS'} or DBI::croak('NUM_OF_FIELDS not set'); my(@row) = (undef) x $fields; \@row }
$h->{'_fbav'} do { $DBI::rows = $h->{'_rows'} = 0; my $fields = $h->{'NUM_OF_FIELDS'} or DBI::croak('NUM_OF_FIELDS not set'); my(@row) = (undef) x $fields; \@row }
Truth table66%2/3
A || B
A= $h->{'_fbav'}B= do { $DBI::rows = $h->{'_rows'} = 0; my $fields = $h->{'NUM_OF_FIELDS'} or DBI::croak('NUM_OF_FIELDS not set'); my(@row) = (undef) x $fields; \@row }
ABresult
1X1
011
000
1049 1919 $DBI::rows = $h->{'_rows'} = 0;
1050 1919 ▶ my $fields = $h->{'NUM_OF_FIELDS'}
Branch: 1 branch
BranchTrueFalseTotal
my $fields = $h->{"NUM_OF_FIELDS"} or DBI::croak("NUM_OF_FIELDS not set") 1919 0 1919
1051 or DBI::croak("NUM_OF_FIELDS not set");
1052 1919 my @row = (undef) x $fields;
1053 1919 \@row;
1054 };
1055 }
1056 172 ▶sub _get_fbav {
Subroutine _get_fbav: called CC=2 SCAR=7.0
1057 172 my $h = shift;
1058 172 ▶ my $av = $h->{'_fbav'} ||= dbih_setup_fbav($h);
Condition66%2/3
$h->{"_fbav"} ||= dbih_setup_fbav($h)
l!l&&r!l&&!r
61660
MC/DC0%0/2
$h->{"_fbav"} ||= dbih_setup_fbav($h)
$h->{"_fbav"} dbih_setup_fbav($h)
Truth table66%2/3
A ||= B
A= $h->{"_fbav"}B= dbih_setup_fbav($h)
ABresult
1X1
011
000
1059 172 $DBI::rows = ++$h->{'_rows'};
1060 172 return $av;
1061 }
1062 1679 ▶sub _set_fbav {
Subroutine _set_fbav: called CC=5 SCAR=16.1
1063 1679 my $h = shift;
1064 1679 my $fbav = $h->{'_fbav'};
1065 1679 ▶ if ($fbav) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fbav) { } 1513 166 1679
1066 1513 $DBI::rows = ++$h->{'_rows'};
1067 }
1068 else {
1069 166 $fbav = $h->_get_fbav;
1070 }
1071 1679 my $row = shift;
1072 1679 ▶ if (my $bc = $h->{'_bound_cols'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $bc = $h->{'_bound_cols'}) { } 182 1497 1679
1073 182 for my $i (0..@$row-1) {
1074 474 my $bound = $bc->[$i];
1075 474 ▶ $fbav->[$i] = ($bound) ? ($$bound = $row->[$i]) : $row->[$i];
Branch: 1 branch
BranchTrueFalseTotal
$bound ? : 432 42 474
1076 }
1077 }
1078 else {
1079 1497 @$fbav = @$row;
1080 }
1081 1679 return $fbav;
1082 }
1083 162 ▶sub bind_col {
Subroutine bind_col: called CC=6 SCAR=18.0
1084 162 my ($h, $col, $value_ref,$from_bind_columns) = @_;
1085 162 ▶ my $fbav = $h->{'_fbav'} ||= dbih_setup_fbav($h); # from _get_fbav()
Condition66%2/3
$h->{"_fbav"} ||= dbih_setup_fbav($h)
l!l&&r!l&&!r
96660
MC/DC0%0/2
$h->{"_fbav"} ||= dbih_setup_fbav($h)
$h->{"_fbav"} dbih_setup_fbav($h)
Truth table66%2/3
A ||= B
A= $h->{"_fbav"}B= dbih_setup_fbav($h)
ABresult
1X1
011
000
1086 162 my $num_of_fields = @$fbav;
1087 162 ▶ DBI::croak("bind_col: column $col is not a valid column (1..$num_of_fields)")
Branch: 1 branch
BranchTrueFalseTotal
if $col < 1 or $col > $num_of_fields 6 156 162
Condition100%3/3
$col < 1 or $col > $num_of_fields
l!l&&r!l&&!r
24156
MC/DC100%2/2
$col < 1 or $col > $num_of_fields
$col < 1 $col > $num_of_fields
Truth table100%3/3
A or B
A= $col < 1B= $col > $num_of_fields
ABresult
1X1
011
000
1088 if $col < 1 or $col > $num_of_fields;
1089 156 ▶ return 1 if not defined $value_ref; # ie caller is just trying to set TYPE
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value_ref 2 154 156
1090 154 ▶ DBI::croak("bind_col($col,$value_ref) needs a reference to a scalar")
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value_ref eq "SCALAR" 0 154 154
1091 unless ref $value_ref eq 'SCALAR';
1092 154 $h->{'_bound_cols'}->[$col-1] = $value_ref;
1093 154 return 1;
1094 }
1095 1252 ▶sub finish {
Subroutine finish: called CC=1 SCAR=0.0
1096 1252 my $h = shift;
1097 1252 $h->{'_fbav'} = undef;
1098 1252 $h->{'Active'} = 0;
1099 1252 return 1;
1100 }
1101 3 ▶sub rows {
Subroutine rows: called CC=2 SCAR=7.0
1102 3 my $h = shift;
1103 3 my $rows = $h->{'_rows'};
1104 3 ▶ return -1 unless defined $rows;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rows 0 3 3
1105 3 return $rows;
1106 }
1107  
1108 107 1;
1109 __END__
« blib/lib/DBD/DBM.pm ↑ Summary blib/lib/DBI/ProxyServer.pm »