blib/lib/DBI/DBD/SqlEngine.pm

filter: Statementstmt 79.3% 593 / 747 Branchbran 60.0% 222 / 370 Conditioncond 35.0% 74 / 211 MC/DCmcdc 16.9% 19 / 112 Subroutinesub 75.6% 90 / 119 Podpod 0.0% 0 / 1 totaltotal 63.9% 998 / 1560 CC 267 SCAR 30.0
CC
267
Cov
67%
quote
132.0
bind_param
118.1
FETCH
104.8
CRAP 20.2
« blib/lib/DBI/ProxyServer.pm ↑ Summary blib/lib/DBI/SQL/Nano.pm »
1 #!/usr/bin/perl
2 # -*- perl -*-
3 #
4 # DBI::DBD::SqlEngine - A base class for implementing DBI drivers that
5 # have not an own SQL engine
6 #
7 # This module is currently maintained by
8 #
9 # H.Merijn Brand & Jens Rehsack
10 #
11 # The original author is Jochen Wiedmann.
12 #
13 # Copyright (C) 2009-2026 by H.Merijn Brand & Jens Rehsack
14 # Copyright (C) 2004 by Jeff Zucker
15 # Copyright (C) 1998 by Jochen Wiedmann
16 #
17 # All rights reserved.
18 #
19 # You may distribute this module under the terms of either the GNU
20 # General Public License or the Artistic License, as specified in
21 # the Perl README file.
22  
23 450 require 5.012;
24  
25 450 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 450 ▶use DBI ();
Subroutine BEGIN: called CC=1 SCAR=0.0
28 450 require DBI::SQL::Nano;
29  
30 package DBI::DBD::SqlEngine;
31  
32 450 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 450 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 450 our %methods_installed;
36  
37 450 our $VERSION = "1.656";
38  
39 450 our $drh = undef; # holds driver handle(s) once initialized
40  
41 450 DBI->setup_driver("DBI::DBD::SqlEngine"); # only needed once but harmless to repeat
42  
43 450 my %accessors = (
44 versions => "get_driver_versions",
45 new_meta => "new_sql_engine_meta",
46 get_meta => "get_sql_engine_meta",
47 set_meta => "set_sql_engine_meta",
48 clear_meta => "clear_sql_engine_meta",
49 );
50  
51 sub driver ($;$)
52 442 ▶{
Subroutine driver: called CC=13 SCAR=29.6
Pod undocumented
53 442 my ( $class, $attr ) = @_;
54  
55 # Drivers typically use a singleton object for the $drh
56 # We use a hash here to have one singleton per subclass.
57 # (Otherwise DBD::CSV and DBD::DBM, for example, would
58 # share the same driver object which would cause problems.)
59 # An alternative would be to not cache the $drh here at all
60 # and require that subclasses do that. Subclasses should do
61 # their own caching, so caching here just provides extra safety.
62 442 ▶ $drh->{$class} and return $drh->{$class};
Branch: 1 branch
BranchTrueFalseTotal
$DBI::DBD::SqlEngine::drh->{$class} and return $DBI::DBD::SqlEngine::drh->{$class} 0 442 442
63  
64 442 ▶ $attr ||= {};
Condition50%1/2
$attr ||= {}
l!l
4420
MC/DC0%0/1
$attr ||= {}
$attr
Truth table50%1/2
A
A= $attr
Aresult
11
00
65 {
66 450 ▶ no strict "refs";
Subroutine BEGIN: called CC=1 SCAR=0.0
67 442 ▶ unless ( $attr->{Attribution} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($attr->{"Attribution"}) 0 442 442
68 {
69 $class eq "DBI::DBD::SqlEngine"
70 0 ▶ and $attr->{Attribution} = "$class by Jens Rehsack";
Branch: 1 branch
BranchTrueFalseTotal
$class eq "DBI::DBD::SqlEngine" and $attr->{"Attribution"} = "$class by Jens Rehsack" 0 0 0
71 0 ▶ $attr->{Attribution} ||= ${ $class . "::ATTRIBUTION" }
Condition0%0/5
$attr->{"Attribution"} ||= ${$class . '::ATTRIBUTION';} || "oops the author of $class forgot to define this"
l!l&&r!l&&!r
000
${$class . '::ATTRIBUTION';} || "oops the author of $class forgot to define this"
l!l
00
MC/DC0%0/2
$attr->{"Attribution"} ||= ${$class . '::ATTRIBUTION';} || "oops the author of $class forgot to define this"
$attr->{"Attribution"} ${$class . '::ATTRIBUTION';}
Truth table0%0/3
A ||= B
A= $attr->{"Attribution"}B= ${$class . '::ATTRIBUTION';}
ABresult
1X1
011
000
72 || "oops the author of $class forgot to define this";
73 }
74 442 ▶ $attr->{Version} ||= ${ $class . "::VERSION" };
Condition66%2/3
$attr->{"Version"} ||= ${$class . '::VERSION';}
l!l&&r!l&&!r
44020
MC/DC0%0/2
$attr->{"Version"} ||= ${$class . '::VERSION';}
$attr->{"Version"} ${$class . '::VERSION';}
Truth table66%2/3
A ||= B
A= $attr->{"Version"}B= ${$class . '::VERSION';}
ABresult
1X1
011
000
75 442 ▶ $attr->{Name} or ( $attr->{Name} = $class ) =~ s/^DBD\:\://;
Branch: 1 branch
BranchTrueFalseTotal
$attr->{"Name"} or ($attr->{"Name"} = $class) =~ s/^DBD\:\:// 440 2 442
76 }
77  
78 442 $drh->{$class} = DBI::_new_drh( $class . "::dr", $attr );
79 442 $drh->{$class}->STORE( ShowErrorStatement => 1 );
80  
81 442 my $prefix = DBI->driver_prefix($class);
82 442 ▶ if ($prefix)
Branch: 1 branch
BranchTrueFalseTotal
if ($prefix) { } 442 0 442
83 {
84 442 my $dbclass = $class . "::db";
85 442 ▶ while ( my ( $accessor, $funcname ) = each %accessors )
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %accessors) 2210 442 2652
86 {
87 2210 my $method = $prefix . $accessor;
88 2210 ▶ $dbclass->can($method) and next;
Branch: 1 branch
BranchTrueFalseTotal
$dbclass->can($method) and next 0 2210 2210
89 2210 my $inject = sprintf <<'EOI', $dbclass, $method, $dbclass, $funcname;
90 sub %s::%s
91 {
92 my $func = %s->can (q{%s});
93 goto &$func;
94 }
95 EOI
96 0 ▶ eval $inject;
Subroutine f_clear_meta: not called CC=1 SCAR=0.5
Subroutine f_get_meta: called CC=1 SCAR=0.5
Subroutine f_new_meta: called CC=1 SCAR=0.5
Subroutine f_set_meta: called CC=1 SCAR=0.5
Subroutine f_versions: called CC=1 SCAR=0.5
Subroutine dbm_clear_meta: called CC=1 SCAR=0.5
Subroutine dbm_get_meta: not called CC=1 SCAR=0.5
Subroutine dbm_new_meta: not called CC=1 SCAR=0.5
Subroutine dbm_set_meta: not called CC=1 SCAR=0.5
Subroutine dbm_versions: called CC=1 SCAR=0.5
97 2210 $dbclass->install_method($method);
98 }
99 }
100 else
101 {
102 0 warn "Using DBI::DBD::SqlEngine with unregistered driver $class.\n"
103 . "Reading documentation how to prevent is strongly recommended.\n";
104  
105 }
106  
107 # XXX inject DBD::XXX::Statement unless exists
108  
109 442 my $stclass = $class . "::st";
110 442 ▶ $stclass->install_method("sql_get_colnames") unless ( $methods_installed{__PACKAGE__}++ );
Branch: 1 branch
BranchTrueFalseTotal
unless $DBI::DBD::SqlEngine::methods_installed{"__PACKAGE__"}++ 440 2 442
111  
112 442 return $drh->{$class};
113 } # driver
114  
115 sub CLONE
116 0 ▶{
Subroutine CLONE: not called CC=1 SCAR=6.9
117 0 undef $drh;
118 } # CLONE
119  
120 # ====== DRIVER ================================================================
121  
122 package DBI::DBD::SqlEngine::dr;
123  
124 450 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
125 450 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
126  
127 450 ▶use Carp qw/carp/;
Subroutine BEGIN: called CC=1 SCAR=0.0
128  
129 450 our $imp_data_size = 0;
130  
131 sub connect ($$;$$$)
132 1250 ▶{
Subroutine connect: called CC=20 SCAR=33.2
133 1250 my ( $drh, $dbname, $user, $auth, $attr ) = @_;
134  
135 # create a 'blank' dbh
136 1250 my $dbh = DBI::_new_dbh(
137 $drh,
138 {
139 Name => $dbname,
140 USER => $user,
141 CURRENT_USER => $user,
142 }
143 );
144  
145 1250 ▶ if ($dbh)
Branch: 1 branch
BranchTrueFalseTotal
if ($dbh) 1250 0 1250
146 {
147 # must be done first, because setting flags implicitly calls $dbdname::db->STORE
148 1250 $dbh->func( 0, "init_default_attributes" );
149 1250 my $two_phased_init;
150 1250 ▶ defined $dbh->{sql_init_phase} and $two_phased_init = ++$dbh->{sql_init_phase};
Branch: 1 branch
BranchTrueFalseTotal
defined $dbh->{"sql_init_phase"} and $two_phased_init = ++$dbh->{"sql_init_phase"} 1250 0 1250
151 1250 my %second_phase_attrs;
152 my @func_inits;
153  
154 # this must be done to allow DBI.pm reblessing got handle after successful connecting
155 1250 ▶ exists $attr->{RootClass} and $second_phase_attrs{RootClass} = delete $attr->{RootClass};
Branch: 1 branch
BranchTrueFalseTotal
exists $attr->{"RootClass"} and $second_phase_attrs{"RootClass"} = delete $attr->{"RootClass"} 0 1250 1250
156  
157 1250 my ( $var, $val );
158 1250 ▶ while ( length $dbname )
Branch: 1 branch
BranchTrueFalseTotal
if (length $dbname) 3048 1250 4298
159 {
160 3048 ▶ if ( $dbname =~ s/^((?:[^\\;]|\\.)*?);//s )
Branch: 1 branch
BranchTrueFalseTotal
if ($dbname =~ s/^((?:[^\\;]|\\.)*?);//s) { } 2052 996 3048
161 {
162 2052 $var = $1;
163 }
164 else
165 {
166 996 $var = $dbname;
167 996 $dbname = "";
168 }
169  
170 3048 ▶ if ( $var =~ m/^(.+?)=(.*)/s )
Branch: 2 branches
BranchTrueFalseTotal
if ($var =~ /^(.+?)=(.*)/s) { } 3048 0 3048
elsif ($var =~ /^(.+?)=>(.*)/s) { } 0 0 0
171 {
172 3048 $var = $1;
173 3048 ( $val = $2 ) =~ s/\\(.)/$1/g;
174 3048 ▶ exists $attr->{$var}
Branch: 1 branch
BranchTrueFalseTotal
if $^W 1296 1752 3048
Condition50%3/6
$^W && (exists $attr->{$var} && carp("$var is given in DSN *and* \$attr during DBI->connect()"))
!ll&&!rl&&r
175212960
exists $attr->{$var} and carp("$var is given in DSN *and* \$attr during DBI->connect()")
!ll&&!rl&&r
129600
MC/DC0%0/3
$^W && (exists $attr->{$var} && carp("$var is given in DSN *and* \$attr during DBI->connect()"))
$^W exists $attr->{$var} carp("$var is given in DSN *and* \$attr during DBI->connect()")
Truth table0%0/4
A && B and C
A= $^WB= exists $attr->{$var}C= carp("$var is given in DSN *and* \$attr during DBI->connect()")
ABCresult
0XX0
10X0
1100
1111
175 and carp("$var is given in DSN *and* \$attr during DBI->connect()")
176 if ($^W);
177 3048 ▶ exists $attr->{$var} or $attr->{$var} = $val;
Branch: 1 branch
BranchTrueFalseTotal
exists $attr->{$var} or $attr->{$var} = $val 0 3048 3048
178 }
179 elsif ( $var =~ m/^(.+?)=>(.*)/s )
180 {
181 0 $var = $1;
182 0 ( $val = $2 ) =~ s/\\(.)/$1/g;
183 0 my $ref = eval $val;
184 # $dbh->$var($ref);
185 0 push( @func_inits, $var, $ref );
186 }
187 }
188  
189 # The attributes need to be sorted in a specific way as the
190 # assignment is through tied hashes and calls STORE on each
191 # attribute. Some attributes require to be called prior to
192 # others
193 # e.g. f_dir *must* be done before xx_tables in DBD::File
194 # The dbh attribute sql_init_order is a hash with the order
195 # as key (low is first, 0 .. 100) and the attributes that
196 # are set to that oreder as anon-list as value:
197 # { 0 => [qw( AutoCommit PrintError RaiseError Profile ... )],
198 # 10 => [ list of attr to be dealt with immediately after first ],
199 # 50 => [ all fields that are unspecified or default sort order ],
200 # 90 => [ all fields that are needed after other initialisation ],
201 # }
202  
203 my %order = map {
204 2500 my $order = $_;
205 2500 map { ( $_ => $order ) } @{ $dbh->{sql_init_order}{$order} };
206 1250 ▶ } sort { $a <=> $b } keys %{ $dbh->{sql_init_order} || {} };
Condition50%1/2
$dbh->{'sql_init_order'} || {}
l!l
12500
MC/DC0%0/1
$dbh->{'sql_init_order'} || {}
$dbh->{'sql_init_order'}
Truth table50%1/2
A
A= $dbh->{'sql_init_order'}
Aresult
11
00
207 my @ordered_attr =
208 13264 map { $_->[0] }
209 29799 sort { $a->[1] <=> $b->[1] }
210 1250 ▶ map { [ $_, $order{$_} // 50 ] }
Condition100%2/2
$order{$_} // 50
l!l
37509514
MC/DC100%1/1
$order{$_} // 50
$order{$_}
Truth table100%2/2
A
A= $order{$_}
Aresult
11
00
211 keys %$attr;
212  
213 # initialize given attributes ... lower weighted before higher weighted
214 1250 foreach my $a (@ordered_attr)
215 {
216 13264 ▶ exists $attr->{$a} or next;
Branch: 1 branch
BranchTrueFalseTotal
exists $attr->{$a} or next 13264 0 13264
217 13264 ▶ $two_phased_init and eval {
Branch: 1 branch
BranchTrueFalseTotal
$two_phased_init and eval { do { $dbh->{$a} = $attr->{$a}; delete $attr->{$a} } } 13264 0 13264
218 13264 $dbh->{$a} = $attr->{$a};
219 13264 delete $attr->{$a};
220 };
221 13264 ▶ $@ and $second_phase_attrs{$a} = delete $attr->{$a};
Branch: 1 branch
BranchTrueFalseTotal
$@ and $second_phase_attrs{$a} = delete $attr->{$a} 0 13264 13264
222 13264 ▶ $two_phased_init or $dbh->STORE( $a, delete $attr->{$a} );
Branch: 1 branch
BranchTrueFalseTotal
$two_phased_init or $dbh->STORE($a, delete $attr->{$a}) 13264 0 13264
223 }
224  
225 1250 ▶ $two_phased_init and $dbh->func( 1, "init_default_attributes" );
Branch: 1 branch
BranchTrueFalseTotal
$two_phased_init and $dbh->func(1, "init_default_attributes") 1250 0 1250
226 1250 %$attr = %second_phase_attrs;
227  
228 1250 ▶ for ( my $i = 0; $i < scalar(@func_inits); $i += 2 )
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @func_inits) 0 1250 1250
229 {
230 0 my $func = $func_inits[$i];
231 0 my $arg = $func_inits[ $i + 1 ];
232 0 $dbh->$func($arg);
233 }
234  
235 1250 $dbh->func("init_done");
236  
237 1250 $dbh->STORE( Active => 1 );
238 }
239  
240 1250 return $dbh;
241 } # connect
242  
243 sub data_sources ($;$)
244 80 ▶{
Subroutine data_sources: called CC=7 SCAR=23.8
245 80 my ( $drh, $attr ) = @_;
246  
247 80 my $tbl_src;
248 $attr
249 and defined $attr->{sql_table_source}
250 and $attr->{sql_table_source}->isa('DBI::DBD::SqlEngine::TableSource')
251 80 ▶ and $tbl_src = $attr->{sql_table_source};
Branch: 1 branch
BranchTrueFalseTotal
$attr and defined $attr->{"sql_table_source"} and $attr->{"sql_table_source"}->isa("DBI::DBD::SqlEngine::TableSource") and $tbl_src = $attr->{"sql_table_source"} 0 80 80
Condition33%2/6
$attr and defined $attr->{"sql_table_source"} and $attr->{"sql_table_source"}->isa("DBI::DBD::SqlEngine::TableSource")
!ll&&!rl&&r
8000
$attr and defined $attr->{"sql_table_source"}
!ll&&!rl&&r
0800
MC/DC0%0/3
$attr and defined $attr->{"sql_table_source"} and $attr->{"sql_table_source"}->isa("DBI::DBD::SqlEngine::TableSource")
$attr defined $attr->{"sql_table_source"} $attr->{"sql_table_source"}->isa("DBI::DBD::SqlEngine::TableSource")
Truth table25%1/4
A and B and C
A= $attrB= defined $attr->{"sql_table_source"}C= $attr->{"sql_table_source"}->isa("DBI::DBD::SqlEngine::TableSource")
ABCresult
0XX0
10X0
1100
1111
252  
253 !defined($tbl_src)
254 and $drh->{ImplementorClass}->can('default_table_source')
255 80 ▶ and $tbl_src = $drh->{ImplementorClass}->default_table_source();
Branch: 1 branch
BranchTrueFalseTotal
not defined $tbl_src and $drh->{"ImplementorClass"}->can("default_table_source") and $tbl_src = $drh->{"ImplementorClass"}->default_table_source 80 0 80
Condition33%1/3
not defined $tbl_src and $drh->{"ImplementorClass"}->can("default_table_source")
!ll&&!rl&&r
0080
MC/DC0%0/2
not defined $tbl_src and $drh->{"ImplementorClass"}->can("default_table_source")
not defined $tbl_src $drh->{"ImplementorClass"}->can("default_table_source")
Truth table33%1/3
not(A) and B
A= not defined $tbl_srcB= $drh->{"ImplementorClass"}->can("default_table_source")
ABresult
0X0
100
111
256 80 ▶ defined($tbl_src) or return;
Branch: 1 branch
BranchTrueFalseTotal
defined $tbl_src or return 80 0 80
257  
258 80 $tbl_src->data_sources( $drh, $attr );
259 } # data_sources
260  
261 sub disconnect_all
262 2 ▶{
Subroutine disconnect_all: called CC=1 SCAR=0.0
263 } # disconnect_all
264  
265 sub DESTROY
266 0 ▶{
Subroutine DESTROY: not called CC=1 SCAR=6.9
267 0 undef;
268 } # DESTROY
269  
270 # ====== DATABASE ==============================================================
271  
272 package DBI::DBD::SqlEngine::db;
273  
274 450 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
275 450 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
276  
277 450 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
278 450 ▶use Scalar::Util qw( refaddr );
Subroutine BEGIN: called CC=1 SCAR=0.0
279  
280 450 ▶if ( eval { require Clone; } )
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require Clone } }) { } 450 0 450
281 {
282 450 Clone->import("clone");
283 }
284 else
285 {
286 0 require Storable; # in CORE since 5.7.3
287 0 *clone = \&Storable::dclone;
288 }
289  
290 450 our $imp_data_size = 0;
291  
292 sub ping
293 788 ▶{
Subroutine ping: called CC=2 SCAR=7.6
294 788 ▶ ( $_[0]->FETCH("Active") ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->FETCH('Active') ? : 788 0 788
295 } # ping
296  
297 sub data_sources
298 72 ▶{
Subroutine data_sources: called CC=3 SCAR=11.8
299 72 my ( $dbh, $attr, @other ) = @_;
300 72 my $drh = $dbh->{Driver}; # XXX proxy issues?
301 72 ▶ ref($attr) eq 'HASH' or $attr = {};
Branch: 1 branch
BranchTrueFalseTotal
ref $attr eq "HASH" or $attr = {} 72 0 72
302 72 ▶ $attr->{sql_table_source} //= $dbh->{sql_table_source};
Condition33%1/3
$attr->{"sql_table_source"} //= $dbh->{"sql_table_source"}
l!l&&r!l&&!r
0072
MC/DC0%0/2
$attr->{"sql_table_source"} //= $dbh->{"sql_table_source"}
$attr->{"sql_table_source"} $dbh->{"sql_table_source"}
Truth table33%1/3
A //= B
A= $attr->{"sql_table_source"}B= $dbh->{"sql_table_source"}
ABresult
1X1
011
000
303 72 return $drh->data_sources( $attr, @other );
304 }
305  
306 sub prepare ($$;@)
307 1410 ▶{
Subroutine prepare: called CC=8 SCAR=25.4
308 1410 my ( $dbh, $statement, @attribs ) = @_;
309  
310 # create a 'blank' sth
311 1410 my $sth = DBI::_new_sth( $dbh, { Statement => $statement } );
312  
313 1410 ▶ if ($sth)
Branch: 1 branch
BranchTrueFalseTotal
if ($sth) 1410 0 1410
314 {
315 1410 my $class = $sth->FETCH("ImplementorClass");
316 1410 $class =~ s/::st$/::Statement/;
317 1410 my $stmt;
318  
319 # if using SQL::Statement version > 1
320 # cache the parser object if the DBD supports parser caching
321 # SQL::Nano and older SQL::Statements don't support this
322  
323 1410 ▶ if ( $class->isa("SQL::Statement") )
Branch: 1 branch
BranchTrueFalseTotal
if ($class->isa('SQL::Statement')) { } 0 1410 1410
324 {
325 0 my $parser = $dbh->{sql_parser_object};
326 0 ▶ $parser ||= eval { $dbh->func("sql_parser_object") };
Condition0%0/3
$parser ||= eval { do { $dbh->func("sql_parser_object") } }
l!l&&r!l&&!r
000
MC/DC0%0/2
$parser ||= eval { do { $dbh->func("sql_parser_object") } }
$parser eval { do { $dbh->func("sql_parser_object") } }
Truth table0%0/3
A ||= B
A= $parserB= eval { do { $dbh->func("sql_parser_object") } }
ABresult
1X1
011
000
327 0 ▶ if ($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 0 0
328 {
329 0 $stmt = eval { $class->new($statement) };
330 }
331 else
332 {
333 0 $stmt = eval { $class->new( $statement, $parser ) };
334 }
335 }
336 else
337 {
338 1410 $stmt = eval { $class->new($statement) };
339 }
340 1410 ▶ if ( $@ || $stmt->{errstr} )
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or $stmt->{'errstr'}) { } 64 1346 1410
Condition66%2/3
$@ or $stmt->{"errstr"}
l!l&&r!l&&!r
6401346
MC/DC50%1/2
$@ or $stmt->{"errstr"}
$@ $stmt->{"errstr"}
Truth table66%2/3
A or B
A= $@B= $stmt->{"errstr"}
ABresult
1X1
011
000
341 {
342 64 ▶ $dbh->set_err( $DBI::stderr, $@ || $stmt->{errstr} );
Condition33%1/3
$@ || $stmt->{'errstr'}
l!l&&r!l&&!r
6400
MC/DC0%0/2
$@ || $stmt->{'errstr'}
$@ $stmt->{'errstr'}
Truth table33%1/3
A || B
A= $@B= $stmt->{'errstr'}
ABresult
1X1
011
000
343 64 undef $sth;
344 }
345 else
346 {
347 1346 $sth->STORE( "sql_stmt", $stmt );
348 1346 $sth->STORE( "sql_params", [] );
349 1346 $sth->STORE( "NUM_OF_PARAMS", scalar( $stmt->params() ) );
350 1346 my @colnames = $sth->sql_get_colnames();
351 1346 $sth->STORE( "NUM_OF_FIELDS", scalar @colnames );
352 }
353 }
354 1410 return $sth;
355 } # prepare
356  
357 sub set_versions
358 1250 ▶{
Subroutine set_versions: called CC=4 SCAR=13.9
359 1250 my $dbh = $_[0];
360 1250 $dbh->{sql_engine_version} = $DBI::DBD::SqlEngine::VERSION;
361 1250 for (qw( nano_version statement_version ))
362 {
363 2500 ▶ defined $DBI::SQL::Nano::versions->{$_} or next;
Branch: 1 branch
BranchTrueFalseTotal
defined $DBI::SQL::Nano::versions->{$_} or next 1250 1250 2500
364 1250 $dbh->{"sql_$_"} = $DBI::SQL::Nano::versions->{$_};
365 }
366 $dbh->{sql_handler} =
367 $dbh->{sql_statement_version}
368 1250 ▶ ? "SQL::Statement"
Branch: 1 branch
BranchTrueFalseTotal
$dbh->{'sql_statement_version'} ? : 0 1250 1250
369 : "DBI::SQL::Nano";
370  
371 1250 return $dbh;
372 } # set_versions
373  
374 sub init_valid_attributes
375 1250 ▶{
Subroutine init_valid_attributes: called CC=1 SCAR=0.0
376 1250 my $dbh = $_[0];
377  
378 $dbh->{sql_valid_attrs} = {
379 1250 sql_engine_version => 1, # DBI::DBD::SqlEngine version
380 sql_handler => 1, # Nano or S:S
381 sql_nano_version => 1, # Nano version
382 sql_statement_version => 1, # S:S version
383 sql_flags => 1, # flags for SQL::Parser
384 sql_dialect => 1, # dialect for SQL::Parser
385 sql_quoted_identifier_case => 1, # case for quoted identifiers
386 sql_identifier_case => 1, # case for non-quoted identifiers
387 sql_parser_object => 1, # SQL::Parser instance
388 sql_sponge_driver => 1, # Sponge driver for table_info ()
389 sql_valid_attrs => 1, # SQL valid attributes
390 sql_readonly_attrs => 1, # SQL readonly attributes
391 sql_init_phase => 1, # Only during initialization
392 sql_meta => 1, # meta data for tables
393 sql_meta_map => 1, # mapping table for identifier case
394 sql_data_source => 1, # reasonable datasource class
395 };
396 $dbh->{sql_readonly_attrs} = {
397 1250 sql_engine_version => 1, # DBI::DBD::SqlEngine version
398 sql_handler => 1, # Nano or S:S
399 sql_nano_version => 1, # Nano version
400 sql_statement_version => 1, # S:S version
401 sql_quoted_identifier_case => 1, # case for quoted identifiers
402 sql_parser_object => 1, # SQL::Parser instance
403 sql_sponge_driver => 1, # Sponge driver for table_info ()
404 sql_valid_attrs => 1, # SQL valid attributes
405 sql_readonly_attrs => 1, # SQL readonly attributes
406 };
407  
408 1250 return $dbh;
409 } # init_valid_attributes
410  
411 sub init_default_attributes
412 2500 ▶{
Subroutine init_default_attributes: called CC=16 SCAR=30.0
413 2500 my ( $dbh, $phase ) = @_;
414 2500 my $given_phase = $phase;
415  
416 2500 ▶ unless ( defined($phase) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $phase) 0 2500 2500
417 {
418 # we have an "old" driver here
419 0 $phase = defined $dbh->{sql_init_phase};
420 0 ▶ $phase and $phase = $dbh->{sql_init_phase};
Branch: 1 branch
BranchTrueFalseTotal
$phase and $phase = $dbh->{"sql_init_phase"} 0 0 0
421 }
422  
423 2500 ▶ if ( 0 == $phase )
Branch: 1 branch
BranchTrueFalseTotal
if (0 == $phase) 1250 1250 2500
424 {
425 # must be done first, because setting flags implicitly calls $dbdname::db->STORE
426 1250 $dbh->func("init_valid_attributes");
427  
428 1250 $dbh->func("set_versions");
429  
430 1250 $dbh->{sql_identifier_case} = 2; # SQL_IC_LOWER
431 1250 $dbh->{sql_quoted_identifier_case} = 3; # SQL_IC_SENSITIVE
432  
433 1250 $dbh->{sql_dialect} = "CSV";
434  
435 1250 $dbh->{sql_init_phase} = $given_phase;
436  
437 # complete derived attributes, if required
438 1250 ( my $drv_class = $dbh->{ImplementorClass} ) =~ s/::db$//;
439 1250 my $drv_prefix = DBI->driver_prefix($drv_class);
440 1250 my $valid_attrs = $drv_prefix . "valid_attrs";
441 1250 my $ro_attrs = $drv_prefix . "readonly_attrs";
442  
443 # check whether we're running in a Gofer server or not (see
444 # validate_FETCH_attr for details)
445 $dbh->{sql_engine_in_gofer} =
446 1250 ▶ ( defined $INC{"DBD/Gofer.pm"} && ( caller(5) )[0] eq "DBI::Gofer::Execute" );
Condition100%3/3
defined $INC{'DBD/Gofer.pm'} && (caller 5)[0] eq 'DBI::Gofer::Execute'
!ll&&!rl&&r
64652282
MC/DC100%2/2
defined $INC{'DBD/Gofer.pm'} && (caller 5)[0] eq 'DBI::Gofer::Execute'
defined $INC{'DBD/Gofer.pm'} (caller 5)[0] eq 'DBI::Gofer::Execute'
Truth table100%3/3
A && B
A= defined $INC{'DBD/Gofer.pm'}B= (caller 5)[0] eq 'DBI::Gofer::Execute'
ABresult
0X0
100
111
447 1250 $dbh->{sql_meta} = {};
448 1250 $dbh->{sql_meta_map} = {}; # choose new name because it contains other keys
449  
450 # init_default_attributes calls inherited routine before derived DBD's
451 # init their default attributes, so we don't override something here
452 #
453 # defining an order of attribute initialization from connect time
454 # specified ones with a magic baarier (see next statement)
455 1250 my $drv_pfx_meta = $drv_prefix . "meta";
456 $dbh->{sql_init_order} = {
457 0 => [qw( Profile RaiseError PrintError AutoCommit )],
458 1250 ▶ 90 => [ "sql_meta", $dbh->{$drv_pfx_meta} ? $dbh->{$drv_pfx_meta} : () ],
Branch: 1 branch
BranchTrueFalseTotal
$dbh->{$drv_pfx_meta} ? : 1056 194 1250
459 };
460 # ensuring Profile, RaiseError, PrintError, AutoCommit are initialized
461 # first when initializing attributes from connect time specified
462 # attributes
463 # further, initializations to predefined tables are happens after any
464 # unspecified attribute initialization (that default to order 50)
465  
466 1250 my @comp_attrs = qw(valid_attrs version readonly_attrs);
467  
468 1250 ▶ if ( exists $dbh->{$drv_pfx_meta} and !$dbh->{sql_engine_in_gofer} )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $dbh->{$drv_pfx_meta} and not $dbh->{"sql_engine_in_gofer"}) 1056 194 1250
Condition66%2/3
exists $dbh->{$drv_pfx_meta} and not $dbh->{"sql_engine_in_gofer"}
!ll&&!rl&&r
19401056
MC/DC50%1/2
exists $dbh->{$drv_pfx_meta} and not $dbh->{"sql_engine_in_gofer"}
exists $dbh->{$drv_pfx_meta} not $dbh->{"sql_engine_in_gofer"}
Truth table66%2/3
A and not(B)
A= exists $dbh->{$drv_pfx_meta}B= not $dbh->{"sql_engine_in_gofer"}
ABresult
0X0
100
111
469 {
470 1056 my $attr = $dbh->{$drv_pfx_meta};
471 defined $attr
472 and defined $dbh->{$valid_attrs}
473 and !defined $dbh->{$valid_attrs}{$attr}
474 1056 ▶ and $dbh->{$valid_attrs}{$attr} = 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $attr and defined $dbh->{$valid_attrs} and not defined $dbh->{$valid_attrs}{$attr} and $dbh->{$valid_attrs}{$attr} = 1 0 1056 1056
Condition33%2/6
defined $attr and defined $dbh->{$valid_attrs} and not defined $dbh->{$valid_attrs}{$attr}
!ll&&!rl&&r
010560
defined $attr and defined $dbh->{$valid_attrs}
!ll&&!rl&&r
001056
MC/DC0%0/3
defined $attr and defined $dbh->{$valid_attrs} and not defined $dbh->{$valid_attrs}{$attr}
defined $attr defined $dbh->{$valid_attrs} not defined $dbh->{$valid_attrs}{$attr}
Truth table25%1/4
A and B and not(C)
A= defined $attrB= defined $dbh->{$valid_attrs}C= not defined $dbh->{$valid_attrs}{$attr}
ABCresult
0XX0
10X0
1100
1111
475  
476 1056 my %h;
477 1056 tie %h, "DBI::DBD::SqlEngine::TieTables", $dbh;
478 1056 $dbh->{$attr} = \%h;
479  
480 1056 push @comp_attrs, "meta";
481 }
482  
483 1250 foreach my $comp_attr (@comp_attrs)
484 {
485 4806 my $attr = $drv_prefix . $comp_attr;
486 defined $dbh->{$valid_attrs}
487 and !defined $dbh->{$valid_attrs}{$attr}
488 4806 ▶ and $dbh->{$valid_attrs}{$attr} = 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $dbh->{$valid_attrs} and not defined $dbh->{$valid_attrs}{$attr} and $dbh->{$valid_attrs}{$attr} = 1 0 4806 4806
Condition33%1/3
defined $dbh->{$valid_attrs} and not defined $dbh->{$valid_attrs}{$attr}
!ll&&!rl&&r
048060
MC/DC0%0/2
defined $dbh->{$valid_attrs} and not defined $dbh->{$valid_attrs}{$attr}
defined $dbh->{$valid_attrs} not defined $dbh->{$valid_attrs}{$attr}
Truth table33%1/3
A and not(B)
A= defined $dbh->{$valid_attrs}B= not defined $dbh->{$valid_attrs}{$attr}
ABresult
0X0
100
111
489 defined $dbh->{$ro_attrs}
490 and !defined $dbh->{$ro_attrs}{$attr}
491 4806 ▶ and $dbh->{$ro_attrs}{$attr} = 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $dbh->{$ro_attrs} and not defined $dbh->{$ro_attrs}{$attr} and $dbh->{$ro_attrs}{$attr} = 1 0 4806 4806
Condition33%1/3
defined $dbh->{$ro_attrs} and not defined $dbh->{$ro_attrs}{$attr}
!ll&&!rl&&r
048060
MC/DC0%0/2
defined $dbh->{$ro_attrs} and not defined $dbh->{$ro_attrs}{$attr}
defined $dbh->{$ro_attrs} not defined $dbh->{$ro_attrs}{$attr}
Truth table33%1/3
A and not(B)
A= defined $dbh->{$ro_attrs}B= not defined $dbh->{$ro_attrs}{$attr}
ABresult
0X0
100
111
492 }
493 }
494  
495 2500 return $dbh;
496 } # init_default_attributes
497  
498 sub init_done
499 1250 ▶{
Subroutine init_done: called CC=2 SCAR=7.1
500 1250 ▶ defined $_[0]->{sql_init_phase} and delete $_[0]->{sql_init_phase};
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0]{"sql_init_phase"} and delete $_[0]{"sql_init_phase"} 1250 0 1250
501 1250 delete $_[0]->{sql_valid_attrs}->{sql_init_phase};
502 1250 return;
503 }
504  
505 sub sql_parser_object
506 0 ▶{
Subroutine sql_parser_object: not called CC=3 SCAR=24.8
507 0 my $dbh = $_[0];
508 0 ▶ my $dialect = $dbh->{sql_dialect} || "CSV";
Condition0%0/2
$dbh->{'sql_dialect'} || 'CSV'
l!l
00
MC/DC0%0/1
$dbh->{'sql_dialect'} || 'CSV'
$dbh->{'sql_dialect'}
Truth table0%0/2
A
A= $dbh->{'sql_dialect'}
Aresult
11
00
509 0 my $parser = {
510 RaiseError => $dbh->FETCH("RaiseError"),
511 PrintError => $dbh->FETCH("PrintError"),
512 };
513 0 ▶ my $sql_flags = $dbh->FETCH("sql_flags") || {};
Condition0%0/2
$dbh->FETCH('sql_flags') || {}
l!l
00
MC/DC0%0/1
$dbh->FETCH('sql_flags') || {}
$dbh->FETCH('sql_flags')
Truth table0%0/2
A
A= $dbh->FETCH('sql_flags')
Aresult
11
00
514 0 %$parser = ( %$parser, %$sql_flags );
515 0 $parser = SQL::Parser->new( $dialect, $parser );
516 0 $dbh->{sql_parser_object} = $parser;
517 0 return $parser;
518 } # sql_parser_object
519  
520 sub sql_sponge_driver
521 28 ▶{
Subroutine sql_sponge_driver: called CC=3 SCAR=12.3
522 28 my $dbh = $_[0];
523 28 my $dbh2 = $dbh->{sql_sponge_driver};
524 28 ▶ unless ($dbh2)
Branch: 1 branch
BranchTrueFalseTotal
unless ($dbh2) 28 0 28
525 {
526 28 $dbh2 = $dbh->{sql_sponge_driver} = DBI->connect("DBI:Sponge:");
527 28 ▶ unless ($dbh2)
Branch: 1 branch
BranchTrueFalseTotal
unless ($dbh2) 0 28 28
528 {
529 0 $dbh->set_err( $DBI::stderr, $DBI::errstr );
530 0 return;
531 }
532 }
533 }
534  
535 sub disconnect ($)
536 226 ▶{
Subroutine disconnect: called CC=1 SCAR=0.0
537 226 %{ $_[0]->{sql_meta} } = ();
538 226 %{ $_[0]->{sql_meta_map} } = ();
539 226 $_[0]->STORE( Active => 0 );
540 226 return 1;
541 } # disconnect
542  
543 sub validate_FETCH_attr
544 0 ▶{
Subroutine validate_FETCH_attr: not called CC=4 SCAR=30.0
545 0 my ( $dbh, $attrib ) = @_;
546  
547 # If running in a Gofer server, access to our tied compatibility hash
548 # would force Gofer to serialize the tieing object including it's
549 # private $dbh reference used to do the driver function calls.
550 # This will result in nasty exceptions. So return a copy of the
551 # sql_meta structure instead, which is the source of for the compatibility
552 # tie-hash. It's not as good as liked, but the best we can do in this
553 # situation.
554 0 ▶ if ( $dbh->{sql_engine_in_gofer} )
Branch: 1 branch
BranchTrueFalseTotal
if ($dbh->{"sql_engine_in_gofer"}) 0 0 0
555 {
556 0 ( my $drv_class = $dbh->{ImplementorClass} ) =~ s/::db$//;
557 0 my $drv_prefix = DBI->driver_prefix($drv_class);
558 0 ▶ exists $dbh->{ $drv_prefix . "meta" } && $attrib eq $dbh->{ $drv_prefix . "meta" }
Branch: 1 branch
BranchTrueFalseTotal
exists $$dbh{$drv_prefix . 'meta'} and $attrib eq $$dbh{$drv_prefix . 'meta'} and $attrib = "sql_meta" 0 0 0
Condition0%0/3
exists $$dbh{$drv_prefix . 'meta'} and $attrib eq $$dbh{$drv_prefix . 'meta'}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $$dbh{$drv_prefix . 'meta'} and $attrib eq $$dbh{$drv_prefix . 'meta'}
exists $$dbh{$drv_prefix . 'meta'} $attrib eq $$dbh{$drv_prefix . 'meta'}
Truth table0%0/3
A and B
A= exists $$dbh{$drv_prefix . 'meta'}B= $attrib eq $$dbh{$drv_prefix . 'meta'}
ABresult
0X0
100
111
559 and $attrib = "sql_meta";
560 }
561  
562 0 return $attrib;
563 }
564  
565 sub FETCH ($$)
566 7642 ▶{
Subroutine FETCH: called CC=12 SCAR=46.5
567 7642 my ( $dbh, $attrib ) = @_;
568 7642 ▶ $attrib eq "AutoCommit"
Branch: 1 branch
BranchTrueFalseTotal
$attrib eq "AutoCommit" and return 1 0 7642 7642
569 and return 1;
570  
571 # Driver private attributes are lower cased
572 7642 ▶ if ( $attrib eq ( lc $attrib ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($attrib eq lc $attrib) 0 7642 7642
573 {
574 # first let the implementation deliver an alias for the attribute to fetch
575 # after it validates the legitimation of the fetch request
576 0 ▶ $attrib = $dbh->func( $attrib, "validate_FETCH_attr" ) or return;
Branch: 1 branch
BranchTrueFalseTotal
$attrib = $dbh->func($attrib, "validate_FETCH_attr") or return 0 0 0
577  
578 0 my $attr_prefix;
579 0 ▶ $attrib =~ m/^([a-z]+_)/ and $attr_prefix = $1;
Branch: 1 branch
BranchTrueFalseTotal
$attrib =~ /^([a-z]+_)/ and $attr_prefix = $1 0 0 0
580 0 ▶ unless ($attr_prefix)
Branch: 1 branch
BranchTrueFalseTotal
unless ($attr_prefix) 0 0 0
581 {
582 0 ( my $drv_class = $dbh->{ImplementorClass} ) =~ s/::db$//;
583 0 $attr_prefix = DBI->driver_prefix($drv_class);
584 0 $attrib = $attr_prefix . $attrib;
585 }
586 0 my $valid_attrs = $attr_prefix . "valid_attrs";
587 0 my $ro_attrs = $attr_prefix . "readonly_attrs";
588  
589 exists $dbh->{$valid_attrs}
590 0 ▶ and ( $dbh->{$valid_attrs}{$attrib}
Branch: 1 branch
BranchTrueFalseTotal
exists $dbh->{$valid_attrs} and $dbh->{$valid_attrs}{$attrib} || (return $dbh->set_err($DBI::stderr, "Invalid attribute '${attrib}'")) 0 0 0
Condition0%0/5
exists $dbh->{$valid_attrs} && ($dbh->{$valid_attrs}{$attrib} || (return $dbh->set_err($DBI::stderr, "Invalid attribute '${attrib}'")))
!ll&&!rl&&r
000
$dbh->{$valid_attrs}{$attrib} or return $dbh->set_err($DBI::stderr, "Invalid attribute '${attrib}'")
l!l
00
MC/DC0%0/2
exists $dbh->{$valid_attrs} && ($dbh->{$valid_attrs}{$attrib} || (return $dbh->set_err($DBI::stderr, "Invalid attribute '${attrib}'")))
exists $dbh->{$valid_attrs} $dbh->{$valid_attrs}{$attrib}
Truth table0%0/3
A && B
A= exists $dbh->{$valid_attrs}B= $dbh->{$valid_attrs}{$attrib}
ABresult
0X0
100
111
591 or return $dbh->set_err( $DBI::stderr, "Invalid attribute '$attrib'" ) );
592 exists $dbh->{$ro_attrs}
593 and $dbh->{$ro_attrs}{$attrib}
594 and defined $dbh->{$attrib}
595 and refaddr( $dbh->{$attrib} )
596 0 ▶ and return clone( $dbh->{$attrib} );
Branch: 1 branch
BranchTrueFalseTotal
exists $dbh->{$ro_attrs} and $dbh->{$ro_attrs}{$attrib} and defined $dbh->{$attrib} and builtin::refaddr($dbh->{$attrib}) and return &clone($dbh->{$attrib}) 0 0 0
Condition0%0/9
exists $dbh->{$ro_attrs} and $dbh->{$ro_attrs}{$attrib} and defined $dbh->{$attrib} and builtin::refaddr($dbh->{$attrib})
!ll&&!rl&&r
000
exists $dbh->{$ro_attrs} and $dbh->{$ro_attrs}{$attrib} and defined $dbh->{$attrib}
!ll&&!rl&&r
000
exists $dbh->{$ro_attrs} and $dbh->{$ro_attrs}{$attrib}
!ll&&!rl&&r
000
MC/DC0%0/4
exists $dbh->{$ro_attrs} and $dbh->{$ro_attrs}{$attrib} and defined $dbh->{$attrib} and builtin::refaddr($dbh->{$attrib})
exists $dbh->{$ro_attrs} $dbh->{$ro_attrs}{$attrib} defined $dbh->{$attrib} builtin::refaddr($dbh->{$attrib})
Truth table0%0/5
A and B and C and D
A= exists $dbh->{$ro_attrs}B= $dbh->{$ro_attrs}{$attrib}C= defined $dbh->{$attrib}D= builtin::refaddr($dbh->{$attrib})
ABCDresult
0XXX0
10XX0
110X0
11100
11111
597  
598 0 return $dbh->{$attrib};
599 }
600 # else pass up to DBI to handle
601 7642 return $dbh->SUPER::FETCH($attrib);
602 } # FETCH
603  
604 sub validate_STORE_attr
605 8824 ▶{
Subroutine validate_STORE_attr: called CC=7 SCAR=20.6
606 8824 my ( $dbh, $attrib, $value ) = @_;
607  
608 8824 ▶ if ( $attrib eq "sql_identifier_case" || $attrib eq "sql_quoted_identifier_case"
Branch: 1 branch
BranchTrueFalseTotal
if ($attrib eq "sql_identifier_case" || $attrib eq "sql_quoted_identifier_case" and $value < 1 || $value > 4) 0 8824 8824
Condition55%5/9
$attrib eq "sql_identifier_case" || $attrib eq "sql_quoted_identifier_case" and $value < 1 || $value > 4
!ll&&!rl&&r
8756680
$attrib eq "sql_identifier_case" or $attrib eq "sql_quoted_identifier_case"
l!l&&r!l&&!r
6808756
$value < 1 or $value > 4
l!l&&r!l&&!r
0068
MC/DC0%0/4
$attrib eq "sql_identifier_case" || $attrib eq "sql_quoted_identifier_case" and $value < 1 || $value > 4
$attrib eq "sql_identifier_case" $attrib eq "sql_quoted_identifier_case" $value < 1 $value > 4
Truth table28%2/7
A or B and C or D
A= $attrib eq "sql_identifier_case"B= $attrib eq "sql_quoted_identifier_case"C= $value < 1D= $value > 4
ABCDresult
00XX0
1X000
01000
1X1X1
1X011
011X1
01011
609 and $value < 1 || $value > 4 )
610 {
611 0 croak "attribute '$attrib' must have a value from 1 .. 4 (SQL_IC_UPPER .. SQL_IC_MIXED)";
612 # XXX correctly a remap of all entries in sql_meta/sql_meta_map is required here
613 }
614  
615 8824 ( my $drv_class = $dbh->{ImplementorClass} ) =~ s/::db$//;
616 8824 my $drv_prefix = DBI->driver_prefix($drv_class);
617  
618 exists $dbh->{ $drv_prefix . "meta" }
619 8824 ▶ and $attrib eq $dbh->{ $drv_prefix . "meta" }
Branch: 1 branch
BranchTrueFalseTotal
exists $$dbh{$drv_prefix . 'meta'} and $attrib eq $$dbh{$drv_prefix . 'meta'} and $attrib = "sql_meta" 4 8820 8824
Condition100%3/3
exists $$dbh{$drv_prefix . 'meta'} and $attrib eq $$dbh{$drv_prefix . 'meta'}
!ll&&!rl&&r
112077004
MC/DC100%2/2
exists $$dbh{$drv_prefix . 'meta'} and $attrib eq $$dbh{$drv_prefix . 'meta'}
exists $$dbh{$drv_prefix . 'meta'} $attrib eq $$dbh{$drv_prefix . 'meta'}
Truth table100%3/3
A and B
A= exists $$dbh{$drv_prefix . 'meta'}B= $attrib eq $$dbh{$drv_prefix . 'meta'}
ABresult
0X0
100
111
620 and $attrib = "sql_meta";
621  
622 8824 return ( $attrib, $value );
623 }
624  
625 # the ::db::STORE method is what gets called when you set
626 # a lower-cased database handle attribute such as $dbh->{somekey}=$someval;
627 #
628 # STORE should check to make sure that "somekey" is a valid attribute name
629 # but only if it is really one of our attributes (starts with dbm_ or foo_)
630 # You can also check for valid values for the attributes if needed
631 # and/or perform other operations
632 #
633 sub STORE ($$$)
634 21132 ▶{
Subroutine STORE: called CC=14 SCAR=28.2
635 21132 my ( $dbh, $attrib, $value ) = @_;
636  
637 21132 ▶ if ( $attrib eq "AutoCommit" )
Branch: 1 branch
BranchTrueFalseTotal
if ($attrib eq "AutoCommit") 1634 19498 21132
638 {
639 1634 ▶ $value and return 1; # is already set
Branch: 1 branch
BranchTrueFalseTotal
$value and return 1 1634 0 1634
640 0 croak "Can't disable AutoCommit";
641 }
642  
643 19498 ▶ if ( $attrib eq lc $attrib )
Branch: 1 branch
BranchTrueFalseTotal
if ($attrib eq lc $attrib) 8824 10674 19498
644 {
645 # Driver private attributes are lower cased
646  
647 8824 ( $attrib, $value ) = $dbh->func( $attrib, $value, "validate_STORE_attr" );
648 8824 ▶ $attrib or return;
Branch: 1 branch
BranchTrueFalseTotal
$attrib or return 8824 0 8824
649  
650 8824 my $attr_prefix;
651 8824 ▶ $attrib =~ m/^([a-z]+_)/ and $attr_prefix = $1;
Branch: 1 branch
BranchTrueFalseTotal
$attrib =~ /^([a-z]+_)/ and $attr_prefix = $1 8824 0 8824
652 8824 ▶ unless ($attr_prefix)
Branch: 1 branch
BranchTrueFalseTotal
unless ($attr_prefix) 0 8824 8824
653 {
654 0 ( my $drv_class = $dbh->{ImplementorClass} ) =~ s/::db$//;
655 0 $attr_prefix = DBI->driver_prefix($drv_class);
656 0 $attrib = $attr_prefix . $attrib;
657 }
658 8824 my $valid_attrs = $attr_prefix . "valid_attrs";
659 8824 my $ro_attrs = $attr_prefix . "readonly_attrs";
660  
661 exists $dbh->{$valid_attrs}
662 8824 ▶ and ( $dbh->{$valid_attrs}{$attrib}
Branch: 1 branch
BranchTrueFalseTotal
exists $dbh->{$valid_attrs} and $dbh->{$valid_attrs}{$attrib} || (return $dbh->set_err($DBI::stderr, "Invalid attribute '${attrib}'")) 5034 3790 8824
Condition80%4/5
exists $dbh->{$valid_attrs} && ($dbh->{$valid_attrs}{$attrib} || (return $dbh->set_err($DBI::stderr, "Invalid attribute '${attrib}'")))
!ll
379050340
$dbh->{$valid_attrs}{$attrib} or return $dbh->set_err($DBI::stderr, "Invalid attribute '${attrib}'")
l!l
50304
MC/DC0%0/2
exists $dbh->{$valid_attrs} && ($dbh->{$valid_attrs}{$attrib} || (return $dbh->set_err($DBI::stderr, "Invalid attribute '${attrib}'")))
exists $dbh->{$valid_attrs} $dbh->{$valid_attrs}{$attrib}
Truth table66%2/3
A && B
A= exists $dbh->{$valid_attrs}B= $dbh->{$valid_attrs}{$attrib}
ABresult
0X0
100
111
663 or return $dbh->set_err( $DBI::stderr, "Invalid attribute '$attrib'" ) );
664 exists $dbh->{$ro_attrs}
665 and $dbh->{$ro_attrs}{$attrib}
666 8820 ▶ and defined $dbh->{$attrib}
Branch: 1 branch
BranchTrueFalseTotal
exists $dbh->{$ro_attrs} and $dbh->{$ro_attrs}{$attrib} and defined $dbh->{$attrib} and return $dbh->set_err($DBI::stderr, "attribute '${attrib}' is readonly and must not be modified") 0 8820 8820
Condition50%3/6
exists $dbh->{$ro_attrs} and $dbh->{$ro_attrs}{$attrib} and defined $dbh->{$attrib}
!ll&&!rl&&r
882000
exists $dbh->{$ro_attrs} and $dbh->{$ro_attrs}{$attrib}
!ll&&!rl&&r
379050300
MC/DC0%0/3
exists $dbh->{$ro_attrs} and $dbh->{$ro_attrs}{$attrib} and defined $dbh->{$attrib}
exists $dbh->{$ro_attrs} $dbh->{$ro_attrs}{$attrib} defined $dbh->{$attrib}
Truth table50%2/4
A and B and C
A= exists $dbh->{$ro_attrs}B= $dbh->{$ro_attrs}{$attrib}C= defined $dbh->{$attrib}
ABCresult
0XX0
10X0
1100
1111
667 and return $dbh->set_err( $DBI::stderr,
668 "attribute '$attrib' is readonly and must not be modified" );
669  
670 8820 ▶ if ( $attrib eq "sql_meta" )
Branch: 1 branch
BranchTrueFalseTotal
if ($attrib eq 'sql_meta') { } 36 8784 8820
671 {
672 36 ▶ while ( my ( $k, $v ) = each %$value )
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$value) 36 36 72
673 {
674 36 $dbh->{$attrib}{$k} = $v;
675 }
676 }
677 else
678 {
679 8784 $dbh->{$attrib} = $value;
680 }
681  
682 8820 return 1;
683 }
684  
685 10674 return $dbh->SUPER::STORE( $attrib, $value );
686 } # STORE
687  
688 sub get_driver_versions
689 24 ▶{
Subroutine get_driver_versions: called CC=16 SCAR=28.3
690 24 my ( $dbh, $table ) = @_;
691 24 my %vsn = (
692 OS => "$^O ($Config::Config{osvers})",
693 Perl => "$] ($Config::Config{archname})",
694 DBI => $DBI::VERSION,
695 );
696 24 my %vmp;
697  
698 my $sql_engine_verinfo =
699 join " ",
700 $dbh->{sql_engine_version}, "using", $dbh->{sql_handler},
701 $dbh->{sql_handler} eq "SQL::Statement"
702 ? $dbh->{sql_statement_version}
703 24 ▶ : $dbh->{sql_nano_version};
Branch: 1 branch
BranchTrueFalseTotal
$dbh->{'sql_handler'} eq 'SQL::Statement' ? : 0 24 24
704  
705 24 my $indent = 0;
706 24 my @deriveds = ( $dbh->{ImplementorClass} );
707 24 ▶ while (@deriveds)
Branch: 1 branch
BranchTrueFalseTotal
if (@deriveds) 64 0 64
708 {
709 64 my $derived = shift @deriveds;
710 64 ▶ $derived eq "DBI::DBD::SqlEngine::db" and last;
Branch: 1 branch
BranchTrueFalseTotal
$derived eq "DBI::DBD::SqlEngine::db" and last 24 40 64
711 40 ▶ $derived->isa("DBI::DBD::SqlEngine::db") or next;
Branch: 1 branch
BranchTrueFalseTotal
$derived->isa("DBI::DBD::SqlEngine::db") or next 40 0 40
712 #no strict 'refs';
713 40 eval "push \@deriveds, \@${derived}::ISA";
714 #use strict;
715 40 ( my $drv_class = $derived ) =~ s/::db$//;
716 40 my $drv_prefix = DBI->driver_prefix($drv_class);
717 40 my $ddgv = $dbh->{ImplementorClass}->can("get_${drv_prefix}versions");
718 40 ▶ my $drv_version = $ddgv ? &$ddgv( $dbh, $table ) : $dbh->{ $drv_prefix . "version" };
Branch: 1 branch
BranchTrueFalseTotal
$ddgv ? : 40 0 40
719 $drv_version ||=
720 0 ▶ eval { $derived->VERSION() }; # XXX access $drv_class::VERSION via symbol table
Condition33%1/3
$drv_version ||= eval { do { $derived->VERSION } }
l!l&&r!l&&!r
4000
MC/DC0%0/2
$drv_version ||= eval { do { $derived->VERSION } }
$drv_version eval { do { $derived->VERSION } }
Truth table33%1/3
A ||= B
A= $drv_versionB= eval { do { $derived->VERSION } }
ABresult
1X1
011
000
721 40 $vsn{$drv_class} = $drv_version;
722 40 ▶ $indent and $vmp{$drv_class} = " " x $indent . $drv_class;
Branch: 1 branch
BranchTrueFalseTotal
$indent and $vmp{$drv_class} = " " x $indent . $drv_class 16 24 40
723 40 $indent += 2;
724 }
725  
726 24 $vsn{"DBI::DBD::SqlEngine"} = $sql_engine_verinfo;
727 24 ▶ $indent and $vmp{"DBI::DBD::SqlEngine"} = " " x $indent . "DBI::DBD::SqlEngine";
Branch: 1 branch
BranchTrueFalseTotal
$indent and $vmp{"DBI::DBD::SqlEngine"} = " " x $indent . 'DBI::DBD::SqlEngine' 24 0 24
728  
729 24 ▶ $DBI::PurePerl and $vsn{"DBI::PurePerl"} = $DBI::PurePerl::VERSION;
Branch: 1 branch
BranchTrueFalseTotal
$DBI::PurePerl and $vsn{"DBI::PurePerl"} = $DBI::PurePerl::VERSION 12 12 24
730  
731 24 $indent += 20;
732 148 ▶ my @versions = map { sprintf "%-${indent}s %s", $vmp{$_} || $_, $vsn{$_} }
Condition66%2/3
$vmp{$_} || $_
l!l&&r!l&&!r
401080
MC/DC0%0/2
$vmp{$_} || $_
$vmp{$_} $_
Truth table66%2/3
A || B
A= $vmp{$_}B= $_
ABresult
1X1
011
000
733 sort {
734 24 ▶ $a->isa($b) and return -1;
Branch: 1 branch
BranchTrueFalseTotal
$a->isa($b) and return -1 22 226 248
735 226 ▶ $b->isa($a) and return 1;
Branch: 1 branch
BranchTrueFalseTotal
$b->isa($a) and return 1 29 197 226
736 197 ▶ $a->isa("DBI::DBD::SqlEngine") and return -1;
Branch: 1 branch
BranchTrueFalseTotal
$a->isa("DBI::DBD::SqlEngine") and return -1 55 142 197
737 142 ▶ $b->isa("DBI::DBD::SqlEngine") and return 1;
Branch: 1 branch
BranchTrueFalseTotal
$b->isa("DBI::DBD::SqlEngine") and return 1 54 88 142
738 88 return $a cmp $b;
739 } keys %vsn;
740  
741 24 ▶ return wantarray ? @versions : join "\n", @versions;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 24 24
742 } # get_versions
743  
744 sub get_single_table_meta
745 62 ▶{
Subroutine get_single_table_meta: called CC=3 SCAR=11.2
746 62 my ( $dbh, $table, $attr ) = @_;
747 62 my $meta;
748  
749 62 ▶ $table eq "."
Branch: 1 branch
BranchTrueFalseTotal
$table eq "." and return $dbh->FETCH($attr) 0 62 62
750 and return $dbh->FETCH($attr);
751  
752 62 ( my $class = $dbh->{ImplementorClass} ) =~ s/::db$/::Table/;
753 62 ( undef, $meta ) = $class->get_table_meta( $dbh, $table, 1 );
754 62 ▶ $meta or croak "No such table '$table'";
Branch: 1 branch
BranchTrueFalseTotal
$meta or croak("No such table '${table}'") 62 0 62
755  
756 # prevent creation of undef attributes
757 62 return $class->get_table_meta_attr( $meta, $attr );
758 } # get_single_table_meta
759  
760 sub get_sql_engine_meta
761 38 ▶{
Subroutine get_sql_engine_meta: called CC=12 SCAR=26.7
762 38 my ( $dbh, $table, $attr ) = @_;
763  
764 38 my $gstm = $dbh->{ImplementorClass}->can("get_single_table_meta");
765  
766 $table eq "*"
767 0 ▶ and $table = [ ".", keys %{ $dbh->{sql_meta} } ];
Branch: 1 branch
BranchTrueFalseTotal
$table eq "*" and $table = [".", keys %{$$dbh{"sql_meta"};}] 0 38 38
768 $table eq "+"
769 0 ▶ and $table = [ grep { m/^[_A-Za-z0-9]+$/ } keys %{ $dbh->{sql_meta} } ];
Branch: 1 branch
BranchTrueFalseTotal
$table eq "+" and $table = [grep({/^[_A-Za-z0-9]+$/;} keys %{$$dbh{"sql_meta"};})] 0 38 38
770 ref $table eq "Regexp"
771 0 ▶ and $table = [ grep { $_ =~ $table } keys %{ $dbh->{sql_meta} } ];
Branch: 1 branch
BranchTrueFalseTotal
ref $table eq "Regexp" and $table = [grep({$_ =~ /$table/;} keys %{$$dbh{"sql_meta"};})] 0 38 38
772  
773 38 ▶ ref $table || ref $attr
Branch: 1 branch
BranchTrueFalseTotal
ref $table or ref $attr or return &$gstm($dbh, $table, $attr) 10 28 38
Condition100%3/3
ref $table or ref $attr
l!l&&r!l&&!r
8228
MC/DC100%2/2
ref $table or ref $attr
ref $table ref $attr
Truth table100%3/3
A or B
A= ref $tableB= ref $attr
ABresult
1X1
011
000
774 or return $gstm->( $dbh, $table, $attr );
775  
776 10 ▶ ref $table or $table = [$table];
Branch: 1 branch
BranchTrueFalseTotal
ref $table or $table = [$table] 8 2 10
777 10 ▶ ref $attr or $attr = [$attr];
Branch: 1 branch
BranchTrueFalseTotal
ref $attr or $attr = [$attr] 10 0 10
778 10 ▶ "ARRAY" eq ref $table
Branch: 1 branch
BranchTrueFalseTotal
"ARRAY" eq ref $table or return $dbh->set_err($DBI::stderr, 'Invalid argument for $table - SCALAR, Regexp or ARRAY expected but got ' . ref($table)) 10 0 10
779 or return
780 $dbh->set_err( $DBI::stderr,
781 "Invalid argument for \$table - SCALAR, Regexp or ARRAY expected but got " . ref $table );
782 10 ▶ "ARRAY" eq ref $attr
Branch: 1 branch
BranchTrueFalseTotal
"ARRAY" eq ref $attr or return $dbh->set_err('Invalid argument for $attr - SCALAR or ARRAY expected but got ' . ref($attr)) 10 0 10
783 or return $dbh->set_err(
784 "Invalid argument for \$attr - SCALAR or ARRAY expected but got " . ref $attr );
785  
786 10 my %results;
787 10 foreach my $tname ( @{$table} )
788 {
789 18 my %tattrs;
790 18 foreach my $aname ( @{$attr} )
791 {
792 34 $tattrs{$aname} = $gstm->( $dbh, $tname, $aname );
793 }
794 18 $results{$tname} = \%tattrs;
795 }
796  
797 10 return \%results;
798 } # get_sql_engine_meta
799  
800 sub new_sql_engine_meta
801 6 ▶{
Subroutine new_sql_engine_meta: called CC=7 SCAR=19.7
802 6 my ( $dbh, $table, $values ) = @_;
803 6 my $respect_case = 0;
804  
805 6 ▶ "HASH" eq ref $values
Branch: 1 branch
BranchTrueFalseTotal
"HASH" eq ref $values or croak('Invalid argument for $values - SCALAR or HASH expected but got ' . ref($values)) 6 0 6
806 or croak "Invalid argument for \$values - SCALAR or HASH expected but got " . ref $values;
807  
808 6 ▶ $table =~ s/^\"// and $respect_case = 1; # handle quoted identifiers
Branch: 1 branch
BranchTrueFalseTotal
$table =~ s/^\"// and $respect_case = 1 0 6 6
809 6 $table =~ s/\"$//;
810  
811 6 ▶ unless ($respect_case)
Branch: 1 branch
BranchTrueFalseTotal
unless ($respect_case) 6 0 6
812 {
813 6 ▶ defined $dbh->{sql_meta_map}{$table} and $table = $dbh->{sql_meta_map}{$table};
Branch: 1 branch
BranchTrueFalseTotal
defined $dbh->{"sql_meta_map"}{$table} and $table = $dbh->{"sql_meta_map"}{$table} 0 6 6
814 }
815  
816 6 $dbh->{sql_meta}{$table} = { %{$values} };
817 6 my $class;
818 6 ▶ defined $values->{sql_table_class} and $class = $values->{sql_table_class};
Branch: 1 branch
BranchTrueFalseTotal
defined $values->{"sql_table_class"} and $class = $values->{"sql_table_class"} 2 4 6
819 6 ▶ defined $class or ( $class = $dbh->{ImplementorClass} ) =~ s/::db$/::Table/;
Branch: 1 branch
BranchTrueFalseTotal
defined $class or ($class = $dbh->{"ImplementorClass"}) =~ s/::db$/::Table/ 2 4 6
820 # XXX we should never hit DBD::File::Table::get_table_meta here ...
821 6 my ( undef, $meta ) = $class->get_table_meta( $dbh, $table, $respect_case );
822 6 1;
823 } # new_sql_engine_meta
824  
825 sub set_single_table_meta
826 8 ▶{
Subroutine set_single_table_meta: called CC=3 SCAR=11.1
827 8 my ( $dbh, $table, $attr, $value ) = @_;
828 8 my $meta;
829  
830 8 ▶ $table eq "."
Branch: 1 branch
BranchTrueFalseTotal
$table eq "." and return $dbh->STORE($attr, $value) 0 8 8
831 and return $dbh->STORE( $attr, $value );
832  
833 8 ( my $class = $dbh->{ImplementorClass} ) =~ s/::db$/::Table/;
834 8 ( undef, $meta ) = $class->get_table_meta( $dbh, $table, 1 ); # 1 means: respect case
835 8 ▶ $meta or croak "No such table '$table'";
Branch: 1 branch
BranchTrueFalseTotal
$meta or croak("No such table '${table}'") 8 0 8
836 8 $class->set_table_meta_attr( $meta, $attr, $value );
837  
838 8 return $dbh;
839 } # set_single_table_meta
840  
841 sub set_sql_engine_meta
842 8 ▶{
Subroutine set_sql_engine_meta: called CC=12 SCAR=28.1
843 8 my ( $dbh, $table, $attr, $value ) = @_;
844  
845 8 my $sstm = $dbh->{ImplementorClass}->can("set_single_table_meta");
846  
847 $table eq "*"
848 0 ▶ and $table = [ ".", keys %{ $dbh->{sql_meta} } ];
Branch: 1 branch
BranchTrueFalseTotal
$table eq "*" and $table = [".", keys %{$$dbh{"sql_meta"};}] 0 8 8
849 $table eq "+"
850 0 ▶ and $table = [ grep { m/^[_A-Za-z0-9]+$/ } keys %{ $dbh->{sql_meta} } ];
Branch: 1 branch
BranchTrueFalseTotal
$table eq "+" and $table = [grep({/^[_A-Za-z0-9]+$/;} keys %{$$dbh{"sql_meta"};})] 0 8 8
851 ref($table) eq "Regexp"
852 0 ▶ and $table = [ grep { $_ =~ $table } keys %{ $dbh->{sql_meta} } ];
Branch: 1 branch
BranchTrueFalseTotal
ref $table eq "Regexp" and $table = [grep({$_ =~ /$table/;} keys %{$$dbh{"sql_meta"};})] 0 8 8
853  
854 8 ▶ ref $table || ref $attr
Branch: 1 branch
BranchTrueFalseTotal
ref $table or ref $attr or return &$sstm($dbh, $table, $attr, $value) 4 4 8
Condition66%2/3
ref $table or ref $attr
l!l&&r!l&&!r
044
MC/DC50%1/2
ref $table or ref $attr
ref $table ref $attr
Truth table66%2/3
A or B
A= ref $tableB= ref $attr
ABresult
1X1
011
000
855 or return $sstm->( $dbh, $table, $attr, $value );
856  
857 4 ▶ ref $table or $table = [$table];
Branch: 1 branch
BranchTrueFalseTotal
ref $table or $table = [$table] 0 4 4
858 4 ▶ ref $attr or $attr = { $attr => $value };
Branch: 1 branch
BranchTrueFalseTotal
ref $attr or $attr = {$attr, $value} 4 0 4
859 4 ▶ "ARRAY" eq ref $table
Branch: 1 branch
BranchTrueFalseTotal
"ARRAY" eq ref $table or croak('Invalid argument for $table - SCALAR, Regexp or ARRAY expected but got ' . ref($table)) 4 0 4
860 or croak "Invalid argument for \$table - SCALAR, Regexp or ARRAY expected but got "
861 . ref $table;
862 4 ▶ "HASH" eq ref $attr
Branch: 1 branch
BranchTrueFalseTotal
"HASH" eq ref $attr or croak('Invalid argument for $attr - SCALAR or HASH expected but got ' . ref($attr)) 4 0 4
863 or croak "Invalid argument for \$attr - SCALAR or HASH expected but got " . ref $attr;
864  
865 4 foreach my $tname ( @{$table} )
866 {
867 4 ▶ while ( my ( $aname, $aval ) = each %$attr )
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$attr) 4 4 8
868 {
869 4 $sstm->( $dbh, $tname, $aname, $aval );
870 }
871 }
872  
873 4 return $dbh;
874 } # set_file_meta
875  
876 sub clear_sql_engine_meta
877 4 ▶{
Subroutine clear_sql_engine_meta: called CC=2 SCAR=7.0
878 4 my ( $dbh, $table ) = @_;
879  
880 4 ( my $class = $dbh->{ImplementorClass} ) =~ s/::db$/::Table/;
881 4 my ( undef, $meta ) = $class->get_table_meta( $dbh, $table, 1 );
882 4 ▶ $meta and %{$meta} = ();
Branch: 1 branch
BranchTrueFalseTotal
$meta and %{$meta;} = () 4 0 4
883  
884 4 return;
885 } # clear_file_meta
886  
887 sub DESTROY ($)
888 194 ▶{
Subroutine DESTROY: called CC=2 SCAR=7.1
889 194 my $dbh = shift;
890 194 ▶ $dbh->SUPER::FETCH("Active") and $dbh->disconnect;
Branch: 1 branch
BranchTrueFalseTotal
$dbh->SUPER::FETCH("Active") and $dbh->disconnect 194 0 194
891 194 undef $dbh->{sql_parser_object};
892 } # DESTROY
893  
894 sub type_info_all ($)
895 0 ▶{
Subroutine type_info_all: not called CC=1 SCAR=6.9
896 [
897 {
898 0 TYPE_NAME => 0,
899 DATA_TYPE => 1,
900 PRECISION => 2,
901 LITERAL_PREFIX => 3,
902 LITERAL_SUFFIX => 4,
903 CREATE_PARAMS => 5,
904 NULLABLE => 6,
905 CASE_SENSITIVE => 7,
906 SEARCHABLE => 8,
907 UNSIGNED_ATTRIBUTE => 9,
908 MONEY => 10,
909 AUTO_INCREMENT => 11,
910 LOCAL_TYPE_NAME => 12,
911 MINIMUM_SCALE => 13,
912 MAXIMUM_SCALE => 14,
913 },
914 [
915 "VARCHAR", DBI::SQL_VARCHAR(), undef, "'", "'", undef, 0, 1, 1, 0, 0, 0, undef, 1, 999999,
916 ],
917 [ "CHAR", DBI::SQL_CHAR(), undef, "'", "'", undef, 0, 1, 1, 0, 0, 0, undef, 1, 999999, ],
918 [ "INTEGER", DBI::SQL_INTEGER(), undef, "", "", undef, 0, 0, 1, 0, 0, 0, undef, 0, 0, ],
919 [ "REAL", DBI::SQL_REAL(), undef, "", "", undef, 0, 0, 1, 0, 0, 0, undef, 0, 0, ],
920 [
921 "BLOB", DBI::SQL_LONGVARBINARY(), undef, "'", "'", undef, 0, 1, 1, 0, 0, 0, undef, 1,
922 999999,
923 ],
924 [
925 "BLOB", DBI::SQL_LONGVARBINARY(), undef, "'", "'", undef, 0, 1, 1, 0, 0, 0, undef, 1,
926 999999,
927 ],
928 [
929 "TEXT", DBI::SQL_LONGVARCHAR(), undef, "'", "'", undef, 0, 1, 1, 0, 0, 0, undef, 1,
930 999999,
931 ],
932 ];
933 } # type_info_all
934  
935 sub get_avail_tables
936 36 ▶{
Subroutine get_avail_tables: called CC=9 SCAR=28.4
937 36 my $dbh = $_[0];
938 36 my @tables = ();
939  
940 36 ▶ if ( $dbh->{sql_handler} eq "SQL::Statement" and $dbh->{sql_ram_tables} )
Branch: 1 branch
BranchTrueFalseTotal
if ($dbh->{"sql_handler"} eq "SQL::Statement" and $dbh->{"sql_ram_tables"}) 0 36 36
Condition33%1/3
$dbh->{"sql_handler"} eq "SQL::Statement" and $dbh->{"sql_ram_tables"}
!ll&&!rl&&r
3600
MC/DC0%0/2
$dbh->{"sql_handler"} eq "SQL::Statement" and $dbh->{"sql_ram_tables"}
$dbh->{"sql_handler"} eq "SQL::Statement" $dbh->{"sql_ram_tables"}
Truth table33%1/3
A and B
A= $dbh->{"sql_handler"} eq "SQL::Statement"B= $dbh->{"sql_ram_tables"}
ABresult
0X0
100
111
941 {
942 # XXX map +[ undef, undef, $_, "TABLE", "TEMP" ], keys %{...}
943 0 foreach my $table ( keys %{ $dbh->{sql_ram_tables} } )
944 {
945 0 push @tables, [ undef, undef, $table, "TABLE", "TEMP" ];
946 }
947 }
948  
949 36 my $tbl_src;
950 defined $dbh->{sql_table_source}
951 and $dbh->{sql_table_source}->isa('DBI::DBD::SqlEngine::TableSource')
952 36 ▶ and $tbl_src = $dbh->{sql_table_source};
Branch: 1 branch
BranchTrueFalseTotal
defined $dbh->{"sql_table_source"} and $dbh->{"sql_table_source"}->isa("DBI::DBD::SqlEngine::TableSource") and $tbl_src = $dbh->{"sql_table_source"} 0 36 36
Condition33%1/3
defined $dbh->{"sql_table_source"} and $dbh->{"sql_table_source"}->isa("DBI::DBD::SqlEngine::TableSource")
!ll&&!rl&&r
3600
MC/DC0%0/2
defined $dbh->{"sql_table_source"} and $dbh->{"sql_table_source"}->isa("DBI::DBD::SqlEngine::TableSource")
defined $dbh->{"sql_table_source"} $dbh->{"sql_table_source"}->isa("DBI::DBD::SqlEngine::TableSource")
Truth table33%1/3
A and B
A= defined $dbh->{"sql_table_source"}B= $dbh->{"sql_table_source"}->isa("DBI::DBD::SqlEngine::TableSource")
ABresult
0X0
100
111
953  
954 !defined($tbl_src)
955 and $dbh->{Driver}->{ImplementorClass}->can('default_table_source')
956 36 ▶ and $tbl_src = $dbh->{Driver}->{ImplementorClass}->default_table_source();
Branch: 1 branch
BranchTrueFalseTotal
not defined $tbl_src and $dbh->{"Driver"}{"ImplementorClass"}->can("default_table_source") and $tbl_src = $dbh->{"Driver"}{"ImplementorClass"}->default_table_source 36 0 36
Condition33%1/3
not defined $tbl_src and $dbh->{"Driver"}{"ImplementorClass"}->can("default_table_source")
!ll&&!rl&&r
0036
MC/DC0%0/2
not defined $tbl_src and $dbh->{"Driver"}{"ImplementorClass"}->can("default_table_source")
not defined $tbl_src $dbh->{"Driver"}{"ImplementorClass"}->can("default_table_source")
Truth table33%1/3
not(A) and B
A= not defined $tbl_srcB= $dbh->{"Driver"}{"ImplementorClass"}->can("default_table_source")
ABresult
0X0
100
111
957 36 ▶ defined($tbl_src) and push( @tables, $tbl_src->avail_tables($dbh) );
Branch: 1 branch
BranchTrueFalseTotal
defined $tbl_src and push @tables, $tbl_src->avail_tables($dbh) 36 0 36
958  
959 36 return @tables;
960 } # get_avail_tables
961  
962 {
963 450 my $names = [qw( TABLE_QUALIFIER TABLE_OWNER TABLE_NAME TABLE_TYPE REMARKS )];
964  
965 sub table_info ($)
966 28 ▶ {
Subroutine table_info: called CC=3 SCAR=11.2
967 28 my $dbh = shift;
968  
969 28 my @tables = $dbh->func("get_avail_tables");
970  
971 # Temporary kludge: DBD::Sponge dies if @tables is empty. :-(
972 # this no longer seems to be true @tables or return;
973  
974 28 my $dbh2 = $dbh->func("sql_sponge_driver");
975 28 my $sth = $dbh2->prepare(
976 "TABLE_INFO",
977 {
978 rows => \@tables,
979 NAME => $names,
980 }
981 );
982 28 ▶ $sth or return $dbh->set_err( $DBI::stderr, $dbh2->errstr );
Branch: 1 branch
BranchTrueFalseTotal
$sth or return $dbh->set_err($DBI::stderr, $dbh2->errstr) 28 0 28
983 28 ▶ $sth->execute or return;
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute or return 28 0 28
984 28 return $sth;
985 } # table_info
986 }
987  
988 450 sub list_tables ($)
989 8 ▶{
Subroutine list_tables: called CC=3 SCAR=11.0
990 8 my $dbh = shift;
991 8 my @table_list;
992  
993 8 ▶ my @tables = $dbh->func("get_avail_tables") or return;
Branch: 1 branch
BranchTrueFalseTotal
my(@tables) = $dbh->func("get_avail_tables") or return 8 0 8
994 8 foreach my $ref (@tables)
995 {
996 # rt69260 and rt67223 - the same issue in 2 different queues
997 16 push @table_list, $ref->[2];
998 }
999  
1000 8 return @table_list;
1001 } # list_tables
1002  
1003 sub quote ($$;$)
1004 0 ▶{
Subroutine quote: not called CC=11 SCAR=48.8
1005 0 my ( $self, $str, $type ) = @_;
1006 0 ▶ defined $str or return "NULL";
Branch: 1 branch
BranchTrueFalseTotal
defined $str or return "NULL" 0 0 0
1007 0 ▶ defined $type && ( $type == DBI::SQL_NUMERIC()
Branch: 1 branch
BranchTrueFalseTotal
defined $type and $type == &DBI::SQL_NUMERIC() || $type == &DBI::SQL_DECIMAL() || $type == &DBI::SQL_INTEGER() || $type == &DBI::SQL_SMALLINT() || $type == &DBI::SQL_FLOAT() || $type == &DBI::SQL_REAL() || $type == &DBI::SQL_DOUBLE() || $type == &DBI::SQL_TINYINT() and return $str 0 0 0
Condition0%0/24
defined $type and $type == &DBI::SQL_NUMERIC() || $type == &DBI::SQL_DECIMAL() || $type == &DBI::SQL_INTEGER() || $type == &DBI::SQL_SMALLINT() || $type == &DBI::SQL_FLOAT() || $type == &DBI::SQL_REAL() || $type == &DBI::SQL_DOUBLE() || $type == &DBI::SQL_TINYINT()
!ll&&!rl&&r
000
$type == &DBI::SQL_NUMERIC() or $type == &DBI::SQL_DECIMAL() or $type == &DBI::SQL_INTEGER() or $type == &DBI::SQL_SMALLINT() or $type == &DBI::SQL_FLOAT() or $type == &DBI::SQL_REAL() or $type == &DBI::SQL_DOUBLE() or $type == &DBI::SQL_TINYINT()
l!l&&r!l&&!r
000
$type == &DBI::SQL_NUMERIC() or $type == &DBI::SQL_DECIMAL() or $type == &DBI::SQL_INTEGER() or $type == &DBI::SQL_SMALLINT() or $type == &DBI::SQL_FLOAT() or $type == &DBI::SQL_REAL() or $type == &DBI::SQL_DOUBLE()
l!l&&r!l&&!r
000
$type == &DBI::SQL_NUMERIC() or $type == &DBI::SQL_DECIMAL() or $type == &DBI::SQL_INTEGER() or $type == &DBI::SQL_SMALLINT() or $type == &DBI::SQL_FLOAT() or $type == &DBI::SQL_REAL()
l!l&&r!l&&!r
000
$type == &DBI::SQL_NUMERIC() or $type == &DBI::SQL_DECIMAL() or $type == &DBI::SQL_INTEGER() or $type == &DBI::SQL_SMALLINT() or $type == &DBI::SQL_FLOAT()
l!l&&r!l&&!r
000
$type == &DBI::SQL_NUMERIC() or $type == &DBI::SQL_DECIMAL() or $type == &DBI::SQL_INTEGER() or $type == &DBI::SQL_SMALLINT()
l!l&&r!l&&!r
000
$type == &DBI::SQL_NUMERIC() or $type == &DBI::SQL_DECIMAL() or $type == &DBI::SQL_INTEGER()
l!l&&r!l&&!r
000
$type == &DBI::SQL_NUMERIC() or $type == &DBI::SQL_DECIMAL()
l!l&&r!l&&!r
000
MC/DC0%0/9
defined $type and $type == &DBI::SQL_NUMERIC() || $type == &DBI::SQL_DECIMAL() || $type == &DBI::SQL_INTEGER() || $type == &DBI::SQL_SMALLINT() || $type == &DBI::SQL_FLOAT() || $type == &DBI::SQL_REAL() || $type == &DBI::SQL_DOUBLE() || $type == &DBI::SQL_TINYINT()
defined $type $type == &DBI::SQL_NUMERIC() $type == &DBI::SQL_DECIMAL() $type == &DBI::SQL_INTEGER() $type == &DBI::SQL_SMALLINT() $type == &DBI::SQL_FLOAT() $type == &DBI::SQL_REAL() $type == &DBI::SQL_DOUBLE() $type == &DBI::SQL_TINYINT()
Truth table0%0/10
A and B or C or D or E or F or G or H or I
A= defined $typeB= $type == &DBI::SQL_NUMERIC()C= $type == &DBI::SQL_DECIMAL()D= $type == &DBI::SQL_INTEGER()E= $type == &DBI::SQL_SMALLINT()F= $type == &DBI::SQL_FLOAT()G= $type == &DBI::SQL_REAL()H= $type == &DBI::SQL_DOUBLE()I= $type == &DBI::SQL_TINYINT()
ABCDEFGHIresult
0XXXXXXXX0
1000000000
11XXXXXXX1
101XXXXXX1
1001XXXXX1
10001XXXX1
100001XXX1
1000001XX1
10000001X1
1000000011
1008 || $type == DBI::SQL_DECIMAL()
1009 || $type == DBI::SQL_INTEGER()
1010 || $type == DBI::SQL_SMALLINT()
1011 || $type == DBI::SQL_FLOAT()
1012 || $type == DBI::SQL_REAL()
1013 || $type == DBI::SQL_DOUBLE()
1014 || $type == DBI::SQL_TINYINT() )
1015 and return $str;
1016  
1017 0 $str =~ s/\\/\\\\/sg;
1018 0 $str =~ s/\0/\\0/sg;
1019 0 $str =~ s/\'/\\\'/sg;
1020 0 $str =~ s/\n/\\n/sg;
1021 0 $str =~ s/\r/\\r/sg;
1022 0 return "'$str'";
1023 } # quote
1024  
1025 sub commit ($)
1026 0 ▶{
Subroutine commit: not called CC=2 SCAR=17.9
1027 0 my $dbh = shift;
1028 0 ▶ $dbh->FETCH("Warn")
Branch: 1 branch
BranchTrueFalseTotal
$dbh->FETCH("Warn") and carp("Commit ineffective while AutoCommit is on", -1) 0 0 0
1029 and carp "Commit ineffective while AutoCommit is on", -1;
1030 0 return 1;
1031 } # commit
1032  
1033 sub rollback ($)
1034 0 ▶{
Subroutine rollback: not called CC=2 SCAR=17.9
1035 0 my $dbh = shift;
1036 0 ▶ $dbh->FETCH("Warn")
Branch: 1 branch
BranchTrueFalseTotal
$dbh->FETCH("Warn") and carp("Rollback ineffective while AutoCommit is on", -1) 0 0 0
1037 and carp "Rollback ineffective while AutoCommit is on", -1;
1038 0 return 0;
1039 } # rollback
1040  
1041 # ====== Tie-Meta ==============================================================
1042  
1043 package DBI::DBD::SqlEngine::TieMeta;
1044  
1045 450 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
1046 450 require Tie::Hash;
1047 450 our @ISA = qw(Tie::Hash);
1048  
1049 sub TIEHASH
1050 28 ▶{
Subroutine TIEHASH: called CC=1 SCAR=0.0
1051 28 my ( $class, $tblClass, $tblMeta ) = @_;
1052  
1053 28 my $self = bless(
1054 {
1055 tblClass => $tblClass,
1056 tblMeta => $tblMeta,
1057 },
1058 $class
1059 );
1060 28 return $self;
1061 } # new
1062  
1063 sub STORE
1064 8 ▶{
Subroutine STORE: called CC=1 SCAR=0.0
1065 8 my ( $self, $meta_attr, $meta_val ) = @_;
1066  
1067 8 $self->{tblClass}->set_table_meta_attr( $self->{tblMeta}, $meta_attr, $meta_val );
1068  
1069 8 return;
1070 } # STORE
1071  
1072 sub FETCH
1073 20 ▶{
Subroutine FETCH: called CC=1 SCAR=0.0
1074 20 my ( $self, $meta_attr ) = @_;
1075  
1076 20 return $self->{tblClass}->get_table_meta_attr( $self->{tblMeta}, $meta_attr );
1077 } # FETCH
1078  
1079 sub FIRSTKEY
1080 0 ▶{
Subroutine FIRSTKEY: not called CC=1 SCAR=6.9
1081 0 my $a = scalar keys %{ $_[0]->{tblMeta} };
1082 0 each %{ $_[0]->{tblMeta} };
1083 } # FIRSTKEY
1084  
1085 sub NEXTKEY
1086 0 ▶{
Subroutine NEXTKEY: not called CC=1 SCAR=6.9
1087 0 each %{ $_[0]->{tblMeta} };
1088 } # NEXTKEY
1089  
1090 sub EXISTS
1091 0 ▶{
Subroutine EXISTS: not called CC=1 SCAR=6.9
1092 0 exists $_[0]->{tblMeta}{ $_[1] };
1093 } # EXISTS
1094  
1095 sub DELETE
1096 0 ▶{
Subroutine DELETE: not called CC=1 SCAR=6.9
1097 0 croak "Can't delete single attributes from table meta structure";
1098 } # DELETE
1099  
1100 sub CLEAR
1101 0 ▶{
Subroutine CLEAR: not called CC=1 SCAR=6.9
1102 0 %{ $_[0]->{tblMeta} } = ();
1103 } # CLEAR
1104  
1105 sub SCALAR
1106 0 ▶{
Subroutine SCALAR: not called CC=1 SCAR=6.9
1107 0 scalar %{ $_[0]->{tblMeta} };
1108 } # SCALAR
1109  
1110 # ====== Tie-Tables ============================================================
1111  
1112 package DBI::DBD::SqlEngine::TieTables;
1113  
1114 450 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
1115 450 require Tie::Hash;
1116 450 our @ISA = qw(Tie::Hash);
1117  
1118 sub TIEHASH
1119 1056 ▶{
Subroutine TIEHASH: called CC=1 SCAR=0.0
1120 1056 my ( $class, $dbh ) = @_;
1121  
1122 1056 ( my $tbl_class = $dbh->{ImplementorClass} ) =~ s/::db$/::Table/;
1123 1056 my $self = bless(
1124 {
1125 dbh => $dbh,
1126 tblClass => $tbl_class,
1127 },
1128 $class
1129 );
1130 1056 return $self;
1131 } # new
1132  
1133 sub STORE
1134 0 ▶{
Subroutine STORE: not called CC=4 SCAR=30.0
1135 0 my ( $self, $table, $tbl_meta ) = @_;
1136  
1137 0 ▶ "HASH" eq ref $tbl_meta
Branch: 1 branch
BranchTrueFalseTotal
"HASH" eq ref $tbl_meta or croak("Invalid data for storing as table meta data (must be hash)") 0 0 0
1138 or croak "Invalid data for storing as table meta data (must be hash)";
1139  
1140 0 ( undef, my $meta ) = $self->{tblClass}->get_table_meta( $self->{dbh}, $table, 1 );
1141 0 ▶ $meta or croak "Invalid table name '$table'";
Branch: 1 branch
BranchTrueFalseTotal
$meta or croak("Invalid table name '${table}'") 0 0 0
1142  
1143 0 ▶ while ( my ( $meta_attr, $meta_val ) = each %$tbl_meta )
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$tbl_meta) 0 0 0
1144 {
1145 0 $self->{tblClass}->set_table_meta_attr( $meta, $meta_attr, $meta_val );
1146 }
1147  
1148 0 return;
1149 } # STORE
1150  
1151 sub FETCH
1152 28 ▶{
Subroutine FETCH: called CC=2 SCAR=7.0
1153 28 my ( $self, $table ) = @_;
1154  
1155 28 ( undef, my $meta ) = $self->{tblClass}->get_table_meta( $self->{dbh}, $table, 1 );
1156 28 ▶ $meta or croak "Invalid table name '$table'";
Branch: 1 branch
BranchTrueFalseTotal
$meta or croak("Invalid table name '${table}'") 28 0 28
1157  
1158 28 my %h;
1159 28 tie %h, "DBI::DBD::SqlEngine::TieMeta", $self->{tblClass}, $meta;
1160  
1161 28 return \%h;
1162 } # FETCH
1163  
1164 sub FIRSTKEY
1165 0 ▶{
Subroutine FIRSTKEY: not called CC=1 SCAR=6.9
1166 0 my $a = scalar keys %{ $_[0]->{dbh}->{sql_meta} };
1167 0 each %{ $_[0]->{dbh}->{sql_meta} };
1168 } # FIRSTKEY
1169  
1170 sub NEXTKEY
1171 0 ▶{
Subroutine NEXTKEY: not called CC=1 SCAR=6.9
1172 0 each %{ $_[0]->{dbh}->{sql_meta} };
1173 } # NEXTKEY
1174  
1175 sub EXISTS
1176 0 ▶{
Subroutine EXISTS: not called CC=2 SCAR=17.9
1177 exists $_[0]->{dbh}->{sql_meta}->{ $_[1] }
1178 0 ▶ or exists $_[0]->{dbh}->{sql_meta_map}->{ $_[1] };
Branch: 1 branch
BranchTrueFalseTotal
exists $_[0]{"dbh"}{"sql_meta"}{$_[1]} or exists $_[0]{"dbh"}{"sql_meta_map"}{$_[1]} 0 0 0
1179 } # EXISTS
1180  
1181 sub DELETE
1182 0 ▶{
Subroutine DELETE: not called CC=2 SCAR=17.9
1183 0 my ( $self, $table ) = @_;
1184  
1185 0 ( undef, my $meta ) = $self->{tblClass}->get_table_meta( $self->{dbh}, $table, 1 );
1186 0 ▶ $meta or croak "Invalid table name '$table'";
Branch: 1 branch
BranchTrueFalseTotal
$meta or croak("Invalid table name '${table}'") 0 0 0
1187  
1188 0 delete $_[0]->{dbh}->{sql_meta}->{ $meta->{table_name} };
1189 } # DELETE
1190  
1191 sub CLEAR
1192 0 ▶{
Subroutine CLEAR: not called CC=1 SCAR=6.9
1193 0 %{ $_[0]->{dbh}->{sql_meta} } = ();
1194 0 %{ $_[0]->{dbh}->{sql_meta_map} } = ();
1195 } # CLEAR
1196  
1197 sub SCALAR
1198 0 ▶{
Subroutine SCALAR: not called CC=1 SCAR=6.9
1199 0 scalar %{ $_[0]->{dbh}->{sql_meta} };
1200 } # SCALAR
1201  
1202 # ====== STATEMENT =============================================================
1203  
1204 package DBI::DBD::SqlEngine::st;
1205  
1206 450 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
1207 450 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
1208  
1209 450 our $imp_data_size = 0;
1210  
1211 sub bind_param ($$$;$)
1212 300 ▶{
Subroutine bind_param: called CC=13 SCAR=47.7
1213 300 my ( $sth, $pNum, $val, $attr ) = @_;
1214 300 ▶ if ( $attr && defined $val )
Branch: 1 branch
BranchTrueFalseTotal
if ($attr and defined $val) 0 300 300
Condition33%1/3
$attr and defined $val
!ll&&!rl&&r
30000
MC/DC0%0/2
$attr and defined $val
$attr defined $val
Truth table33%1/3
A and B
A= $attrB= defined $val
ABresult
0X0
100
111
1215 {
1216 0 ▶ my $type = ref $attr eq "HASH" ? $attr->{TYPE} : $attr;
Branch: 1 branch
BranchTrueFalseTotal
ref $attr eq 'HASH' ? : 0 0 0
1217 0 ▶ if ( $type == DBI::SQL_BIGINT()
Branch: 2 branches
BranchTrueFalseTotal
if ($type == &DBI::SQL_BIGINT() or $type == &DBI::SQL_INTEGER() or $type == &DBI::SQL_SMALLINT() or $type == &DBI::SQL_TINYINT()) { } 0 0 0
elsif ($type == &DBI::SQL_DECIMAL() or $type == &DBI::SQL_DOUBLE() or $type == &DBI::SQL_FLOAT() or $type == &DBI::SQL_NUMERIC() or $type == &DBI::SQL_REAL()) { } 0 0 0
Condition0%0/9
$type == &DBI::SQL_BIGINT() or $type == &DBI::SQL_INTEGER() or $type == &DBI::SQL_SMALLINT() or $type == &DBI::SQL_TINYINT()
l!l&&r!l&&!r
000
$type == &DBI::SQL_BIGINT() or $type == &DBI::SQL_INTEGER() or $type == &DBI::SQL_SMALLINT()
l!l&&r!l&&!r
000
$type == &DBI::SQL_BIGINT() or $type == &DBI::SQL_INTEGER()
l!l&&r!l&&!r
000
MC/DC0%0/4
$type == &DBI::SQL_BIGINT() or $type == &DBI::SQL_INTEGER() or $type == &DBI::SQL_SMALLINT() or $type == &DBI::SQL_TINYINT()
$type == &DBI::SQL_BIGINT() $type == &DBI::SQL_INTEGER() $type == &DBI::SQL_SMALLINT() $type == &DBI::SQL_TINYINT()
Truth table0%0/5
A or B or C or D
A= $type == &DBI::SQL_BIGINT()B= $type == &DBI::SQL_INTEGER()C= $type == &DBI::SQL_SMALLINT()D= $type == &DBI::SQL_TINYINT()
ABCDresult
1XXX1
01XX1
001X1
00011
00000
1218 || $type == DBI::SQL_INTEGER()
1219 || $type == DBI::SQL_SMALLINT()
1220 || $type == DBI::SQL_TINYINT() )
1221 {
1222 0 $val += 0;
1223 }
1224 ▶ elsif ( $type == DBI::SQL_DECIMAL()
Condition0%0/12
$type == &DBI::SQL_DECIMAL() or $type == &DBI::SQL_DOUBLE() or $type == &DBI::SQL_FLOAT() or $type == &DBI::SQL_NUMERIC() or $type == &DBI::SQL_REAL()
l!l&&r!l&&!r
000
$type == &DBI::SQL_DECIMAL() or $type == &DBI::SQL_DOUBLE() or $type == &DBI::SQL_FLOAT() or $type == &DBI::SQL_NUMERIC()
l!l&&r!l&&!r
000
$type == &DBI::SQL_DECIMAL() or $type == &DBI::SQL_DOUBLE() or $type == &DBI::SQL_FLOAT()
l!l&&r!l&&!r
000
$type == &DBI::SQL_DECIMAL() or $type == &DBI::SQL_DOUBLE()
l!l&&r!l&&!r
000
MC/DC0%0/5
$type == &DBI::SQL_DECIMAL() or $type == &DBI::SQL_DOUBLE() or $type == &DBI::SQL_FLOAT() or $type == &DBI::SQL_NUMERIC() or $type == &DBI::SQL_REAL()
$type == &DBI::SQL_DECIMAL() $type == &DBI::SQL_DOUBLE() $type == &DBI::SQL_FLOAT() $type == &DBI::SQL_NUMERIC() $type == &DBI::SQL_REAL()
Truth table0%0/6
A or B or C or D or E
A= $type == &DBI::SQL_DECIMAL()B= $type == &DBI::SQL_DOUBLE()C= $type == &DBI::SQL_FLOAT()D= $type == &DBI::SQL_NUMERIC()E= $type == &DBI::SQL_REAL()
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
1225 || $type == DBI::SQL_DOUBLE()
1226 || $type == DBI::SQL_FLOAT()
1227 || $type == DBI::SQL_NUMERIC()
1228 || $type == DBI::SQL_REAL() )
1229 {
1230 0 $val += 0.;
1231 }
1232 else
1233 {
1234 0 $val = "$val";
1235 }
1236 }
1237 300 $sth->{sql_params}[ $pNum - 1 ] = $val;
1238 300 return 1;
1239 } # bind_param
1240  
1241 sub execute
1242 1050 ▶{
Subroutine execute: called CC=10 SCAR=23.9
1243 1050 my $sth = shift;
1244 1050 ▶ my $params = @_ ? ( $sth->{sql_params} = [@_] ) : $sth->{sql_params};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 8 1042 1050
1245  
1246 1050 $sth->finish;
1247 1050 my $stmt = $sth->{sql_stmt};
1248  
1249 # must not proved when already executed - SQL::Statement modifies
1250 # received params
1251 1050 ▶ unless ( $sth->{sql_params_checked}++ )
Branch: 1 branch
BranchTrueFalseTotal
unless ($sth->{"sql_params_checked"}++) 1050 0 1050
1252 {
1253 # SQL::Statement and DBI::SQL::Nano will return the list of required params
1254 # when called in list context. Do not look into the several items, they're
1255 # implementation specific and may change without warning
1256 1050 ▶ unless ( ( my $req_prm = $stmt->params() ) == ( my $nparm = @$params ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ((my $req_prm = $stmt->params) == (my $nparm = @$params)) 0 1050 1050
1257 {
1258 0 my $msg = "You passed $nparm parameters where $req_prm required";
1259 0 return $sth->set_err( $DBI::stderr, $msg );
1260 }
1261 }
1262  
1263 1050 my @err;
1264 my $result;
1265 1050 eval {
1266 1050 ▶ local $SIG{__WARN__} = sub { push @err, @_ };
Subroutine __ANON__: called CC=1 SCAR=0.0
1267 1050 $result = $stmt->execute( $sth, $params );
1268 };
1269 1050 ▶ unless ( defined $result )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $result) 72 978 1050
1270 {
1271 72 ▶ $sth->set_err( $DBI::stderr, $@ || $stmt->{errstr} || $err[0] );
Condition33%2/6
$@ || $stmt->{'errstr'} || $err[0]
l!l&&r!l&&!r
7200
$@ or $stmt->{"errstr"}
l!l&&r!l&&!r
7200
MC/DC0%0/3
$@ || $stmt->{'errstr'} || $err[0]
$@ $stmt->{"errstr"} $err[0]
Truth table25%1/4
A or B || C
A= $@B= $stmt->{"errstr"}C= $err[0]
ABCresult
1XX1
01X1
0011
0000
1272 72 return;
1273 }
1274  
1275 978 warn $_ for @err;
1276  
1277 978 ▶ if ( $stmt->{NUM_OF_FIELDS} )
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->{"NUM_OF_FIELDS"}) 224 754 978
1278 { # is a SELECT statement
1279 224 $sth->STORE( Active => 1 );
1280 $sth->FETCH("NUM_OF_FIELDS")
1281 224 ▶ or $sth->STORE( "NUM_OF_FIELDS", $stmt->{NUM_OF_FIELDS} );
Branch: 1 branch
BranchTrueFalseTotal
$sth->FETCH("NUM_OF_FIELDS") or $sth->STORE("NUM_OF_FIELDS", $stmt->{"NUM_OF_FIELDS"}) 154 70 224
1282 }
1283 978 return $result;
1284 } # execute
1285  
1286 sub finish
1287 1914 ▶{
Subroutine finish: called CC=1 SCAR=0.0
1288 1914 my $sth = $_[0];
1289 1914 $sth->SUPER::STORE( Active => 0 );
1290 1914 delete $sth->{sql_stmt}{data};
1291 1914 return 1;
1292 } # finish
1293  
1294 sub fetch ($)
1295 746 ▶{
Subroutine fetch: called CC=7 SCAR=20.2
1296 746 my $sth = $_[0];
1297 746 my $data = $sth->{sql_stmt}{data};
1298 746 ▶ if ( !$data || ref $data ne "ARRAY" )
Branch: 1 branch
BranchTrueFalseTotal
if (not $data or ref $data ne "ARRAY") 116 630 746
Condition66%2/3
not $data or ref $data ne "ARRAY"
l!l&&r!l&&!r
1160630
MC/DC50%1/2
not $data or ref $data ne "ARRAY"
not $data ref $data ne "ARRAY"
Truth table66%2/3
not(A) or B
A= not $dataB= ref $data ne "ARRAY"
ABresult
1X1
011
000
1299 {
1300 116 $sth->set_err(
1301 $DBI::stderr,
1302 "Attempt to fetch row without a preceding execute () call or from a non-SELECT statement"
1303 );
1304 116 return;
1305 }
1306 630 my $dav = shift @$data;
1307 630 ▶ unless ($dav)
Branch: 1 branch
BranchTrueFalseTotal
unless ($dav) 206 424 630
1308 {
1309 206 $sth->finish;
1310 206 return;
1311 }
1312 424 ▶ if ( $sth->FETCH("ChopBlanks") ) # XXX: (TODO) Only chop on CHAR fields,
Branch: 1 branch
BranchTrueFalseTotal
if ($sth->FETCH("ChopBlanks")) 0 424 424
1313 { # not on VARCHAR or NUMERIC (see DBI docs)
1314 0 ▶ $_ && $_ =~ s/ +$// for @$dav;
Branch: 1 branch
BranchTrueFalseTotal
$_ and $_ =~ s/ +$// 0 0 0
1315 }
1316 424 return $sth->_set_fbav($dav);
1317 } # fetch
1318  
1319 450 ▶no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
1320 450 *fetchrow_arrayref = \&fetch;
1321  
1322 450 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
1323  
1324 sub sql_get_colnames
1325 3914 ▶{
Subroutine sql_get_colnames: called CC=9 SCAR=28.5
1326 3914 my $sth = $_[0];
1327 # Being a bit dirty here, as neither SQL::Statement::Structure nor
1328 # DBI::SQL::Nano::Statement_ does not offer an interface to the
1329 # required data
1330 3914 my @colnames;
1331 3914 ▶ if ( $sth->{sql_stmt}->{NAME} and "ARRAY" eq ref( $sth->{sql_stmt}->{NAME} ) )
Branch: 2 branches
BranchTrueFalseTotal
if ($sth->{'sql_stmt'}{'NAME'} and 'ARRAY' eq ref $sth->{'sql_stmt'}{'NAME'}) { } 1464 2450 3914
elsif ($sth->{'sql_stmt'}->isa('SQL::Statement')) { } 0 2450 2450
Condition66%2/3
$sth->{"sql_stmt"}{"NAME"} and "ARRAY" eq ref $sth->{"sql_stmt"}{"NAME"}
!ll&&!rl&&r
245001464
MC/DC50%1/2
$sth->{"sql_stmt"}{"NAME"} and "ARRAY" eq ref $sth->{"sql_stmt"}{"NAME"}
$sth->{"sql_stmt"}{"NAME"} "ARRAY" eq ref $sth->{"sql_stmt"}{"NAME"}
Truth table66%2/3
A and B
A= $sth->{"sql_stmt"}{"NAME"}B= "ARRAY" eq ref $sth->{"sql_stmt"}{"NAME"}
ABresult
0X0
100
111
1332 {
1333 1464 @colnames = @{ $sth->{sql_stmt}->{NAME} };
1334 }
1335 elsif ( $sth->{sql_stmt}->isa('SQL::Statement') )
1336 {
1337 0 ▶ my $stmt = $sth->{sql_stmt} || {};
Condition0%0/2
$sth->{'sql_stmt'} || {}
l!l
00
MC/DC0%0/1
$sth->{'sql_stmt'} || {}
$sth->{'sql_stmt'}
Truth table0%0/2
A
A= $sth->{'sql_stmt'}
Aresult
11
00
1338 0 ▶ my @coldefs = @{ $stmt->{column_defs} || [] };
Condition0%0/2
$stmt->{'column_defs'} || []
l!l
00
MC/DC0%0/1
$stmt->{'column_defs'} || []
$stmt->{'column_defs'}
Truth table0%0/2
A
A= $stmt->{'column_defs'}
Aresult
11
00
1339 0 ▶ @colnames = map { $_->{name} || $_->{value} } @coldefs;
Condition0%0/3
$_->{'name'} || $_->{'value'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$_->{'name'} || $_->{'value'}
$_->{'name'} $_->{'value'}
Truth table0%0/3
A || B
A= $_->{'name'}B= $_->{'value'}
ABresult
1X1
011
000
1340 }
1341 3914 ▶ @colnames = $sth->{sql_stmt}->column_names() unless (@colnames);
Branch: 1 branch
BranchTrueFalseTotal
unless @colnames 2450 1464 3914
1342  
1343 3914 ▶ @colnames = () if ( grep { m/\*/ } @colnames );
Branch: 1 branch
BranchTrueFalseTotal
if grep {/\*/;} @colnames 0 3914 3914
1344  
1345 3914 return @colnames;
1346 }
1347  
1348 sub FETCH ($$)
1349 3840 ▶{
Subroutine FETCH: called CC=7 SCAR=19.5
1350 3840 my ( $sth, $attrib ) = @_;
1351  
1352 3840 ▶ $attrib eq "NAME" and return [ $sth->sql_get_colnames() ];
Branch: 1 branch
BranchTrueFalseTotal
$attrib eq "NAME" and return [$sth->sql_get_colnames] 640 3200 3840
1353  
1354 3200 ▶ $attrib eq "TYPE" and return [ ( DBI::SQL_VARCHAR() ) x scalar $sth->sql_get_colnames() ];
Branch: 1 branch
BranchTrueFalseTotal
$attrib eq "TYPE" and return [(&DBI::SQL_VARCHAR()) x scalar($sth->sql_get_colnames)] 644 2556 3200
1355 2556 ▶ $attrib eq "TYPE_NAME" and return [ ("VARCHAR") x scalar $sth->sql_get_colnames() ];
Branch: 1 branch
BranchTrueFalseTotal
$attrib eq "TYPE_NAME" and return [("VARCHAR") x scalar($sth->sql_get_colnames)] 4 2552 2556
1356 2552 ▶ $attrib eq "PRECISION" and return [ (0) x scalar $sth->sql_get_colnames() ];
Branch: 1 branch
BranchTrueFalseTotal
$attrib eq "PRECISION" and return [(0) x scalar($sth->sql_get_colnames)] 640 1912 2552
1357 1912 ▶ $attrib eq "NULLABLE" and return [ (1) x scalar $sth->sql_get_colnames() ];
Branch: 1 branch
BranchTrueFalseTotal
$attrib eq "NULLABLE" and return [(1) x scalar($sth->sql_get_colnames)] 72 1840 1912
1358  
1359 1840 ▶ if ( $attrib eq lc $attrib )
Branch: 1 branch
BranchTrueFalseTotal
if ($attrib eq lc $attrib) 640 1200 1840
1360 {
1361 # Private driver attributes are lower cased
1362 640 return $sth->{$attrib};
1363 }
1364  
1365 # else pass up to DBI to handle
1366 1200 return $sth->SUPER::FETCH($attrib);
1367 } # FETCH
1368  
1369 sub STORE ($$$)
1370 5762 ▶{
Subroutine STORE: called CC=2 SCAR=6.9
1371 5762 my ( $sth, $attrib, $value ) = @_;
1372 5762 ▶ if ( $attrib eq lc $attrib ) # Private driver attributes are lower cased
Branch: 1 branch
BranchTrueFalseTotal
if ($attrib eq lc $attrib) 2692 3070 5762
1373 {
1374 2692 $sth->{$attrib} = $value;
1375 2692 return 1;
1376 }
1377 3070 return $sth->SUPER::STORE( $attrib, $value );
1378 } # STORE
1379  
1380 sub DESTROY ($)
1381 1410 ▶{
Subroutine DESTROY: called CC=2 SCAR=6.9
1382 1410 my $sth = shift;
1383 1410 ▶ $sth->SUPER::FETCH("Active") and $sth->finish;
Branch: 1 branch
BranchTrueFalseTotal
$sth->SUPER::FETCH("Active") and $sth->finish 14 1396 1410
1384 1410 undef $sth->{sql_stmt};
1385 1410 undef $sth->{sql_params};
1386 } # DESTROY
1387  
1388 sub rows ($)
1389 464 ▶{
Subroutine rows: called CC=1 SCAR=0.0
1390 464 return $_[0]->{sql_stmt}{NUM_OF_ROWS};
1391 } # rows
1392  
1393 # ====== TableSource ===========================================================
1394  
1395 package DBI::DBD::SqlEngine::TableSource;
1396  
1397 450 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
1398 450 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
1399  
1400 450 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
1401  
1402 sub data_sources ($;$)
1403 0 ▶{
Subroutine data_sources: not called CC=2 SCAR=17.9
1404 0 my ( $class, $drh, $attrs ) = @_;
1405 0 ▶ croak( ( ref( $_[0] ) ? ref( $_[0] ) : $_[0] ) . " must implement data_sources" );
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
1406 }
1407  
1408 sub avail_tables
1409 0 ▶{
Subroutine avail_tables: not called CC=2 SCAR=17.9
1410 0 my ( $self, $dbh ) = @_;
1411 0 ▶ croak( ( ref( $_[0] ) ? ref( $_[0] ) : $_[0] ) . " must implement avail_tables" );
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
1412 }
1413  
1414 # ====== DataSource ============================================================
1415  
1416 package DBI::DBD::SqlEngine::DataSource;
1417  
1418 450 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
1419 450 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
1420  
1421 450 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
1422  
1423 sub complete_table_name ($$;$)
1424 0 ▶{
Subroutine complete_table_name: not called CC=2 SCAR=17.9
1425 0 my ( $self, $meta, $table, $respect_case ) = @_;
1426 0 ▶ croak( ( ref( $_[0] ) ? ref( $_[0] ) : $_[0] ) . " must implement complete_table_name" );
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
1427 }
1428  
1429 sub open_data ($)
1430 0 ▶{
Subroutine open_data: not called CC=2 SCAR=17.9
1431 0 my ( $self, $meta, $attrs, $flags ) = @_;
1432 0 ▶ croak( ( ref( $_[0] ) ? ref( $_[0] ) : $_[0] ) . " must implement open_data" );
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
1433 }
1434  
1435 # ====== SQL::STATEMENT ========================================================
1436  
1437 package DBI::DBD::SqlEngine::Statement;
1438  
1439 450 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
1440 450 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
1441  
1442 450 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
1443  
1444 450 our @ISA = qw(DBI::SQL::Nano::Statement);
1445  
1446 sub open_table ($$$$$)
1447 1050 ▶{
Subroutine open_table: called CC=9 SCAR=22.1
1448 1050 my ( $self, $data, $table, $createMode, $lockMode ) = @_;
1449  
1450 1050 my $class = ref $self;
1451 1050 $class =~ s/::Statement/::Table/;
1452  
1453 1050 my $flags = {
1454 createMode => $createMode,
1455 lockMode => $lockMode,
1456 };
1457 1050 ▶ $self->{command} eq "DROP" and $flags->{dropMode} = 1;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"command"} eq "DROP" and $flags->{"dropMode"} = 1 264 786 1050
1458  
1459 1050 ▶ my ( $tblnm, $table_meta ) = $class->get_table_meta( $data->{Database}, $table, 1 )
Branch: 1 branch
BranchTrueFalseTotal
() = $class->get_table_meta($data->{"Database"}, $table, 1) or croak("Cannot find appropriate meta for table '${table}'") 1014 0 1014
1460 or croak "Cannot find appropriate meta for table '$table'";
1461  
1462 1014 ▶ defined $table_meta->{sql_table_class} and $class = $table_meta->{sql_table_class};
Branch: 1 branch
BranchTrueFalseTotal
defined $table_meta->{"sql_table_class"} and $class = $table_meta->{"sql_table_class"} 2 1012 1014
1463  
1464 # because column name mapping is initialized in constructor ...
1465 # and therefore specific opening operations might be done before
1466 # reaching DBI::DBD::SqlEngine::Table->new(), we need to intercept
1467 # ReadOnly here
1468 1014 ▶ my $write_op = $createMode || $lockMode || $flags->{dropMode};
Condition83%5/6
$createMode || $lockMode || $flags->{'dropMode'}
l!l&&r!l&&!r
7820232
$createMode or $lockMode
l!l&&r!l&&!r
134648232
MC/DC66%2/3
$createMode || $lockMode || $flags->{'dropMode'}
$createMode $lockMode $flags->{'dropMode'}
Truth table75%3/4
A or B || C
A= $createModeB= $lockModeC= $flags->{'dropMode'}
ABCresult
1XX1
01X1
0011
0000
1469 1014 ▶ if ($write_op)
Branch: 1 branch
BranchTrueFalseTotal
if ($write_op) 782 232 1014
1470 {
1471 $table_meta->{readonly}
1472 and croak "Table '$table' is marked readonly - "
1473 . $self->{command}
1474 782 ▶ . ( $lockMode ? " with locking" : "" )
Branch: 2 branches
BranchTrueFalseTotal
$table_meta->{"readonly"} and croak("Table '${table}' is marked readonly - " . $self->{"command"} . ($lockMode ? " with locking" : "") . ' command forbidden') 24 758 782
$lockMode ? : 24 0 24
1475 . " command forbidden";
1476 }
1477  
1478 990 return $class->new( $data, { table => $table }, $flags );
1479 } # open_table
1480  
1481 # ====== SQL::TABLE ============================================================
1482  
1483 package DBI::DBD::SqlEngine::Table;
1484  
1485 450 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
1486 450 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
1487  
1488 450 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
1489  
1490 450 our @ISA = qw(DBI::SQL::Nano::Table);
1491  
1492 sub bootstrap_table_meta
1493 894 ▶{
Subroutine bootstrap_table_meta: called CC=5 SCAR=16.1
1494 894 my ( $self, $dbh, $meta, $table ) = @_;
1495  
1496 defined $dbh->{ReadOnly}
1497 and !defined( $meta->{readonly} )
1498 894 ▶ and $meta->{readonly} = $dbh->{ReadOnly};
Branch: 1 branch
BranchTrueFalseTotal
defined $dbh->{"ReadOnly"} and not defined $meta->{"readonly"} and $meta->{"readonly"} = $dbh->{"ReadOnly"} 16 878 894
Condition100%3/3
defined $dbh->{"ReadOnly"} and not defined $meta->{"readonly"}
!ll&&!rl&&r
8621616
MC/DC100%2/2
defined $dbh->{"ReadOnly"} and not defined $meta->{"readonly"}
defined $dbh->{"ReadOnly"} not defined $meta->{"readonly"}
Truth table100%3/3
A and not(B)
A= defined $dbh->{"ReadOnly"}B= not defined $meta->{"readonly"}
ABresult
0X0
100
111
1499 defined $meta->{sql_identifier_case}
1500 894 ▶ or $meta->{sql_identifier_case} = $dbh->{sql_identifier_case};
Branch: 1 branch
BranchTrueFalseTotal
defined $meta->{"sql_identifier_case"} or $meta->{"sql_identifier_case"} = $dbh->{"sql_identifier_case"} 50 844 894
1501  
1502 894 ▶ exists $meta->{sql_data_source} or $meta->{sql_data_source} = $dbh->{sql_data_source};
Branch: 1 branch
BranchTrueFalseTotal
exists $meta->{"sql_data_source"} or $meta->{"sql_data_source"} = $dbh->{"sql_data_source"} 42 852 894
1503  
1504 894 $meta;
1505 }
1506  
1507 sub init_table_meta
1508 676 ▶{
Subroutine init_table_meta: called CC=1 SCAR=0.0
1509 676 my ( $self, $dbh, $meta, $table ) = @_ if (0);
1510  
1511 676 return;
1512 } # init_table_meta
1513  
1514 sub get_table_meta ($$$;$)
1515 2324 ▶{
Subroutine get_table_meta: called CC=13 SCAR=25.7
1516 2324 my ( $self, $dbh, $table, $respect_case, @other ) = @_;
1517 2324 ▶ unless ( defined $respect_case )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $respect_case) 2112 212 2324
1518 {
1519 2112 $respect_case = 0;
1520 2112 ▶ $table =~ s/^\"// and $respect_case = 1; # handle quoted identifiers
Branch: 1 branch
BranchTrueFalseTotal
$table =~ s/^\"// and $respect_case = 1 0 2112 2112
1521 2112 $table =~ s/\"$//;
1522 }
1523  
1524 2324 ▶ unless ($respect_case)
Branch: 1 branch
BranchTrueFalseTotal
unless ($respect_case) 2288 36 2324
1525 {
1526 2288 ▶ defined $dbh->{sql_meta_map}{$table} and $table = $dbh->{sql_meta_map}{$table};
Branch: 1 branch
BranchTrueFalseTotal
defined $dbh->{"sql_meta_map"}{$table} and $table = $dbh->{"sql_meta_map"}{$table} 486 1802 2288
1527 }
1528  
1529 2324 my $meta = {};
1530 2324 ▶ defined $dbh->{sql_meta}{$table} and $meta = $dbh->{sql_meta}{$table};
Branch: 1 branch
BranchTrueFalseTotal
defined $dbh->{"sql_meta"}{$table} and $meta = $dbh->{"sql_meta"}{$table} 1530 794 2324
1531  
1532 do_initialize:
1533 2366 ▶ unless ( $meta->{initialized} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($meta->{"initialized"}) 882 1484 2366
1534 {
1535 882 $self->bootstrap_table_meta( $dbh, $meta, $table, @other );
1536 882 ▶ $meta->{sql_data_source}->complete_table_name( $meta, $table, $respect_case, @other )
Branch: 1 branch
BranchTrueFalseTotal
$meta->{"sql_data_source"}->complete_table_name($meta, $table, $respect_case, @other) or return 750 128 878
1537 or return;
1538  
1539 750 ▶ if ( defined $meta->{table_name} and $table ne $meta->{table_name} )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $meta->{"table_name"} and $table ne $meta->{"table_name"}) 194 556 750
Condition100%3/3
defined $meta->{"table_name"} and $table ne $meta->{"table_name"}
!ll&&!rl&&r
4552194
MC/DC100%2/2
defined $meta->{"table_name"} and $table ne $meta->{"table_name"}
defined $meta->{"table_name"} $table ne $meta->{"table_name"}
Truth table100%3/3
A and B
A= defined $meta->{"table_name"}B= $table ne $meta->{"table_name"}
ABresult
0X0
100
111
1540 {
1541 194 $dbh->{sql_meta_map}{$table} = $meta->{table_name};
1542 194 $table = $meta->{table_name};
1543 }
1544  
1545 # now we know a bit more - let's check if user can't use consequent spelling
1546 # XXX add know issue about reset sql_identifier_case here ...
1547 750 ▶ if ( defined $dbh->{sql_meta}{$table} )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dbh->{"sql_meta"}{$table}) 78 672 750
1548 {
1549 78 $meta = delete $dbh->{sql_meta}{$table}; # avoid endless loop
1550 $meta->{initialized}
1551 78 ▶ or goto do_initialize;
Branch: 1 branch
BranchTrueFalseTotal
$meta->{"initialized"} or goto do_initialize 36 42 78
1552 #or $meta->{sql_data_source}->complete_table_name( $meta, $table, $respect_case, @other )
1553 #or return;
1554 }
1555  
1556 708 ▶ unless ( $dbh->{sql_meta}{$table}{initialized} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($dbh->{"sql_meta"}{$table}{"initialized"}) 708 0 708
1557 {
1558 708 $self->init_table_meta( $dbh, $meta, $table );
1559 676 $meta->{initialized} = 1;
1560 676 $dbh->{sql_meta}{$table} = $meta;
1561 }
1562 }
1563  
1564 2160 return ( $table, $meta );
1565 } # get_table_meta
1566  
1567 450 my %reset_on_modify = ();
1568 450 my %compat_map = ();
1569  
1570 sub register_reset_on_modify
1571 880 ▶{
Subroutine register_reset_on_modify: called CC=3 SCAR=11.0
1572 880 my ( $proto, $extra_resets ) = @_;
1573 880 foreach my $cv ( keys %$extra_resets )
1574 {
1575 #%reset_on_modify = ( %reset_on_modify, %$extra_resets );
1576 3104 ▶ push @{ $reset_on_modify{$cv} },
Branch: 1 branch
BranchTrueFalseTotal
ref $extra_resets->{$cv} ? : 896 2208 3104
1577 3104 ref $extra_resets->{$cv} ? @{ $extra_resets->{$cv} } : ( $extra_resets->{$cv} );
1578 }
1579 880 return;
1580 } # register_reset_on_modify
1581  
1582 sub register_compat_map
1583 880 ▶{
Subroutine register_compat_map: called CC=1 SCAR=0.0
1584 880 my ( $proto, $extra_compat_map ) = @_;
1585 880 %compat_map = ( %compat_map, %$extra_compat_map );
1586 880 return;
1587 } # register_compat_map
1588  
1589 sub get_table_meta_attr
1590 82 ▶{
Subroutine get_table_meta_attr: called CC=3 SCAR=12.5
1591 82 my ( $class, $meta, $attrib ) = @_;
1592 exists $compat_map{$attrib}
1593 82 ▶ and $attrib = $compat_map{$attrib};
Branch: 1 branch
BranchTrueFalseTotal
exists $compat_map{$attrib} and $attrib = $compat_map{$attrib} 0 82 82
1594 exists $meta->{$attrib}
1595 82 ▶ and return $meta->{$attrib};
Branch: 1 branch
BranchTrueFalseTotal
exists $meta->{$attrib} and return $meta->{$attrib} 82 0 82
1596 0 return;
1597 } # get_table_meta_attr
1598  
1599 sub set_table_meta_attr
1600 16 ▶{
Subroutine set_table_meta_attr: called CC=2 SCAR=6.9
1601 16 my ( $class, $meta, $attrib, $value ) = @_;
1602 exists $compat_map{$attrib}
1603 16 ▶ and $attrib = $compat_map{$attrib};
Branch: 1 branch
BranchTrueFalseTotal
exists $compat_map{$attrib} and $attrib = $compat_map{$attrib} 8 8 16
1604 16 $class->table_meta_attr_changed( $meta, $attrib, $value );
1605 16 $meta->{$attrib} = $value;
1606 } # set_table_meta_attr
1607  
1608 sub table_meta_attr_changed
1609 16 ▶{
Subroutine table_meta_attr_changed: called CC=3 SCAR=12.5
1610 16 my ( $class, $meta, $attrib, $value ) = @_;
1611 defined $reset_on_modify{$attrib}
1612 16 and delete @$meta{ @{ $reset_on_modify{$attrib} } }
1613 16 ▶ and $meta->{initialized} = 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $reset_on_modify{$attrib} and delete @$meta{@{$reset_on_modify{$attrib};}} and $meta->{"initialized"} = 0 16 0 16
Condition33%1/3
defined $reset_on_modify{$attrib} and delete @$meta{@{$reset_on_modify{$attrib};}}
!ll&&!rl&&r
0016
MC/DC0%0/2
defined $reset_on_modify{$attrib} and delete @$meta{@{$reset_on_modify{$attrib};}}
defined $reset_on_modify{$attrib} delete @$meta{@{$reset_on_modify{$attrib};}}
Truth table33%1/3
A and B
A= defined $reset_on_modify{$attrib}B= delete @$meta{@{$reset_on_modify{$attrib};}}
ABresult
0X0
100
111
1614 } # table_meta_attr_changed
1615  
1616 sub open_data
1617 990 ▶{
Subroutine open_data: called CC=2 SCAR=7.0
1618 990 my ( $self, $meta, $attrs, $flags ) = @_;
1619  
1620 $meta->{sql_data_source}
1621 990 ▶ or croak "Table " . $meta->{table_name} . " not completely initialized";
Branch: 1 branch
BranchTrueFalseTotal
$meta->{"sql_data_source"} or croak('Table ' . $meta->{"table_name"} . ' not completely initialized') 990 0 990
1622 990 $meta->{sql_data_source}->open_data( $meta, $attrs, $flags );
1623  
1624 882 return;
1625 } # open_data
1626  
1627 # ====== SQL::Eval API =========================================================
1628  
1629 sub new
1630 990 ▶{
Subroutine new: called CC=5 SCAR=16.3
1631 990 my ( $className, $data, $attrs, $flags ) = @_;
1632 990 my $dbh = $data->{Database};
1633  
1634 990 ▶ my ( $tblnm, $meta ) = $className->get_table_meta( $dbh, $attrs->{table}, 1 )
Branch: 1 branch
BranchTrueFalseTotal
() = $className->get_table_meta($dbh, $attrs->{"table"}, 1) or croak(qq[Cannot find appropriate table '$attrs->{"table"}']) 990 0 990
1635 or croak "Cannot find appropriate table '$attrs->{table}'";
1636 990 $attrs->{table} = $tblnm;
1637  
1638 # Being a bit dirty here, as SQL::Statement::Structure does not offer
1639 # me an interface to the data I want
1640 $flags->{createMode} && $data->{sql_stmt}{table_defs}
1641 990 ▶ and $meta->{table_defs} = $data->{sql_stmt}{table_defs};
Branch: 1 branch
BranchTrueFalseTotal
$flags->{"createMode"} and $data->{"sql_stmt"}{"table_defs"} and $meta->{"table_defs"} = $data->{"sql_stmt"}{"table_defs"} 0 990 990
Condition66%2/3
$flags->{"createMode"} and $data->{"sql_stmt"}{"table_defs"}
!ll&&!rl&&r
8561340
MC/DC0%0/2
$flags->{"createMode"} and $data->{"sql_stmt"}{"table_defs"}
$flags->{"createMode"} $data->{"sql_stmt"}{"table_defs"}
Truth table66%2/3
A and B
A= $flags->{"createMode"}B= $data->{"sql_stmt"}{"table_defs"}
ABresult
0X0
100
111
1642  
1643 # open_file must be called before inherited new is invoked
1644 # because column name mapping is initialized in constructor ...
1645 990 $className->open_data( $meta, $attrs, $flags );
1646  
1647 my $tbl = {
1648 882 ▶ %{$attrs},
Condition100%2/2
$meta->{'col_names'} || []
l!l
724158
MC/DC100%1/1
$meta->{'col_names'} || []
$meta->{'col_names'}
Truth table100%2/2
A
A= $meta->{'col_names'}
Aresult
11
00
1649 meta => $meta,
1650 882 col_names => $meta->{col_names} || [],
1651 };
1652 882 return $className->SUPER::new($tbl);
1653 } # new
1654  
1655 sub DESTROY
1656 882 ▶{
Subroutine DESTROY: called CC=2 SCAR=6.9
1657 882 my $self = shift;
1658 882 my $meta = $self->{meta};
1659 882 ▶ $self->{row} and undef $self->{row};
Branch: 1 branch
BranchTrueFalseTotal
$self->{"row"} and undef $self->{"row"} 36 846 882
1660 ()
1661 882 }
1662  
1663 450 1;
1664  
1665 =pod
1666  
1667 =head1 NAME
1668  
1669 DBI::DBD::SqlEngine - Base class for DBI drivers without their own SQL engine
1670  
1671 =head1 SYNOPSIS
1672  
1673 package DBD::myDriver;
1674  
1675 use base qw(DBI::DBD::SqlEngine);
1676  
1677 sub driver {
1678 ...
1679 my $drh = $proto->SUPER::driver ($attr);
1680 ...
1681 return $drh->{class};
1682 }
1683  
1684 package DBD::myDriver::dr;
1685  
1686 our @ISA = qw(DBI::DBD::SqlEngine::dr);
1687  
1688 sub data_sources { ... }
1689 ...
1690  
1691 package DBD::myDriver::db;
1692  
1693 our @ISA = qw(DBI::DBD::SqlEngine::db);
1694  
1695 sub init_valid_attributes { ... }
1696 sub init_default_attributes { ... }
1697 sub set_versions { ... }
1698 sub validate_STORE_attr { my ($dbh, $attrib, $value) = @_; ... }
1699 sub validate_FETCH_attr { my ($dbh, $attrib) = @_; ... }
1700 sub get_myd_versions { ... }
1701 sub get_avail_tables { ... }
1702  
1703 package DBD::myDriver::st;
1704  
1705 our @ISA = qw(DBI::DBD::SqlEngine::st);
1706  
1707 sub FETCH { ... }
1708 sub STORE { ... }
1709  
1710 package DBD::myDriver::Statement;
1711  
1712 our @ISA = qw(DBI::DBD::SqlEngine::Statement);
1713  
1714 sub open_table { ... }
1715  
1716 package DBD::myDriver::Table;
1717  
1718 our @ISA = qw(DBI::DBD::SqlEngine::Table);
1719  
1720 sub new { ... }
1721  
1722 =head1 DESCRIPTION
1723  
1724 DBI::DBD::SqlEngine abstracts the usage of SQL engines from the
1725 DBD. DBD authors can concentrate on the data retrieval they want to
1726 provide.
1727  
1728 It is strongly recommended that you read L<DBD::File::Developers> and
1729 L<DBD::File::Roadmap>, because many of the DBD::File API is provided
1730 by DBI::DBD::SqlEngine.
1731  
1732 Currently the API of DBI::DBD::SqlEngine is experimental and will
1733 likely change in the near future to provide the table meta data basics
1734 like DBD::File.
1735  
1736 DBI::DBD::SqlEngine expects that any driver in inheritance chain has
1737 a L<DBI prefix|DBI::DBD/The_database_handle_constructor>.
1738  
1739 =head2 Metadata
1740  
1741 The following attributes are handled by DBI itself and not by
1742 DBI::DBD::SqlEngine, thus they all work as expected:
1743  
1744 Active
1745 ActiveKids
1746 CachedKids
1747 CompatMode (Not used)
1748 InactiveDestroy
1749 AutoInactiveDestroy
1750 Kids
1751 PrintError
1752 RaiseError
1753 Warn (Not used)
1754  
1755 =head3 The following DBI attributes are handled by DBI::DBD::SqlEngine:
1756  
1757 =head4 AutoCommit
1758  
1759 Always on.
1760  
1761 =head4 ChopBlanks
1762  
1763 Works.
1764  
1765 =head4 NUM_OF_FIELDS
1766  
1767 Valid after C<< $sth->execute >>.
1768  
1769 =head4 NUM_OF_PARAMS
1770  
1771 Valid after C<< $sth->prepare >>.
1772  
1773 =head4 NAME
1774  
1775 Valid after C<< $sth->execute >>; probably undef for Non-Select statements.
1776  
1777 =head4 NULLABLE
1778  
1779 Not really working, always returns an array ref of ones, as DBD::CSV
1780 does not verify input data. Valid after C<< $sth->execute >>; undef for
1781 non-select statements.
1782  
1783 =head3 The following DBI attributes and methods are not supported:
1784  
1785 =over 4
1786  
1787 =item bind_param_inout
1788  
1789 =item CursorName
1790  
1791 =item LongReadLen
1792  
1793 =item LongTruncOk
1794  
1795 =back
1796  
1797 =head3 DBI::DBD::SqlEngine specific attributes
1798  
1799 In addition to the DBI attributes, you can use the following dbh
1800 attributes:
1801  
1802 =head4 sql_engine_version
1803  
1804 Contains the module version of this driver (B<readonly>)
1805  
1806 =head4 sql_nano_version
1807  
1808 Contains the module version of DBI::SQL::Nano (B<readonly>)
1809  
1810 =head4 sql_statement_version
1811  
1812 Contains the module version of SQL::Statement, if available (B<readonly>)
1813  
1814 =head4 sql_handler
1815  
1816 Contains the SQL Statement engine, either DBI::SQL::Nano or SQL::Statement
1817 (B<readonly>).
1818  
1819 =head4 sql_parser_object
1820  
1821 Contains an instantiated instance of SQL::Parser (B<readonly>).
1822 This is filled when used first time (only when used with SQL::Statement).
1823  
1824 =head4 sql_sponge_driver
1825  
1826 Contains an internally used DBD::Sponge handle (B<readonly>).
1827  
1828 =head4 sql_valid_attrs
1829  
1830 Contains the list of valid attributes for each DBI::DBD::SqlEngine based
1831 driver (B<readonly>).
1832  
1833 =head4 sql_readonly_attrs
1834  
1835 Contains the list of those attributes which are readonly (B<readonly>).
1836  
1837 =head4 sql_identifier_case
1838  
1839 Contains how DBI::DBD::SqlEngine deals with non-quoted SQL identifiers:
1840  
1841 * SQL_IC_UPPER (1) means all identifiers are internally converted
1842 into upper-cased pendants
1843 * SQL_IC_LOWER (2) means all identifiers are internally converted
1844 into lower-cased pendants
1845 * SQL_IC_MIXED (4) means all identifiers are taken as they are
1846  
1847 These conversions happen if (and only if) no existing identifier matches.
1848 Once existing identifier is used as known.
1849  
1850 The SQL statement execution classes doesn't have to care, so don't expect
1851 C<sql_identifier_case> affects column names in statements like
1852  
1853 SELECT * FROM foo
1854  
1855 =head4 sql_quoted_identifier_case
1856  
1857 Contains how DBI::DBD::SqlEngine deals with quoted SQL identifiers
1858 (B<readonly>). It's fixated to SQL_IC_SENSITIVE (3), which is interpreted
1859 as SQL_IC_MIXED.
1860  
1861 =head4 sql_flags
1862  
1863 Contains additional flags to instantiate an SQL::Parser. Because an
1864 SQL::Parser is instantiated only once, it's recommended to set this flag
1865 before any statement is executed.
1866  
1867 =head4 sql_dialect
1868  
1869 Controls the dialect understood by SQL::Parser. Possible values (delivery
1870 state of SQL::Statement):
1871  
1872 * ANSI
1873 * CSV
1874 * AnyData
1875  
1876 Defaults to "CSV". Because an SQL::Parser is instantiated only once and
1877 SQL::Parser doesn't allow one to modify the dialect once instantiated,
1878 it's strongly recommended to set this flag before any statement is
1879 executed (best place is connect attribute hash).
1880  
1881 =head4 sql_engine_in_gofer
1882  
1883 This value has a true value in case of this driver is operated via
1884 L<DBD::Gofer>. The impact of being operated via Gofer is a read-only
1885 driver (not read-only databases!), so you cannot modify any attributes
1886 later - neither any table settings. B<But> you won't get an error in
1887 cases you modify table attributes, so please carefully watch
1888 C<sql_engine_in_gofer>.
1889  
1890 =head4 sql_meta
1891  
1892 Private data area which contains information about the tables this
1893 module handles. Table meta data might not be available until the
1894 table has been accessed for the first time e.g., by issuing a select
1895 on it however it is possible to pre-initialize attributes for each table
1896 you use.
1897  
1898 DBI::DBD::SqlEngine recognizes the (public) attributes C<col_names>,
1899 C<table_name>, C<readonly>, C<sql_data_source> and C<sql_identifier_case>.
1900 Be very careful when modifying attributes you do not know, the consequence
1901 might be a destroyed or corrupted table.
1902  
1903 While C<sql_meta> is a private and readonly attribute (which means, you
1904 cannot modify it's values), derived drivers might provide restricted
1905 write access through another attribute. Well known accessors are
1906 C<csv_tables> for L<DBD::CSV>, C<ad_tables> for L<DBD::AnyData> and
1907 C<dbm_tables> for L<DBD::DBM>.
1908  
1909 =head4 sql_table_source
1910  
1911 Controls the class which will be used for fetching available tables.
1912  
1913 See L</DBI::DBD::SqlEngine::TableSource> for details.
1914  
1915 =head4 sql_data_source
1916  
1917 Contains the class name to be used for opening tables.
1918  
1919 See L</DBI::DBD::SqlEngine::DataSource> for details.
1920  
1921 =head2 Driver private methods
1922  
1923 =head3 Default DBI methods
1924  
1925 =head4 data_sources
1926  
1927 The C<data_sources> method returns a list of subdirectories of the current
1928 directory in the form "dbi:CSV:f_dir=$dirname".
1929  
1930 If you want to read the subdirectories of another directory, use
1931  
1932 my ($drh) = DBI->install_driver ("CSV");
1933 my (@list) = $drh->data_sources (f_dir => "/usr/local/csv_data");
1934  
1935 =head4 list_tables
1936  
1937 This method returns a list of file names inside $dbh->{f_dir}.
1938 Example:
1939  
1940 my ($dbh) = DBI->connect ("dbi:CSV:f_dir=/usr/local/csv_data");
1941 my (@list) = $dbh->func ("list_tables");
1942  
1943 Note that the list includes all files contained in the directory, even
1944 those that have non-valid table names, from the view of SQL.
1945  
1946 =head3 Additional methods
1947  
1948 The following methods are only available via their documented name when
1949 DBI::DBD::SQlEngine is used directly. Because this is only reasonable for
1950 testing purposes, the real names must be used instead. Those names can be
1951 computed by replacing the C<sql_> in the method name with the driver prefix.
1952  
1953 =head4 sql_versions
1954  
1955 Signature:
1956  
1957 sub sql_versions (;$) {
1958 my ($table_name) = @_;
1959 $table_name ||= ".";
1960 ...
1961 }
1962  
1963 Returns the versions of the driver, including the DBI version, the Perl
1964 version, DBI::PurePerl version (if DBI::PurePerl is active) and the version
1965 of the SQL engine in use.
1966  
1967 my $dbh = DBI->connect ("dbi:File:");
1968 my $sql_versions = $dbh->func( "sql_versions" );
1969 print "$sql_versions\n";
1970 __END__
1971 # DBI::DBD::SqlEngine 0.05 using SQL::Statement 1.402
1972 # DBI 1.623
1973 # OS netbsd (6.99.12)
1974 # Perl 5.016002 (x86_64-netbsd-thread-multi)
1975  
1976 Called in list context, sql_versions will return an array containing each
1977 line as single entry.
1978  
1979 Some drivers might use the optional (table name) argument and modify
1980 version information related to the table (e.g. DBD::DBM provides storage
1981 backend information for the requested table, when it has a table name).
1982  
1983 =head4 sql_get_meta
1984  
1985 Signature:
1986  
1987 sub sql_get_meta ($$) {
1988 my ($table_name, $attrib) = @_;
1989 ...
1990 }
1991  
1992 Returns the value of a meta attribute set for a specific table, if any.
1993 See L<sql_meta> for the possible attributes.
1994  
1995 A table name of C<"."> (single dot) is interpreted as the default table.
1996 This will retrieve the appropriate attribute globally from the dbh.
1997 This has the same restrictions as C<< $dbh->{$attrib} >>.
1998  
1999 =head4 sql_set_meta
2000  
2001 Signature:
2002  
2003 sub sql_set_meta ($$$) {
2004 my ($table_name, $attrib, $value) = @_;
2005 ...
2006 }
2007  
2008 Sets the value of a meta attribute set for a specific table.
2009 See L<sql_meta> for the possible attributes.
2010  
2011 A table name of C<"."> (single dot) is interpreted as the default table
2012 which will set the specified attribute globally for the dbh.
2013 This has the same restrictions as C<< $dbh->{$attrib} = $value >>.
2014  
2015 =head4 sql_clear_meta
2016  
2017 Signature:
2018  
2019 sub sql_clear_meta ($) {
2020 my ($table_name) = @_;
2021 ...
2022 }
2023  
2024 Clears the table specific meta information in the private storage of the
2025 dbh.
2026  
2027 =head2 Extensibility
2028  
2029 =head3 DBI::DBD::SqlEngine::TableSource
2030  
2031 Provides data sources and table information on database driver and database
2032 handle level.
2033  
2034 package DBI::DBD::SqlEngine::TableSource;
2035  
2036 sub data_sources ($;$) {
2037 my ($class, $drh, $attrs) = @_;
2038 ...
2039 }
2040  
2041 sub avail_tables {
2042 my ( $class, $drh ) = @_;
2043 ...
2044 }
2045  
2046 The C<data_sources> method is called when the user invokes any of the
2047 following:
2048  
2049 @ary = DBI->data_sources ($driver);
2050 @ary = DBI->data_sources ($driver, \%attr);
2051  
2052 @ary = $dbh->data_sources ();
2053 @ary = $dbh->data_sources (\%attr);
2054  
2055 The C<avail_tables> method is called when the user invokes any of the
2056 following:
2057  
2058 @names = $dbh->tables ($catalog, $schema, $table, $type);
2059  
2060 $sth = $dbh->table_info ($catalog, $schema, $table, $type);
2061 $sth = $dbh->table_info ($catalog, $schema, $table, $type, \%attr);
2062  
2063 $dbh->func ("list_tables");
2064  
2065 Every time where an C<\%attr> argument can be specified, this C<\%attr>
2066 object's C<sql_table_source> attribute is preferred over the C<$dbh>
2067 attribute or the driver default, e.g.
2068  
2069 @ary = DBI->data_sources ("dbi:CSV:", {
2070 f_dir => "/your/csv/tables",
2071 # note: this class doesn't comes with DBI
2072 sql_table_source => "DBD::File::Archive::Tar::TableSource",
2073 # scan tarballs instead of directories
2074 });
2075  
2076 When you're going to implement such a DBD::File::Archive::Tar::TableSource
2077 class, remember to add correct attributes (including C<sql_table_source>
2078 and C<sql_data_source>) to the returned DSN's.
2079  
2080 =head3 DBI::DBD::SqlEngine::DataSource
2081  
2082 Provides base functionality for dealing with tables. It is primarily
2083 designed for allowing transparent access to files on disk or already
2084 opened (file-)streams (e.g. for DBD::CSV).
2085  
2086 Derived classes shall be restricted to similar functionality, too (e.g.
2087 opening streams from an archive, transparently compress/uncompress
2088 log files before parsing them,
2089  
2090 package DBI::DBD::SqlEngine::DataSource;
2091  
2092 sub complete_table_name ($$;$) {
2093 my ($self, $meta, $table, $respect_case) = @_;
2094 ...
2095 }
2096  
2097 The method C<complete_table_name> is called when first setting up the
2098 I<meta information> for a table:
2099  
2100 "SELECT user.id, user.name, user.shell FROM user WHERE ..."
2101  
2102 results in opening the table C<user>. First step of the table open
2103 process is completing the name. Let's imagine you're having a L<DBD::CSV>
2104 handle with following settings:
2105  
2106 $dbh->{sql_identifier_case} = SQL_IC_LOWER;
2107 $dbh->{f_ext} = '.lst';
2108 $dbh->{f_dir} = '/data/web/adrmgr';
2109  
2110 Those settings will result in looking for files matching
2111 C<[Uu][Ss][Ee][Rr](\.lst)?$> in C</data/web/adrmgr/>. The scanning of the
2112 directory C</data/web/adrmgr/> and the pattern match check will be done
2113 in C<DBD::File::DataSource::File> by the C<complete_table_name> method.
2114  
2115 If you intend to provide other sources of data streams than files, in
2116 addition to provide an appropriate C<complete_table_name> method, a method
2117 to open the resource is required:
2118  
2119 package DBI::DBD::SqlEngine::DataSource;
2120  
2121 sub open_data ($) {
2122 my ($self, $meta, $attrs, $flags) = @_;
2123 ...
2124 }
2125  
2126 After the method C<open_data> has been run successfully, the table's meta
2127 information are in a state which allows the table's data accessor methods
2128 will be able to fetch/store row information. Implementation details heavily
2129 depends on the table implementation, whereby the most famous is surely
2130 L<DBD::File::Table|DBD::File/DBD::File::Table>.
2131  
2132 =head1 SQL ENGINES
2133  
2134 DBI::DBD::SqlEngine currently supports two SQL engines:
2135 L<SQL::Statement|SQL::Statement> and
2136 L<DBI::SQL::Nano::Statement_|DBI::SQL::Nano>. DBI::SQL::Nano supports a
2137 I<very> limited subset of SQL statements, but it might be faster for some
2138 very simple tasks. SQL::Statement in contrast supports a much larger subset
2139 of ANSI SQL.
2140  
2141 To use SQL::Statement, you need at least version 1.401 of
2142 SQL::Statement and the environment variable C<DBI_SQL_NANO> must not
2143 be set to a true value.
2144  
2145 =head1 SUPPORT
2146  
2147 You can find documentation for this module with the perldoc command.
2148  
2149 perldoc DBI::DBD::SqlEngine
2150  
2151 You can also look for information at:
2152  
2153 =over 4
2154  
2155 =item * RT: CPAN's request tracker
2156  
2157 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBI>
2158 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Statement>
2159  
2160 =item * CPAN Ratings
2161  
2162 L<http://cpanratings.perl.org/d/DBI>
2163  
2164 =item * Search CPAN
2165  
2166 L<http://search.cpan.org/dist/DBI/>
2167  
2168 =back
2169  
2170 =head2 Where can I go for more help?
2171  
2172 For questions about installation or usage, please ask on the
2173 dbi-dev@perl.org mailing list.
2174  
2175 If you have a bug report, patch or suggestion, please open
2176 a new report ticket on CPAN, if there is not already one for
2177 the issue you want to report. Of course, you can mail any of the
2178 module maintainers, but it is less likely to be missed if
2179 it is reported on RT.
2180  
2181 Report tickets should contain a detailed description of the bug or
2182 enhancement request you want to report and at least an easy way to
2183 verify/reproduce the issue and any supplied fix. Patches are always
2184 welcome, too.
2185  
2186 =head1 ACKNOWLEDGEMENTS
2187  
2188 Thanks to Tim Bunce, Martin Evans and H.Merijn Brand for their continued
2189 support while developing DBD::File, DBD::DBM and DBD::AnyData.
2190 Their support, hints and feedback helped to design and implement this
2191 module.
2192  
2193 =head1 AUTHOR
2194  
2195 This module is currently maintained by
2196  
2197 H.Merijn Brand < perl5 at tux.freedom.nl > and
2198 Jens Rehsack < rehsack at googlemail.com >
2199  
2200 The original authors are Jochen Wiedmann and Jeff Zucker.
2201  
2202 =head1 COPYRIGHT AND LICENSE
2203  
2204 Copyright (C) 2009-2026 by H.Merijn Brand & Jens Rehsack
2205 Copyright (C) 2004-2009 by Jeff Zucker
2206 Copyright (C) 1998-2004 by Jochen Wiedmann
2207  
2208 All rights reserved.
2209  
2210 You may freely distribute and/or modify this module under the terms of
2211 either the GNU General Public License (GPL) or the Artistic License, as
2212 specified in the Perl README file.
2213  
2214 =head1 SEE ALSO
2215  
2216 L<DBI>, L<DBD::File>, L<DBD::AnyData> and L<DBD::Sys>.
2217  
2218 =cut
« blib/lib/DBI/ProxyServer.pm ↑ Summary blib/lib/DBI/SQL/Nano.pm »