blib/lib/DBI/DBD/SqlEngine.pm

filter: Statementstmt 79.3% 592 / 746 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% 997 / 1559 CC 266 SCAR 30.0
CC
266
Cov
67%
quote
132.0
bind_param
118.1
FETCH
104.8
CRAP 20.2
« blib/lib/DBD/DBM.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 449 require 5.012;
24  
25 449 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 449 ▶use DBI ();
Subroutine BEGIN: called CC=1 SCAR=0.0
28 449 require DBI::SQL::Nano;
29  
30 package DBI::DBD::SqlEngine;
31  
32 449 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 449 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 449 our %methods_installed;
36  
37 449 our $VERSION = "0.06";
38  
39 449 our $drh = undef; # holds driver handle(s) once initialized
40  
41 449 DBI->setup_driver("DBI::DBD::SqlEngine"); # only needed once but harmless to repeat
42  
43 449 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 441 ▶{
Subroutine driver: called CC=13 SCAR=29.6
Pod undocumented
53 441 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 441 ▶ $drh->{$class} and return $drh->{$class};
Branch: 1 branch
BranchTrueFalseTotal
$DBI::DBD::SqlEngine::drh->{$class} and return $DBI::DBD::SqlEngine::drh->{$class} 0 441 441
63  
64 441 ▶ $attr ||= {};
Condition50%1/2
$attr ||= {}
l!l
4410
MC/DC0%0/1
$attr ||= {}
$attr
Truth table50%1/2
A
A= $attr
Aresult
11
00
65 {
66 449 ▶ no strict "refs";
Subroutine BEGIN: called CC=1 SCAR=0.0
67 441 ▶ unless ( $attr->{Attribution} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($attr->{"Attribution"}) 0 441 441
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 441 ▶ $attr->{Version} ||= ${ $class . "::VERSION" };
Condition66%2/3
$attr->{"Version"} ||= ${$class . '::VERSION';}
l!l&&r!l&&!r
43920
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 441 ▶ $attr->{Name} or ( $attr->{Name} = $class ) =~ s/^DBD\:\://;
Branch: 1 branch
BranchTrueFalseTotal
$attr->{"Name"} or ($attr->{"Name"} = $class) =~ s/^DBD\:\:// 439 2 441
76 }
77  
78 441 $drh->{$class} = DBI::_new_drh( $class . "::dr", $attr );
79 441 $drh->{$class}->STORE( ShowErrorStatement => 1 );
80  
81 441 my $prefix = DBI->driver_prefix($class);
82 441 ▶ if ($prefix)
Branch: 1 branch
BranchTrueFalseTotal
if ($prefix) { } 441 0 441
83 {
84 441 my $dbclass = $class . "::db";
85 441 ▶ while ( my ( $accessor, $funcname ) = each %accessors )
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %accessors) 2205 441 2646
86 {
87 2205 my $method = $prefix . $accessor;
88 2205 ▶ $dbclass->can($method) and next;
Branch: 1 branch
BranchTrueFalseTotal
$dbclass->can($method) and next 0 2205 2205
89 2205 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 2205 ▶ 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 2205 $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 441 my $stclass = $class . "::st";
110 441 ▶ $stclass->install_method("sql_get_colnames") unless ( $methods_installed{__PACKAGE__}++ );
Branch: 1 branch
BranchTrueFalseTotal
unless $DBI::DBD::SqlEngine::methods_installed{"__PACKAGE__"}++ 439 2 441
111  
112 441 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 449 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
125 449 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
126  
127 449 ▶use Carp qw/carp/;
Subroutine BEGIN: called CC=1 SCAR=0.0
128  
129 449 our $imp_data_size = 0;
130  
131 sub connect ($$;$$$)
132 1222 ▶{
Subroutine connect: called CC=20 SCAR=33.2
133 1222 my ( $drh, $dbname, $user, $auth, $attr ) = @_;
134  
135 # create a 'blank' dbh
136 1222 my $dbh = DBI::_new_dbh(
137 $drh,
138 {
139 Name => $dbname,
140 USER => $user,
141 CURRENT_USER => $user,
142 }
143 );
144  
145 1222 ▶ if ($dbh)
Branch: 1 branch
BranchTrueFalseTotal
if ($dbh) 1222 0 1222
146 {
147 # must be done first, because setting flags implicitly calls $dbdname::db->STORE
148 1222 $dbh->func( 0, "init_default_attributes" );
149 1222 my $two_phased_init;
150 1222 ▶ 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"} 1222 0 1222
151 1222 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 1222 ▶ 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 1222 1222
156  
157 1222 my ( $var, $val );
158 1222 ▶ while ( length $dbname )
Branch: 1 branch
BranchTrueFalseTotal
if (length $dbname) 2984 1222 4206
159 {
160 2984 ▶ if ( $dbname =~ s/^((?:[^\\;]|\\.)*?);//s )
Branch: 1 branch
BranchTrueFalseTotal
if ($dbname =~ s/^((?:[^\\;]|\\.)*?);//s) { } 2016 968 2984
161 {
162 2016 $var = $1;
163 }
164 else
165 {
166 968 $var = $dbname;
167 968 $dbname = "";
168 }
169  
170 2984 ▶ if ( $var =~ m/^(.+?)=(.*)/s )
Branch: 2 branches
BranchTrueFalseTotal
if ($var =~ /^(.+?)=(.*)/s) { } 2984 0 2984
elsif ($var =~ /^(.+?)=>(.*)/s) { } 0 0 0
171 {
172 2984 $var = $1;
173 2984 ( $val = $2 ) =~ s/\\(.)/$1/g;
174 2984 ▶ exists $attr->{$var}
Branch: 1 branch
BranchTrueFalseTotal
if $^W 1280 1704 2984
Condition50%3/6
$^W && (exists $attr->{$var} && carp("$var is given in DSN *and* \$attr during DBI->connect()"))
!ll&&!rl&&r
170412800
exists $attr->{$var} and carp("$var is given in DSN *and* \$attr during DBI->connect()")
!ll&&!rl&&r
128000
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 2984 ▶ exists $attr->{$var} or $attr->{$var} = $val;
Branch: 1 branch
BranchTrueFalseTotal
exists $attr->{$var} or $attr->{$var} = $val 0 2984 2984
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 2444 my $order = $_;
205 2444 map { ( $_ => $order ) } @{ $dbh->{sql_init_order}{$order} };
206 1222 ▶ } sort { $a <=> $b } keys %{ $dbh->{sql_init_order} || {} };
Condition50%1/2
$dbh->{'sql_init_order'} || {}
l!l
12220
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 12979 map { $_->[0] }
209 28897 sort { $a->[1] <=> $b->[1] }
210 1222 ▶ map { [ $_, $order{$_} // 50 ] }
Condition100%2/2
$order{$_} // 50
l!l
36669313
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 1222 foreach my $a (@ordered_attr)
215 {
216 12979 ▶ exists $attr->{$a} or next;
Branch: 1 branch
BranchTrueFalseTotal
exists $attr->{$a} or next 12979 0 12979
217 12979 ▶ $two_phased_init and eval {
Branch: 1 branch
BranchTrueFalseTotal
$two_phased_init and eval { do { $dbh->{$a} = $attr->{$a}; delete $attr->{$a} } } 12979 0 12979
218 12979 $dbh->{$a} = $attr->{$a};
219 12979 delete $attr->{$a};
220 };
221 12979 ▶ $@ and $second_phase_attrs{$a} = delete $attr->{$a};
Branch: 1 branch
BranchTrueFalseTotal
$@ and $second_phase_attrs{$a} = delete $attr->{$a} 0 12979 12979
222 12979 ▶ $two_phased_init or $dbh->STORE( $a, delete $attr->{$a} );
Branch: 1 branch
BranchTrueFalseTotal
$two_phased_init or $dbh->STORE($a, delete $attr->{$a}) 12979 0 12979
223 }
224  
225 1222 ▶ $two_phased_init and $dbh->func( 1, "init_default_attributes" );
Branch: 1 branch
BranchTrueFalseTotal
$two_phased_init and $dbh->func(1, "init_default_attributes") 1222 0 1222
226 1222 %$attr = %second_phase_attrs;
227  
228 1222 ▶ for ( my $i = 0; $i < scalar(@func_inits); $i += 2 )
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @func_inits) 0 1222 1222
229 {
230 0 my $func = $func_inits[$i];
231 0 my $arg = $func_inits[ $i + 1 ];
232 0 $dbh->$func($arg);
233 }
234  
235 1222 $dbh->func("init_done");
236  
237 1222 $dbh->STORE( Active => 1 );
238 }
239  
240 1222 return $dbh;
241 } # connect
242  
243 sub data_sources ($;$)
244 74 ▶{
Subroutine data_sources: called CC=7 SCAR=23.8
245 74 my ( $drh, $attr ) = @_;
246  
247 74 my $tbl_src;
248 $attr
249 and defined $attr->{sql_table_source}
250 and $attr->{sql_table_source}->isa('DBI::DBD::SqlEngine::TableSource')
251 74 ▶ 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 74 74
Condition33%2/6
$attr and defined $attr->{"sql_table_source"} and $attr->{"sql_table_source"}->isa("DBI::DBD::SqlEngine::TableSource")
!ll&&!rl&&r
7400
$attr and defined $attr->{"sql_table_source"}
!ll&&!rl&&r
0740
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 74 ▶ 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 74 0 74
Condition33%1/3
not defined $tbl_src and $drh->{"ImplementorClass"}->can("default_table_source")
!ll&&!rl&&r
0074
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 74 ▶ defined($tbl_src) or return;
Branch: 1 branch
BranchTrueFalseTotal
defined $tbl_src or return 74 0 74
257  
258 74 $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 449 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
275 449 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
276  
277 449 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
278 449 ▶use Scalar::Util qw( refaddr );
Subroutine BEGIN: called CC=1 SCAR=0.0
279  
280 449 ▶if ( eval { require Clone; } )
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require Clone } }) { } 449 0 449
281 {
282 449 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 449 our $imp_data_size = 0;
291  
292 sub ping
293 766 ▶{
Subroutine ping: called CC=2 SCAR=7.6
294 766 ▶ ( $_[0]->FETCH("Active") ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->FETCH('Active') ? : 766 0 766
295 } # ping
296  
297 sub data_sources
298 66 ▶{
Subroutine data_sources: called CC=3 SCAR=11.8
299 66 my ( $dbh, $attr, @other ) = @_;
300 66 my $drh = $dbh->{Driver}; # XXX proxy issues?
301 66 ▶ ref($attr) eq 'HASH' or $attr = {};
Branch: 1 branch
BranchTrueFalseTotal
ref $attr eq "HASH" or $attr = {} 66 0 66
302 66 ▶ $attr->{sql_table_source} //= $dbh->{sql_table_source};
Condition33%1/3
$attr->{"sql_table_source"} //= $dbh->{"sql_table_source"}
l!l&&r!l&&!r
0066
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 66 return $drh->data_sources( $attr, @other );
304 }
305  
306 sub prepare ($$;@)
307 1358 ▶{
Subroutine prepare: called CC=8 SCAR=25.4
308 1358 my ( $dbh, $statement, @attribs ) = @_;
309  
310 # create a 'blank' sth
311 1358 my $sth = DBI::_new_sth( $dbh, { Statement => $statement } );
312  
313 1358 ▶ if ($sth)
Branch: 1 branch
BranchTrueFalseTotal
if ($sth) 1358 0 1358
314 {
315 1358 my $class = $sth->FETCH("ImplementorClass");
316 1358 $class =~ s/::st$/::Statement/;
317 1358 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 1358 ▶ if ( $class->isa("SQL::Statement") )
Branch: 1 branch
BranchTrueFalseTotal
if ($class->isa('SQL::Statement')) { } 0 1358 1358
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 1358 $stmt = eval { $class->new($statement) };
339 }
340 1358 ▶ if ( $@ || $stmt->{errstr} )
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or $stmt->{'errstr'}) { } 63 1295 1358
Condition66%2/3
$@ or $stmt->{"errstr"}
l!l&&r!l&&!r
6301295
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 63 ▶ $dbh->set_err( $DBI::stderr, $@ || $stmt->{errstr} );
Condition33%1/3
$@ || $stmt->{'errstr'}
l!l&&r!l&&!r
6300
MC/DC0%0/2
$@ || $stmt->{'errstr'}
$@ $stmt->{'errstr'}
Truth table33%1/3
A || B
A= $@B= $stmt->{'errstr'}
ABresult
1X1
011
000
343 63 undef $sth;
344 }
345 else
346 {
347 1295 $sth->STORE( "sql_stmt", $stmt );
348 1295 $sth->STORE( "sql_params", [] );
349 1295 $sth->STORE( "NUM_OF_PARAMS", scalar( $stmt->params() ) );
350 1295 my @colnames = $sth->sql_get_colnames();
351 1295 $sth->STORE( "NUM_OF_FIELDS", scalar @colnames );
352 }
353 }
354 1358 return $sth;
355 } # prepare
356  
357 sub set_versions
358 1222 ▶{
Subroutine set_versions: called CC=4 SCAR=13.9
359 1222 my $dbh = $_[0];
360 1222 $dbh->{sql_engine_version} = $DBI::DBD::SqlEngine::VERSION;
361 1222 for (qw( nano_version statement_version ))
362 {
363 2444 ▶ defined $DBI::SQL::Nano::versions->{$_} or next;
Branch: 1 branch
BranchTrueFalseTotal
defined $DBI::SQL::Nano::versions->{$_} or next 1222 1222 2444
364 1222 $dbh->{"sql_$_"} = $DBI::SQL::Nano::versions->{$_};
365 }
366 $dbh->{sql_handler} =
367 $dbh->{sql_statement_version}
368 1222 ▶ ? "SQL::Statement"
Branch: 1 branch
BranchTrueFalseTotal
$dbh->{'sql_statement_version'} ? : 0 1222 1222
369 : "DBI::SQL::Nano";
370  
371 1222 return $dbh;
372 } # set_versions
373  
374 sub init_valid_attributes
375 1222 ▶{
Subroutine init_valid_attributes: called CC=1 SCAR=0.0
376 1222 my $dbh = $_[0];
377  
378 $dbh->{sql_valid_attrs} = {
379 1222 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 1222 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 1222 return $dbh;
409 } # init_valid_attributes
410  
411 sub init_default_attributes
412 2444 ▶{
Subroutine init_default_attributes: called CC=16 SCAR=30.0
413 2444 my ( $dbh, $phase ) = @_;
414 2444 my $given_phase = $phase;
415  
416 2444 ▶ unless ( defined($phase) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $phase) 0 2444 2444
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 2444 ▶ if ( 0 == $phase )
Branch: 1 branch
BranchTrueFalseTotal
if (0 == $phase) 1222 1222 2444
424 {
425 # must be done first, because setting flags implicitly calls $dbdname::db->STORE
426 1222 $dbh->func("init_valid_attributes");
427  
428 1222 $dbh->func("set_versions");
429  
430 1222 $dbh->{sql_identifier_case} = 2; # SQL_IC_LOWER
431 1222 $dbh->{sql_quoted_identifier_case} = 3; # SQL_IC_SENSITIVE
432  
433 1222 $dbh->{sql_dialect} = "CSV";
434  
435 1222 $dbh->{sql_init_phase} = $given_phase;
436  
437 # complete derived attributes, if required
438 1222 ( my $drv_class = $dbh->{ImplementorClass} ) =~ s/::db$//;
439 1222 my $drv_prefix = DBI->driver_prefix($drv_class);
440 1222 my $valid_attrs = $drv_prefix . "valid_attrs";
441 1222 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 1222 ▶ ( 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
63051082
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 1222 $dbh->{sql_meta} = {};
448 1222 $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 1222 my $drv_pfx_meta = $drv_prefix . "meta";
456 $dbh->{sql_init_order} = {
457 0 => [qw( Profile RaiseError PrintError AutoCommit )],
458 1222 ▶ 90 => [ "sql_meta", $dbh->{$drv_pfx_meta} ? $dbh->{$drv_pfx_meta} : () ],
Branch: 1 branch
BranchTrueFalseTotal
$dbh->{$drv_pfx_meta} ? : 1028 194 1222
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 1222 my @comp_attrs = qw(valid_attrs version readonly_attrs);
467  
468 1222 ▶ 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"}) 1028 194 1222
Condition66%2/3
exists $dbh->{$drv_pfx_meta} and not $dbh->{"sql_engine_in_gofer"}
!ll&&!rl&&r
19401028
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 1028 my $attr = $dbh->{$drv_pfx_meta};
471 defined $attr
472 and defined $dbh->{$valid_attrs}
473 and !defined $dbh->{$valid_attrs}{$attr}
474 1028 ▶ 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 1028 1028
Condition33%2/6
defined $attr and defined $dbh->{$valid_attrs} and not defined $dbh->{$valid_attrs}{$attr}
!ll&&!rl&&r
010280
defined $attr and defined $dbh->{$valid_attrs}
!ll&&!rl&&r
001028
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 1028 my %h;
477 1028 tie %h, "DBI::DBD::SqlEngine::TieTables", $dbh;
478 1028 $dbh->{$attr} = \%h;
479  
480 1028 push @comp_attrs, "meta";
481 }
482  
483 1222 foreach my $comp_attr (@comp_attrs)
484 {
485 4694 my $attr = $drv_prefix . $comp_attr;
486 defined $dbh->{$valid_attrs}
487 and !defined $dbh->{$valid_attrs}{$attr}
488 4694 ▶ 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 4694 4694
Condition33%1/3
defined $dbh->{$valid_attrs} and not defined $dbh->{$valid_attrs}{$attr}
!ll&&!rl&&r
046940
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 4694 ▶ 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 4694 4694
Condition33%1/3
defined $dbh->{$ro_attrs} and not defined $dbh->{$ro_attrs}{$attr}
!ll&&!rl&&r
046940
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 2444 return $dbh;
496 } # init_default_attributes
497  
498 sub init_done
499 1222 ▶{
Subroutine init_done: called CC=2 SCAR=7.1
500 1222 ▶ 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"} 1222 0 1222
501 1222 delete $_[0]->{sql_valid_attrs}->{sql_init_phase};
502 1222 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 7482 ▶{
Subroutine FETCH: called CC=12 SCAR=46.5
567 7482 my ( $dbh, $attrib ) = @_;
568 7482 ▶ $attrib eq "AutoCommit"
Branch: 1 branch
BranchTrueFalseTotal
$attrib eq "AutoCommit" and return 1 0 7482 7482
569 and return 1;
570  
571 # Driver private attributes are lower cased
572 7482 ▶ if ( $attrib eq ( lc $attrib ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($attrib eq lc $attrib) 0 7482 7482
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 7482 return $dbh->SUPER::FETCH($attrib);
602 } # FETCH
603  
604 sub validate_STORE_attr
605 8607 ▶{
Subroutine validate_STORE_attr: called CC=7 SCAR=20.6
606 8607 my ( $dbh, $attrib, $value ) = @_;
607  
608 8607 ▶ 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 8607 8607
Condition55%5/9
$attrib eq "sql_identifier_case" || $attrib eq "sql_quoted_identifier_case" and $value < 1 || $value > 4
!ll&&!rl&&r
8539680
$attrib eq "sql_identifier_case" or $attrib eq "sql_quoted_identifier_case"
l!l&&r!l&&!r
6808539
$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 8607 ( my $drv_class = $dbh->{ImplementorClass} ) =~ s/::db$//;
616 8607 my $drv_prefix = DBI->driver_prefix($drv_class);
617  
618 exists $dbh->{ $drv_prefix . "meta" }
619 8607 ▶ 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 8603 8607
Condition100%3/3
exists $$dbh{$drv_prefix . 'meta'} and $attrib eq $$dbh{$drv_prefix . 'meta'}
!ll&&!rl&&r
112074834
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 8607 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 20563 ▶{
Subroutine STORE: called CC=14 SCAR=28.2
635 20563 my ( $dbh, $attrib, $value ) = @_;
636  
637 20563 ▶ if ( $attrib eq "AutoCommit" )
Branch: 1 branch
BranchTrueFalseTotal
if ($attrib eq "AutoCommit") 1586 18977 20563
638 {
639 1586 ▶ $value and return 1; # is already set
Branch: 1 branch
BranchTrueFalseTotal
$value and return 1 1586 0 1586
640 0 croak "Can't disable AutoCommit";
641 }
642  
643 18977 ▶ if ( $attrib eq lc $attrib )
Branch: 1 branch
BranchTrueFalseTotal
if ($attrib eq lc $attrib) 8607 10370 18977
644 {
645 # Driver private attributes are lower cased
646  
647 8607 ( $attrib, $value ) = $dbh->func( $attrib, $value, "validate_STORE_attr" );
648 8607 ▶ $attrib or return;
Branch: 1 branch
BranchTrueFalseTotal
$attrib or return 8607 0 8607
649  
650 8607 my $attr_prefix;
651 8607 ▶ $attrib =~ m/^([a-z]+_)/ and $attr_prefix = $1;
Branch: 1 branch
BranchTrueFalseTotal
$attrib =~ /^([a-z]+_)/ and $attr_prefix = $1 8607 0 8607
652 8607 ▶ unless ($attr_prefix)
Branch: 1 branch
BranchTrueFalseTotal
unless ($attr_prefix) 0 8607 8607
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 8607 my $valid_attrs = $attr_prefix . "valid_attrs";
659 8607 my $ro_attrs = $attr_prefix . "readonly_attrs";
660  
661 exists $dbh->{$valid_attrs}
662 8607 ▶ 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}'")) 4934 3673 8607
Condition80%4/5
exists $dbh->{$valid_attrs} && ($dbh->{$valid_attrs}{$attrib} || (return $dbh->set_err($DBI::stderr, "Invalid attribute '${attrib}'")))
!ll
367349340
$dbh->{$valid_attrs}{$attrib} or return $dbh->set_err($DBI::stderr, "Invalid attribute '${attrib}'")
l!l
49304
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 8603 ▶ 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 8603 8603
Condition50%3/6
exists $dbh->{$ro_attrs} and $dbh->{$ro_attrs}{$attrib} and defined $dbh->{$attrib}
!ll&&!rl&&r
860300
exists $dbh->{$ro_attrs} and $dbh->{$ro_attrs}{$attrib}
!ll&&!rl&&r
367349300
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 8603 ▶ if ( $attrib eq "sql_meta" )
Branch: 1 branch
BranchTrueFalseTotal
if ($attrib eq 'sql_meta') { } 36 8567 8603
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 8567 $dbh->{$attrib} = $value;
680 }
681  
682 8603 return 1;
683 }
684  
685 10370 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 40 ▶ 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 37 215 252
735 215 ▶ $b->isa($a) and return 1;
Branch: 1 branch
BranchTrueFalseTotal
$b->isa($a) and return 1 17 198 215
736 198 ▶ $a->isa("DBI::DBD::SqlEngine") and return -1;
Branch: 1 branch
BranchTrueFalseTotal
$a->isa("DBI::DBD::SqlEngine") and return -1 71 127 198
737 127 ▶ $b->isa("DBI::DBD::SqlEngine") and return 1;
Branch: 1 branch
BranchTrueFalseTotal
$b->isa("DBI::DBD::SqlEngine") and return 1 44 83 127
738 83 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 38 ▶ 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 38 ▶ 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 38 ▶ 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 8 ▶ 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 8 ▶ 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 8 ▶ 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 449 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 449 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 449 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
1046 449 require Tie::Hash;
1047 449 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 449 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
1115 449 require Tie::Hash;
1116 449 our @ISA = qw(Tie::Hash);
1117  
1118 sub TIEHASH
1119 1028 ▶{
Subroutine TIEHASH: called CC=1 SCAR=0.0
1120 1028 my ( $class, $dbh ) = @_;
1121  
1122 1028 ( my $tbl_class = $dbh->{ImplementorClass} ) =~ s/::db$/::Table/;
1123 1028 my $self = bless(
1124 {
1125 dbh => $dbh,
1126 tblClass => $tbl_class,
1127 },
1128 $class
1129 );
1130 1028 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 449 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
1207 449 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
1208  
1209 449 our $imp_data_size = 0;
1210  
1211 sub bind_param ($$$;$)
1212 288 ▶{
Subroutine bind_param: called CC=13 SCAR=47.7
1213 288 my ( $sth, $pNum, $val, $attr ) = @_;
1214 288 ▶ if ( $attr && defined $val )
Branch: 1 branch
BranchTrueFalseTotal
if ($attr and defined $val) 0 288 288
Condition33%1/3
$attr and defined $val
!ll&&!rl&&r
28800
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 288 $sth->{sql_params}[ $pNum - 1 ] = $val;
1238 288 return 1;
1239 } # bind_param
1240  
1241 sub execute
1242 1002 ▶{
Subroutine execute: called CC=9 SCAR=22.8
1243 1002 my $sth = shift;
1244 1002 ▶ my $params = @_ ? ( $sth->{sql_params} = [@_] ) : $sth->{sql_params};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 8 994 1002
1245  
1246 1002 $sth->finish;
1247 1002 my $stmt = $sth->{sql_stmt};
1248  
1249 # must not proved when already executed - SQL::Statement modifies
1250 # received params
1251 1002 ▶ unless ( $sth->{sql_params_checked}++ )
Branch: 1 branch
BranchTrueFalseTotal
unless ($sth->{"sql_params_checked"}++) 1002 0 1002
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 1002 ▶ unless ( ( my $req_prm = $stmt->params() ) == ( my $nparm = @$params ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ((my $req_prm = $stmt->params) == (my $nparm = @$params)) 0 1002 1002
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 1002 my @err;
1264 my $result;
1265 1002 eval {
1266 1002 ▶ local $SIG{__WARN__} = sub { push @err, @_ };
Subroutine __ANON__: called CC=1 SCAR=0.0
1267 1002 $result = $stmt->execute( $sth, $params );
1268 };
1269 1002 ▶ unless ( defined $result )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $result) 56 946 1002
1270 {
1271 56 ▶ $sth->set_err( $DBI::stderr, $@ || $stmt->{errstr} || $err[0] );
Condition33%2/6
$@ || $stmt->{'errstr'} || $err[0]
l!l&&r!l&&!r
5600
$@ or $stmt->{"errstr"}
l!l&&r!l&&!r
5600
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 56 return;
1273 }
1274  
1275 946 ▶ if ( $stmt->{NUM_OF_FIELDS} )
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->{"NUM_OF_FIELDS"}) 218 728 946
1276 { # is a SELECT statement
1277 218 $sth->STORE( Active => 1 );
1278 $sth->FETCH("NUM_OF_FIELDS")
1279 218 ▶ 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"}) 148 70 218
1280 }
1281 946 return $result;
1282 } # execute
1283  
1284 sub finish
1285 1845 ▶{
Subroutine finish: called CC=1 SCAR=0.0
1286 1845 my $sth = $_[0];
1287 1845 $sth->SUPER::STORE( Active => 0 );
1288 1845 delete $sth->{sql_stmt}{data};
1289 1845 return 1;
1290 } # finish
1291  
1292 sub fetch ($)
1293 726 ▶{
Subroutine fetch: called CC=7 SCAR=20.2
1294 726 my $sth = $_[0];
1295 726 my $data = $sth->{sql_stmt}{data};
1296 726 ▶ if ( !$data || ref $data ne "ARRAY" )
Branch: 1 branch
BranchTrueFalseTotal
if (not $data or ref $data ne "ARRAY") 114 612 726
Condition66%2/3
not $data or ref $data ne "ARRAY"
l!l&&r!l&&!r
1140612
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
1297 {
1298 114 $sth->set_err(
1299 $DBI::stderr,
1300 "Attempt to fetch row without a preceding execute () call or from a non-SELECT statement"
1301 );
1302 114 return;
1303 }
1304 612 my $dav = shift @$data;
1305 612 ▶ unless ($dav)
Branch: 1 branch
BranchTrueFalseTotal
unless ($dav) 200 412 612
1306 {
1307 200 $sth->finish;
1308 200 return;
1309 }
1310 412 ▶ if ( $sth->FETCH("ChopBlanks") ) # XXX: (TODO) Only chop on CHAR fields,
Branch: 1 branch
BranchTrueFalseTotal
if ($sth->FETCH("ChopBlanks")) 0 412 412
1311 { # not on VARCHAR or NUMERIC (see DBI docs)
1312 0 ▶ $_ && $_ =~ s/ +$// for @$dav;
Branch: 1 branch
BranchTrueFalseTotal
$_ and $_ =~ s/ +$// 0 0 0
1313 }
1314 412 return $sth->_set_fbav($dav);
1315 } # fetch
1316  
1317 449 ▶no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
1318 449 *fetchrow_arrayref = \&fetch;
1319  
1320 449 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
1321  
1322 sub sql_get_colnames
1323 3803 ▶{
Subroutine sql_get_colnames: called CC=9 SCAR=28.5
1324 3803 my $sth = $_[0];
1325 # Being a bit dirty here, as neither SQL::Statement::Structure nor
1326 # DBI::SQL::Nano::Statement_ does not offer an interface to the
1327 # required data
1328 3803 my @colnames;
1329 3803 ▶ 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'}) { } 1416 2387 3803
elsif ($sth->{'sql_stmt'}->isa('SQL::Statement')) { } 0 2387 2387
Condition66%2/3
$sth->{"sql_stmt"}{"NAME"} and "ARRAY" eq ref $sth->{"sql_stmt"}{"NAME"}
!ll&&!rl&&r
238701416
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
1330 {
1331 1416 @colnames = @{ $sth->{sql_stmt}->{NAME} };
1332 }
1333 elsif ( $sth->{sql_stmt}->isa('SQL::Statement') )
1334 {
1335 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
1336 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
1337 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
1338 }
1339 3803 ▶ @colnames = $sth->{sql_stmt}->column_names() unless (@colnames);
Branch: 1 branch
BranchTrueFalseTotal
unless @colnames 2387 1416 3803
1340  
1341 3803 ▶ @colnames = () if ( grep { m/\*/ } @colnames );
Branch: 1 branch
BranchTrueFalseTotal
if grep {/\*/;} @colnames 0 3803 3803
1342  
1343 3803 return @colnames;
1344 }
1345  
1346 sub FETCH ($$)
1347 3751 ▶{
Subroutine FETCH: called CC=7 SCAR=19.5
1348 3751 my ( $sth, $attrib ) = @_;
1349  
1350 3751 ▶ $attrib eq "NAME" and return [ $sth->sql_get_colnames() ];
Branch: 1 branch
BranchTrueFalseTotal
$attrib eq "NAME" and return [$sth->sql_get_colnames] 625 3126 3751
1351  
1352 3126 ▶ $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)] 629 2497 3126
1353 2497 ▶ $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 2493 2497
1354 2493 ▶ $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)] 625 1868 2493
1355 1868 ▶ $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 1796 1868
1356  
1357 1796 ▶ if ( $attrib eq lc $attrib )
Branch: 1 branch
BranchTrueFalseTotal
if ($attrib eq lc $attrib) 625 1171 1796
1358 {
1359 # Private driver attributes are lower cased
1360 625 return $sth->{$attrib};
1361 }
1362  
1363 # else pass up to DBI to handle
1364 1171 return $sth->SUPER::FETCH($attrib);
1365 } # FETCH
1366  
1367 sub STORE ($$$)
1368 5552 ▶{
Subroutine STORE: called CC=2 SCAR=6.9
1369 5552 my ( $sth, $attrib, $value ) = @_;
1370 5552 ▶ if ( $attrib eq lc $attrib ) # Private driver attributes are lower cased
Branch: 1 branch
BranchTrueFalseTotal
if ($attrib eq lc $attrib) 2590 2962 5552
1371 {
1372 2590 $sth->{$attrib} = $value;
1373 2590 return 1;
1374 }
1375 2962 return $sth->SUPER::STORE( $attrib, $value );
1376 } # STORE
1377  
1378 sub DESTROY ($)
1379 1358 ▶{
Subroutine DESTROY: called CC=2 SCAR=6.9
1380 1358 my $sth = shift;
1381 1358 ▶ $sth->SUPER::FETCH("Active") and $sth->finish;
Branch: 1 branch
BranchTrueFalseTotal
$sth->SUPER::FETCH("Active") and $sth->finish 14 1344 1358
1382 1358 undef $sth->{sql_stmt};
1383 1358 undef $sth->{sql_params};
1384 } # DESTROY
1385  
1386 sub rows ($)
1387 444 ▶{
Subroutine rows: called CC=1 SCAR=0.0
1388 444 return $_[0]->{sql_stmt}{NUM_OF_ROWS};
1389 } # rows
1390  
1391 # ====== TableSource ===========================================================
1392  
1393 package DBI::DBD::SqlEngine::TableSource;
1394  
1395 449 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
1396 449 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
1397  
1398 449 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
1399  
1400 sub data_sources ($;$)
1401 0 ▶{
Subroutine data_sources: not called CC=2 SCAR=17.9
1402 0 my ( $class, $drh, $attrs ) = @_;
1403 0 ▶ croak( ( ref( $_[0] ) ? ref( $_[0] ) : $_[0] ) . " must implement data_sources" );
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
1404 }
1405  
1406 sub avail_tables
1407 0 ▶{
Subroutine avail_tables: not called CC=2 SCAR=17.9
1408 0 my ( $self, $dbh ) = @_;
1409 0 ▶ croak( ( ref( $_[0] ) ? ref( $_[0] ) : $_[0] ) . " must implement avail_tables" );
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
1410 }
1411  
1412 # ====== DataSource ============================================================
1413  
1414 package DBI::DBD::SqlEngine::DataSource;
1415  
1416 449 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
1417 449 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
1418  
1419 449 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
1420  
1421 sub complete_table_name ($$;$)
1422 0 ▶{
Subroutine complete_table_name: not called CC=2 SCAR=17.9
1423 0 my ( $self, $meta, $table, $respect_case ) = @_;
1424 0 ▶ croak( ( ref( $_[0] ) ? ref( $_[0] ) : $_[0] ) . " must implement complete_table_name" );
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
1425 }
1426  
1427 sub open_data ($)
1428 0 ▶{
Subroutine open_data: not called CC=2 SCAR=17.9
1429 0 my ( $self, $meta, $attrs, $flags ) = @_;
1430 0 ▶ croak( ( ref( $_[0] ) ? ref( $_[0] ) : $_[0] ) . " must implement open_data" );
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
1431 }
1432  
1433 # ====== SQL::STATEMENT ========================================================
1434  
1435 package DBI::DBD::SqlEngine::Statement;
1436  
1437 449 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
1438 449 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
1439  
1440 449 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
1441  
1442 449 our @ISA = qw(DBI::SQL::Nano::Statement);
1443  
1444 sub open_table ($$$$$)
1445 1002 ▶{
Subroutine open_table: called CC=9 SCAR=22.1
1446 1002 my ( $self, $data, $table, $createMode, $lockMode ) = @_;
1447  
1448 1002 my $class = ref $self;
1449 1002 $class =~ s/::Statement/::Table/;
1450  
1451 1002 my $flags = {
1452 createMode => $createMode,
1453 lockMode => $lockMode,
1454 };
1455 1002 ▶ $self->{command} eq "DROP" and $flags->{dropMode} = 1;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"command"} eq "DROP" and $flags->{"dropMode"} = 1 234 768 1002
1456  
1457 1002 ▶ 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}'") 982 0 982
1458 or croak "Cannot find appropriate meta for table '$table'";
1459  
1460 982 ▶ 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 980 982
1461  
1462 # because column name mapping is initialized in constructor ...
1463 # and therefore specific opening operations might be done before
1464 # reaching DBI::DBD::SqlEngine::Table->new(), we need to intercept
1465 # ReadOnly here
1466 982 ▶ my $write_op = $createMode || $lockMode || $flags->{dropMode};
Condition83%5/6
$createMode || $lockMode || $flags->{'dropMode'}
l!l&&r!l&&!r
7560226
$createMode or $lockMode
l!l&&r!l&&!r
131625226
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
1467 982 ▶ if ($write_op)
Branch: 1 branch
BranchTrueFalseTotal
if ($write_op) 756 226 982
1468 {
1469 $table_meta->{readonly}
1470 and croak "Table '$table' is marked readonly - "
1471 . $self->{command}
1472 756 ▶ . ( $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 732 756
$lockMode ? : 24 0 24
1473 . " command forbidden";
1474 }
1475  
1476 958 return $class->new( $data, { table => $table }, $flags );
1477 } # open_table
1478  
1479 # ====== SQL::TABLE ============================================================
1480  
1481 package DBI::DBD::SqlEngine::Table;
1482  
1483 449 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
1484 449 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
1485  
1486 449 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
1487  
1488 449 our @ISA = qw(DBI::SQL::Nano::Table);
1489  
1490 sub bootstrap_table_meta
1491 856 ▶{
Subroutine bootstrap_table_meta: called CC=5 SCAR=16.1
1492 856 my ( $self, $dbh, $meta, $table ) = @_;
1493  
1494 defined $dbh->{ReadOnly}
1495 and !defined( $meta->{readonly} )
1496 856 ▶ and $meta->{readonly} = $dbh->{ReadOnly};
Branch: 1 branch
BranchTrueFalseTotal
defined $dbh->{"ReadOnly"} and not defined $meta->{"readonly"} and $meta->{"readonly"} = $dbh->{"ReadOnly"} 16 840 856
Condition100%3/3
defined $dbh->{"ReadOnly"} and not defined $meta->{"readonly"}
!ll&&!rl&&r
8241616
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
1497 defined $meta->{sql_identifier_case}
1498 856 ▶ 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"} 42 814 856
1499  
1500 856 ▶ 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"} 34 822 856
1501  
1502 856 $meta;
1503 }
1504  
1505 sub init_table_meta
1506 662 ▶{
Subroutine init_table_meta: called CC=1 SCAR=0.0
1507 662 my ( $self, $dbh, $meta, $table ) = @_ if (0);
1508  
1509 662 return;
1510 } # init_table_meta
1511  
1512 sub get_table_meta ($$$;$)
1513 2244 ▶{
Subroutine get_table_meta: called CC=13 SCAR=25.7
1514 2244 my ( $self, $dbh, $table, $respect_case, @other ) = @_;
1515 2244 ▶ unless ( defined $respect_case )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $respect_case) 2032 212 2244
1516 {
1517 2032 $respect_case = 0;
1518 2032 ▶ $table =~ s/^\"// and $respect_case = 1; # handle quoted identifiers
Branch: 1 branch
BranchTrueFalseTotal
$table =~ s/^\"// and $respect_case = 1 0 2032 2032
1519 2032 $table =~ s/\"$//;
1520 }
1521  
1522 2244 ▶ unless ($respect_case)
Branch: 1 branch
BranchTrueFalseTotal
unless ($respect_case) 2208 36 2244
1523 {
1524 2208 ▶ 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 1722 2208
1525 }
1526  
1527 2244 my $meta = {};
1528 2244 ▶ 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} 1472 772 2244
1529  
1530 do_initialize:
1531 2278 ▶ unless ( $meta->{initialized} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($meta->{"initialized"}) 844 1434 2278
1532 {
1533 844 $self->bootstrap_table_meta( $dbh, $meta, $table, @other );
1534 844 ▶ $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 712 128 840
1535 or return;
1536  
1537 712 ▶ 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 518 712
Condition100%3/3
defined $meta->{"table_name"} and $table ne $meta->{"table_name"}
!ll&&!rl&&r
4514194
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
1538 {
1539 194 $dbh->{sql_meta_map}{$table} = $meta->{table_name};
1540 194 $table = $meta->{table_name};
1541 }
1542  
1543 # now we know a bit more - let's check if user can't use consequent spelling
1544 # XXX add know issue about reset sql_identifier_case here ...
1545 712 ▶ if ( defined $dbh->{sql_meta}{$table} )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dbh->{"sql_meta"}{$table}) 70 642 712
1546 {
1547 70 $meta = delete $dbh->{sql_meta}{$table}; # avoid endless loop
1548 $meta->{initialized}
1549 70 ▶ or goto do_initialize;
Branch: 1 branch
BranchTrueFalseTotal
$meta->{"initialized"} or goto do_initialize 36 34 70
1550 #or $meta->{sql_data_source}->complete_table_name( $meta, $table, $respect_case, @other )
1551 #or return;
1552 }
1553  
1554 678 ▶ unless ( $dbh->{sql_meta}{$table}{initialized} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($dbh->{"sql_meta"}{$table}{"initialized"}) 678 0 678
1555 {
1556 678 $self->init_table_meta( $dbh, $meta, $table );
1557 662 $meta->{initialized} = 1;
1558 662 $dbh->{sql_meta}{$table} = $meta;
1559 }
1560 }
1561  
1562 2096 return ( $table, $meta );
1563 } # get_table_meta
1564  
1565 449 my %reset_on_modify = ();
1566 449 my %compat_map = ();
1567  
1568 sub register_reset_on_modify
1569 878 ▶{
Subroutine register_reset_on_modify: called CC=3 SCAR=11.0
1570 878 my ( $proto, $extra_resets ) = @_;
1571 878 foreach my $cv ( keys %$extra_resets )
1572 {
1573 #%reset_on_modify = ( %reset_on_modify, %$extra_resets );
1574 3097 ▶ push @{ $reset_on_modify{$cv} },
Branch: 1 branch
BranchTrueFalseTotal
ref $extra_resets->{$cv} ? : 894 2203 3097
1575 3097 ref $extra_resets->{$cv} ? @{ $extra_resets->{$cv} } : ( $extra_resets->{$cv} );
1576 }
1577 878 return;
1578 } # register_reset_on_modify
1579  
1580 sub register_compat_map
1581 878 ▶{
Subroutine register_compat_map: called CC=1 SCAR=0.0
1582 878 my ( $proto, $extra_compat_map ) = @_;
1583 878 %compat_map = ( %compat_map, %$extra_compat_map );
1584 878 return;
1585 } # register_compat_map
1586  
1587 sub get_table_meta_attr
1588 82 ▶{
Subroutine get_table_meta_attr: called CC=3 SCAR=12.5
1589 82 my ( $class, $meta, $attrib ) = @_;
1590 exists $compat_map{$attrib}
1591 82 ▶ and $attrib = $compat_map{$attrib};
Branch: 1 branch
BranchTrueFalseTotal
exists $compat_map{$attrib} and $attrib = $compat_map{$attrib} 0 82 82
1592 exists $meta->{$attrib}
1593 82 ▶ and return $meta->{$attrib};
Branch: 1 branch
BranchTrueFalseTotal
exists $meta->{$attrib} and return $meta->{$attrib} 82 0 82
1594 0 return;
1595 } # get_table_meta_attr
1596  
1597 sub set_table_meta_attr
1598 16 ▶{
Subroutine set_table_meta_attr: called CC=2 SCAR=6.9
1599 16 my ( $class, $meta, $attrib, $value ) = @_;
1600 exists $compat_map{$attrib}
1601 16 ▶ and $attrib = $compat_map{$attrib};
Branch: 1 branch
BranchTrueFalseTotal
exists $compat_map{$attrib} and $attrib = $compat_map{$attrib} 8 8 16
1602 16 $class->table_meta_attr_changed( $meta, $attrib, $value );
1603 16 $meta->{$attrib} = $value;
1604 } # set_table_meta_attr
1605  
1606 sub table_meta_attr_changed
1607 16 ▶{
Subroutine table_meta_attr_changed: called CC=3 SCAR=12.5
1608 16 my ( $class, $meta, $attrib, $value ) = @_;
1609 defined $reset_on_modify{$attrib}
1610 16 and delete @$meta{ @{ $reset_on_modify{$attrib} } }
1611 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
1612 } # table_meta_attr_changed
1613  
1614 sub open_data
1615 958 ▶{
Subroutine open_data: called CC=2 SCAR=7.0
1616 958 my ( $self, $meta, $attrs, $flags ) = @_;
1617  
1618 $meta->{sql_data_source}
1619 958 ▶ 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') 958 0 958
1620 958 $meta->{sql_data_source}->open_data( $meta, $attrs, $flags );
1621  
1622 853 return;
1623 } # open_data
1624  
1625 # ====== SQL::Eval API =========================================================
1626  
1627 sub new
1628 958 ▶{
Subroutine new: called CC=5 SCAR=16.3
1629 958 my ( $className, $data, $attrs, $flags ) = @_;
1630 958 my $dbh = $data->{Database};
1631  
1632 958 ▶ 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"}']) 958 0 958
1633 or croak "Cannot find appropriate table '$attrs->{table}'";
1634 958 $attrs->{table} = $tblnm;
1635  
1636 # Being a bit dirty here, as SQL::Statement::Structure does not offer
1637 # me an interface to the data I want
1638 $flags->{createMode} && $data->{sql_stmt}{table_defs}
1639 958 ▶ 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 958 958
Condition66%2/3
$flags->{"createMode"} and $data->{"sql_stmt"}{"table_defs"}
!ll&&!rl&&r
8271310
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
1640  
1641 # open_file must be called before inherited new is invoked
1642 # because column name mapping is initialized in constructor ...
1643 958 $className->open_data( $meta, $attrs, $flags );
1644  
1645 my $tbl = {
1646 853 ▶ %{$attrs},
Condition100%2/2
$meta->{'col_names'} || []
l!l
698155
MC/DC100%1/1
$meta->{'col_names'} || []
$meta->{'col_names'}
Truth table100%2/2
A
A= $meta->{'col_names'}
Aresult
11
00
1647 meta => $meta,
1648 853 col_names => $meta->{col_names} || [],
1649 };
1650 853 return $className->SUPER::new($tbl);
1651 } # new
1652  
1653 sub DESTROY
1654 853 ▶{
Subroutine DESTROY: called CC=2 SCAR=6.9
1655 853 my $self = shift;
1656 853 my $meta = $self->{meta};
1657 853 ▶ $self->{row} and undef $self->{row};
Branch: 1 branch
BranchTrueFalseTotal
$self->{"row"} and undef $self->{"row"} 36 817 853
1658 ()
1659 853 }
1660  
1661 449 1;
1662  
1663 =pod
1664  
1665 =head1 NAME
1666  
1667 DBI::DBD::SqlEngine - Base class for DBI drivers without their own SQL engine
1668  
1669 =head1 SYNOPSIS
1670  
1671 package DBD::myDriver;
1672  
1673 use base qw(DBI::DBD::SqlEngine);
1674  
1675 sub driver {
1676 ...
1677 my $drh = $proto->SUPER::driver ($attr);
1678 ...
1679 return $drh->{class};
1680 }
1681  
1682 package DBD::myDriver::dr;
1683  
1684 our @ISA = qw(DBI::DBD::SqlEngine::dr);
1685  
1686 sub data_sources { ... }
1687 ...
1688  
1689 package DBD::myDriver::db;
1690  
1691 our @ISA = qw(DBI::DBD::SqlEngine::db);
1692  
1693 sub init_valid_attributes { ... }
1694 sub init_default_attributes { ... }
1695 sub set_versions { ... }
1696 sub validate_STORE_attr { my ($dbh, $attrib, $value) = @_; ... }
1697 sub validate_FETCH_attr { my ($dbh, $attrib) = @_; ... }
1698 sub get_myd_versions { ... }
1699 sub get_avail_tables { ... }
1700  
1701 package DBD::myDriver::st;
1702  
1703 our @ISA = qw(DBI::DBD::SqlEngine::st);
1704  
1705 sub FETCH { ... }
1706 sub STORE { ... }
1707  
1708 package DBD::myDriver::Statement;
1709  
1710 our @ISA = qw(DBI::DBD::SqlEngine::Statement);
1711  
1712 sub open_table { ... }
1713  
1714 package DBD::myDriver::Table;
1715  
1716 our @ISA = qw(DBI::DBD::SqlEngine::Table);
1717  
1718 sub new { ... }
1719  
1720 =head1 DESCRIPTION
1721  
1722 DBI::DBD::SqlEngine abstracts the usage of SQL engines from the
1723 DBD. DBD authors can concentrate on the data retrieval they want to
1724 provide.
1725  
1726 It is strongly recommended that you read L<DBD::File::Developers> and
1727 L<DBD::File::Roadmap>, because many of the DBD::File API is provided
1728 by DBI::DBD::SqlEngine.
1729  
1730 Currently the API of DBI::DBD::SqlEngine is experimental and will
1731 likely change in the near future to provide the table meta data basics
1732 like DBD::File.
1733  
1734 DBI::DBD::SqlEngine expects that any driver in inheritance chain has
1735 a L<DBI prefix|DBI::DBD/The_database_handle_constructor>.
1736  
1737 =head2 Metadata
1738  
1739 The following attributes are handled by DBI itself and not by
1740 DBI::DBD::SqlEngine, thus they all work as expected:
1741  
1742 Active
1743 ActiveKids
1744 CachedKids
1745 CompatMode (Not used)
1746 InactiveDestroy
1747 AutoInactiveDestroy
1748 Kids
1749 PrintError
1750 RaiseError
1751 Warn (Not used)
1752  
1753 =head3 The following DBI attributes are handled by DBI::DBD::SqlEngine:
1754  
1755 =head4 AutoCommit
1756  
1757 Always on.
1758  
1759 =head4 ChopBlanks
1760  
1761 Works.
1762  
1763 =head4 NUM_OF_FIELDS
1764  
1765 Valid after C<< $sth->execute >>.
1766  
1767 =head4 NUM_OF_PARAMS
1768  
1769 Valid after C<< $sth->prepare >>.
1770  
1771 =head4 NAME
1772  
1773 Valid after C<< $sth->execute >>; probably undef for Non-Select statements.
1774  
1775 =head4 NULLABLE
1776  
1777 Not really working, always returns an array ref of ones, as DBD::CSV
1778 does not verify input data. Valid after C<< $sth->execute >>; undef for
1779 non-select statements.
1780  
1781 =head3 The following DBI attributes and methods are not supported:
1782  
1783 =over 4
1784  
1785 =item bind_param_inout
1786  
1787 =item CursorName
1788  
1789 =item LongReadLen
1790  
1791 =item LongTruncOk
1792  
1793 =back
1794  
1795 =head3 DBI::DBD::SqlEngine specific attributes
1796  
1797 In addition to the DBI attributes, you can use the following dbh
1798 attributes:
1799  
1800 =head4 sql_engine_version
1801  
1802 Contains the module version of this driver (B<readonly>)
1803  
1804 =head4 sql_nano_version
1805  
1806 Contains the module version of DBI::SQL::Nano (B<readonly>)
1807  
1808 =head4 sql_statement_version
1809  
1810 Contains the module version of SQL::Statement, if available (B<readonly>)
1811  
1812 =head4 sql_handler
1813  
1814 Contains the SQL Statement engine, either DBI::SQL::Nano or SQL::Statement
1815 (B<readonly>).
1816  
1817 =head4 sql_parser_object
1818  
1819 Contains an instantiated instance of SQL::Parser (B<readonly>).
1820 This is filled when used first time (only when used with SQL::Statement).
1821  
1822 =head4 sql_sponge_driver
1823  
1824 Contains an internally used DBD::Sponge handle (B<readonly>).
1825  
1826 =head4 sql_valid_attrs
1827  
1828 Contains the list of valid attributes for each DBI::DBD::SqlEngine based
1829 driver (B<readonly>).
1830  
1831 =head4 sql_readonly_attrs
1832  
1833 Contains the list of those attributes which are readonly (B<readonly>).
1834  
1835 =head4 sql_identifier_case
1836  
1837 Contains how DBI::DBD::SqlEngine deals with non-quoted SQL identifiers:
1838  
1839 * SQL_IC_UPPER (1) means all identifiers are internally converted
1840 into upper-cased pendants
1841 * SQL_IC_LOWER (2) means all identifiers are internally converted
1842 into lower-cased pendants
1843 * SQL_IC_MIXED (4) means all identifiers are taken as they are
1844  
1845 These conversions happen if (and only if) no existing identifier matches.
1846 Once existing identifier is used as known.
1847  
1848 The SQL statement execution classes doesn't have to care, so don't expect
1849 C<sql_identifier_case> affects column names in statements like
1850  
1851 SELECT * FROM foo
1852  
1853 =head4 sql_quoted_identifier_case
1854  
1855 Contains how DBI::DBD::SqlEngine deals with quoted SQL identifiers
1856 (B<readonly>). It's fixated to SQL_IC_SENSITIVE (3), which is interpreted
1857 as SQL_IC_MIXED.
1858  
1859 =head4 sql_flags
1860  
1861 Contains additional flags to instantiate an SQL::Parser. Because an
1862 SQL::Parser is instantiated only once, it's recommended to set this flag
1863 before any statement is executed.
1864  
1865 =head4 sql_dialect
1866  
1867 Controls the dialect understood by SQL::Parser. Possible values (delivery
1868 state of SQL::Statement):
1869  
1870 * ANSI
1871 * CSV
1872 * AnyData
1873  
1874 Defaults to "CSV". Because an SQL::Parser is instantiated only once and
1875 SQL::Parser doesn't allow one to modify the dialect once instantiated,
1876 it's strongly recommended to set this flag before any statement is
1877 executed (best place is connect attribute hash).
1878  
1879 =head4 sql_engine_in_gofer
1880  
1881 This value has a true value in case of this driver is operated via
1882 L<DBD::Gofer>. The impact of being operated via Gofer is a read-only
1883 driver (not read-only databases!), so you cannot modify any attributes
1884 later - neither any table settings. B<But> you won't get an error in
1885 cases you modify table attributes, so please carefully watch
1886 C<sql_engine_in_gofer>.
1887  
1888 =head4 sql_meta
1889  
1890 Private data area which contains information about the tables this
1891 module handles. Table meta data might not be available until the
1892 table has been accessed for the first time e.g., by issuing a select
1893 on it however it is possible to pre-initialize attributes for each table
1894 you use.
1895  
1896 DBI::DBD::SqlEngine recognizes the (public) attributes C<col_names>,
1897 C<table_name>, C<readonly>, C<sql_data_source> and C<sql_identifier_case>.
1898 Be very careful when modifying attributes you do not know, the consequence
1899 might be a destroyed or corrupted table.
1900  
1901 While C<sql_meta> is a private and readonly attribute (which means, you
1902 cannot modify it's values), derived drivers might provide restricted
1903 write access through another attribute. Well known accessors are
1904 C<csv_tables> for L<DBD::CSV>, C<ad_tables> for L<DBD::AnyData> and
1905 C<dbm_tables> for L<DBD::DBM>.
1906  
1907 =head4 sql_table_source
1908  
1909 Controls the class which will be used for fetching available tables.
1910  
1911 See L</DBI::DBD::SqlEngine::TableSource> for details.
1912  
1913 =head4 sql_data_source
1914  
1915 Contains the class name to be used for opening tables.
1916  
1917 See L</DBI::DBD::SqlEngine::DataSource> for details.
1918  
1919 =head2 Driver private methods
1920  
1921 =head3 Default DBI methods
1922  
1923 =head4 data_sources
1924  
1925 The C<data_sources> method returns a list of subdirectories of the current
1926 directory in the form "dbi:CSV:f_dir=$dirname".
1927  
1928 If you want to read the subdirectories of another directory, use
1929  
1930 my ($drh) = DBI->install_driver ("CSV");
1931 my (@list) = $drh->data_sources (f_dir => "/usr/local/csv_data");
1932  
1933 =head4 list_tables
1934  
1935 This method returns a list of file names inside $dbh->{f_dir}.
1936 Example:
1937  
1938 my ($dbh) = DBI->connect ("dbi:CSV:f_dir=/usr/local/csv_data");
1939 my (@list) = $dbh->func ("list_tables");
1940  
1941 Note that the list includes all files contained in the directory, even
1942 those that have non-valid table names, from the view of SQL.
1943  
1944 =head3 Additional methods
1945  
1946 The following methods are only available via their documented name when
1947 DBI::DBD::SQlEngine is used directly. Because this is only reasonable for
1948 testing purposes, the real names must be used instead. Those names can be
1949 computed by replacing the C<sql_> in the method name with the driver prefix.
1950  
1951 =head4 sql_versions
1952  
1953 Signature:
1954  
1955 sub sql_versions (;$) {
1956 my ($table_name) = @_;
1957 $table_name ||= ".";
1958 ...
1959 }
1960  
1961 Returns the versions of the driver, including the DBI version, the Perl
1962 version, DBI::PurePerl version (if DBI::PurePerl is active) and the version
1963 of the SQL engine in use.
1964  
1965 my $dbh = DBI->connect ("dbi:File:");
1966 my $sql_versions = $dbh->func( "sql_versions" );
1967 print "$sql_versions\n";
1968 __END__
1969 # DBI::DBD::SqlEngine 0.05 using SQL::Statement 1.402
1970 # DBI 1.623
1971 # OS netbsd (6.99.12)
1972 # Perl 5.016002 (x86_64-netbsd-thread-multi)
1973  
1974 Called in list context, sql_versions will return an array containing each
1975 line as single entry.
1976  
1977 Some drivers might use the optional (table name) argument and modify
1978 version information related to the table (e.g. DBD::DBM provides storage
1979 backend information for the requested table, when it has a table name).
1980  
1981 =head4 sql_get_meta
1982  
1983 Signature:
1984  
1985 sub sql_get_meta ($$) {
1986 my ($table_name, $attrib) = @_;
1987 ...
1988 }
1989  
1990 Returns the value of a meta attribute set for a specific table, if any.
1991 See L<sql_meta> for the possible attributes.
1992  
1993 A table name of C<"."> (single dot) is interpreted as the default table.
1994 This will retrieve the appropriate attribute globally from the dbh.
1995 This has the same restrictions as C<< $dbh->{$attrib} >>.
1996  
1997 =head4 sql_set_meta
1998  
1999 Signature:
2000  
2001 sub sql_set_meta ($$$) {
2002 my ($table_name, $attrib, $value) = @_;
2003 ...
2004 }
2005  
2006 Sets the value of a meta attribute set for a specific table.
2007 See L<sql_meta> for the possible attributes.
2008  
2009 A table name of C<"."> (single dot) is interpreted as the default table
2010 which will set the specified attribute globally for the dbh.
2011 This has the same restrictions as C<< $dbh->{$attrib} = $value >>.
2012  
2013 =head4 sql_clear_meta
2014  
2015 Signature:
2016  
2017 sub sql_clear_meta ($) {
2018 my ($table_name) = @_;
2019 ...
2020 }
2021  
2022 Clears the table specific meta information in the private storage of the
2023 dbh.
2024  
2025 =head2 Extensibility
2026  
2027 =head3 DBI::DBD::SqlEngine::TableSource
2028  
2029 Provides data sources and table information on database driver and database
2030 handle level.
2031  
2032 package DBI::DBD::SqlEngine::TableSource;
2033  
2034 sub data_sources ($;$) {
2035 my ($class, $drh, $attrs) = @_;
2036 ...
2037 }
2038  
2039 sub avail_tables {
2040 my ( $class, $drh ) = @_;
2041 ...
2042 }
2043  
2044 The C<data_sources> method is called when the user invokes any of the
2045 following:
2046  
2047 @ary = DBI->data_sources ($driver);
2048 @ary = DBI->data_sources ($driver, \%attr);
2049  
2050 @ary = $dbh->data_sources ();
2051 @ary = $dbh->data_sources (\%attr);
2052  
2053 The C<avail_tables> method is called when the user invokes any of the
2054 following:
2055  
2056 @names = $dbh->tables ($catalog, $schema, $table, $type);
2057  
2058 $sth = $dbh->table_info ($catalog, $schema, $table, $type);
2059 $sth = $dbh->table_info ($catalog, $schema, $table, $type, \%attr);
2060  
2061 $dbh->func ("list_tables");
2062  
2063 Every time where an C<\%attr> argument can be specified, this C<\%attr>
2064 object's C<sql_table_source> attribute is preferred over the C<$dbh>
2065 attribute or the driver default, e.g.
2066  
2067 @ary = DBI->data_sources ("dbi:CSV:", {
2068 f_dir => "/your/csv/tables",
2069 # note: this class doesn't comes with DBI
2070 sql_table_source => "DBD::File::Archive::Tar::TableSource",
2071 # scan tarballs instead of directories
2072 });
2073  
2074 When you're going to implement such a DBD::File::Archive::Tar::TableSource
2075 class, remember to add correct attributes (including C<sql_table_source>
2076 and C<sql_data_source>) to the returned DSN's.
2077  
2078 =head3 DBI::DBD::SqlEngine::DataSource
2079  
2080 Provides base functionality for dealing with tables. It is primarily
2081 designed for allowing transparent access to files on disk or already
2082 opened (file-)streams (e.g. for DBD::CSV).
2083  
2084 Derived classes shall be restricted to similar functionality, too (e.g.
2085 opening streams from an archive, transparently compress/uncompress
2086 log files before parsing them,
2087  
2088 package DBI::DBD::SqlEngine::DataSource;
2089  
2090 sub complete_table_name ($$;$) {
2091 my ($self, $meta, $table, $respect_case) = @_;
2092 ...
2093 }
2094  
2095 The method C<complete_table_name> is called when first setting up the
2096 I<meta information> for a table:
2097  
2098 "SELECT user.id, user.name, user.shell FROM user WHERE ..."
2099  
2100 results in opening the table C<user>. First step of the table open
2101 process is completing the name. Let's imagine you're having a L<DBD::CSV>
2102 handle with following settings:
2103  
2104 $dbh->{sql_identifier_case} = SQL_IC_LOWER;
2105 $dbh->{f_ext} = '.lst';
2106 $dbh->{f_dir} = '/data/web/adrmgr';
2107  
2108 Those settings will result in looking for files matching
2109 C<[Uu][Ss][Ee][Rr](\.lst)?$> in C</data/web/adrmgr/>. The scanning of the
2110 directory C</data/web/adrmgr/> and the pattern match check will be done
2111 in C<DBD::File::DataSource::File> by the C<complete_table_name> method.
2112  
2113 If you intend to provide other sources of data streams than files, in
2114 addition to provide an appropriate C<complete_table_name> method, a method
2115 to open the resource is required:
2116  
2117 package DBI::DBD::SqlEngine::DataSource;
2118  
2119 sub open_data ($) {
2120 my ($self, $meta, $attrs, $flags) = @_;
2121 ...
2122 }
2123  
2124 After the method C<open_data> has been run successfully, the table's meta
2125 information are in a state which allows the table's data accessor methods
2126 will be able to fetch/store row information. Implementation details heavily
2127 depends on the table implementation, whereby the most famous is surely
2128 L<DBD::File::Table|DBD::File/DBD::File::Table>.
2129  
2130 =head1 SQL ENGINES
2131  
2132 DBI::DBD::SqlEngine currently supports two SQL engines:
2133 L<SQL::Statement|SQL::Statement> and
2134 L<DBI::SQL::Nano::Statement_|DBI::SQL::Nano>. DBI::SQL::Nano supports a
2135 I<very> limited subset of SQL statements, but it might be faster for some
2136 very simple tasks. SQL::Statement in contrast supports a much larger subset
2137 of ANSI SQL.
2138  
2139 To use SQL::Statement, you need at least version 1.401 of
2140 SQL::Statement and the environment variable C<DBI_SQL_NANO> must not
2141 be set to a true value.
2142  
2143 =head1 SUPPORT
2144  
2145 You can find documentation for this module with the perldoc command.
2146  
2147 perldoc DBI::DBD::SqlEngine
2148  
2149 You can also look for information at:
2150  
2151 =over 4
2152  
2153 =item * RT: CPAN's request tracker
2154  
2155 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBI>
2156 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Statement>
2157  
2158 =item * CPAN Ratings
2159  
2160 L<http://cpanratings.perl.org/d/DBI>
2161  
2162 =item * Search CPAN
2163  
2164 L<http://search.cpan.org/dist/DBI/>
2165  
2166 =back
2167  
2168 =head2 Where can I go for more help?
2169  
2170 For questions about installation or usage, please ask on the
2171 dbi-dev@perl.org mailing list.
2172  
2173 If you have a bug report, patch or suggestion, please open
2174 a new report ticket on CPAN, if there is not already one for
2175 the issue you want to report. Of course, you can mail any of the
2176 module maintainers, but it is less likely to be missed if
2177 it is reported on RT.
2178  
2179 Report tickets should contain a detailed description of the bug or
2180 enhancement request you want to report and at least an easy way to
2181 verify/reproduce the issue and any supplied fix. Patches are always
2182 welcome, too.
2183  
2184 =head1 ACKNOWLEDGEMENTS
2185  
2186 Thanks to Tim Bunce, Martin Evans and H.Merijn Brand for their continued
2187 support while developing DBD::File, DBD::DBM and DBD::AnyData.
2188 Their support, hints and feedback helped to design and implement this
2189 module.
2190  
2191 =head1 AUTHOR
2192  
2193 This module is currently maintained by
2194  
2195 H.Merijn Brand < perl5 at tux.freedom.nl > and
2196 Jens Rehsack < rehsack at googlemail.com >
2197  
2198 The original authors are Jochen Wiedmann and Jeff Zucker.
2199  
2200 =head1 COPYRIGHT AND LICENSE
2201  
2202 Copyright (C) 2009-2026 by H.Merijn Brand & Jens Rehsack
2203 Copyright (C) 2004-2009 by Jeff Zucker
2204 Copyright (C) 1998-2004 by Jochen Wiedmann
2205  
2206 All rights reserved.
2207  
2208 You may freely distribute and/or modify this module under the terms of
2209 either the GNU General Public License (GPL) or the Artistic License, as
2210 specified in the Perl README file.
2211  
2212 =head1 SEE ALSO
2213  
2214 L<DBI>, L<DBD::File>, L<DBD::AnyData> and L<DBD::Sys>.
2215  
2216 =cut
« blib/lib/DBD/DBM.pm ↑ Summary blib/lib/DBI/SQL/Nano.pm »