blib/lib/DBD/DBM.pm

filter: Statementstmt 80.9% 229 / 283 Branchbran 52.4% 86 / 164 Conditioncond 38.6% 29 / 75 MC/DCmcdc 13.9% 6 / 43 Subroutinesub 81.8% 27 / 33 Podpod 0.0% 0 / 1 totaltotal 62.9% 377 / 599 CC 106 SCAR 30.5
CC
106
Cov
66%
open_data
50.4
bootstrap_table_meta
49.3
__ANON__
20.0
CRAP 21.1
« blib/lib/DBI/ProxyServer.pm ↑ Summary blib/lib/DBI/DBD/SqlEngine.pm »
1 #######################################################################
2 #
3 # DBD::DBM - a DBI driver for DBM files
4 #
5 # Copyright (c) 2004 by Jeff Zucker < jzucker AT cpan.org >
6 # Copyright (c) 2010-2013 by Jens Rehsack & H.Merijn Brand
7 #
8 # All rights reserved.
9 #
10 # You may freely distribute and/or modify this module under the terms
11 # of either the GNU General Public License (GPL) or the Artistic License,
12 # as specified in the Perl README file.
13 #
14 # USERS - see the pod at the bottom of this file
15 #
16 # DBD AUTHORS - see the comments in the code
17 #
18 #######################################################################
19 431 require 5.012;
20 431 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 431 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 #################
24 package DBD::DBM;
25 #################
26 431 ▶use base qw( DBD::File );
Subroutine BEGIN: called CC=1 SCAR=0.0
27 431 our ($drh,$methods_already_installed);
28 431 our $VERSION = '0.08';
29 431 our $ATTRIBUTION = 'DBD::DBM by Jens Rehsack';
30  
31 # no need to have driver() unless you need private methods
32 #
33 sub driver ($;$)
34 421 ▶{
Subroutine driver: called CC=3 SCAR=11.2
Pod undocumented
35 421 my ( $class, $attr ) = @_;
36 421 ▶ return $drh if ($drh);
Branch: 1 branch
BranchTrueFalseTotal
if $DBD::DBM::drh 0 421 421
37  
38 # do the real work in DBD::File
39 #
40 421 $attr->{Attribution} = 'DBD::DBM by Jens Rehsack';
41 421 $drh = $class->SUPER::driver($attr);
42  
43 # install private methods
44 #
45 # this requires that dbm_ (or foo_) be a registered prefix
46 # but you can write private methods before official registration
47 # by hacking the $dbd_prefix_registry in a private copy of DBI.pm
48 #
49 421 ▶ unless ( $methods_already_installed++ )
Branch: 1 branch
BranchTrueFalseTotal
unless ($DBD::DBM::methods_already_installed++) 421 0 421
50 {
51 421 DBD::DBM::st->install_method('dbm_schema');
52 }
53  
54 421 return $drh;
55 }
56  
57 sub CLONE
58 0 ▶{
Subroutine CLONE: not called CC=1 SCAR=6.9
59 0 undef $drh;
60 }
61  
62 431 ▶if (eval { require Params::Util; }) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require Params::Util } }) { } 431 0 431
63 431 Params::Util->import ("_CLASS");
64 } else {
65 # SPDX-SnippetBegin
66 # SPDX-SnippetCopyrightText: 2005-2012 Adam Kennedy. 2020 Jens Rehsack.
67 # SPDX-License-Identifier: Artistic-1.0-Perl
68 # SPDX-PackageName: pkg:cpan/Params-Util@1.102
69 # SPDX-Description: taken from Params::Util::PP 1.102
70 0 ▶ *_CLASS = sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
71 0 my $arg = $_[0];
72 0 ▶ return (defined $arg and not ref $arg and $arg =~ m/^[^\W\d]\w*(?:::\w+)*\z/s) ? $arg : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $arg && !ref($arg) && $arg =~ /^[^\W\d]\w*(?:::\w+)*\z/s ? : 0 0 0
Condition0%0/6
defined $arg and not ref $arg and $arg =~ /^[^\W\d]\w*(?:::\w+)*\z/s
!ll&&!rl&&r
000
defined $arg and not ref $arg
!ll&&!rl&&r
000
MC/DC0%0/3
defined $arg and not ref $arg and $arg =~ /^[^\W\d]\w*(?:::\w+)*\z/s
defined $arg not ref $arg $arg =~ /^[^\W\d]\w*(?:::\w+)*\z/s
Truth table0%0/4
A and not(B) and C
A= defined $argB= not ref $argC= $arg =~ /^[^\W\d]\w*(?:::\w+)*\z/s
ABCresult
0XX0
10X0
1100
1111
73 0 };
74 # SPDX-SnippetEnd
75 }
76  
77 #####################
78 package DBD::DBM::dr;
79 #####################
80 431 our $imp_data_size = 0;
81 431 our @ISA = qw(DBD::File::dr);
82  
83 # you could put some :dr private methods here
84  
85 # you may need to over-ride some DBD::File::dr methods here
86 # but you can probably get away with just letting it do the work
87 # in most cases
88  
89 #####################
90 package DBD::DBM::db;
91 #####################
92 431 our $imp_data_size = 0;
93 431 our @ISA = qw(DBD::File::db);
94  
95 431 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
96 431 ▶use Module::Load ();
Subroutine BEGIN: called CC=1 SCAR=0.0
97  
98 sub validate_STORE_attr
99 7483 ▶{
Subroutine validate_STORE_attr: called CC=4 SCAR=20.4
100 7483 my ( $dbh, $attrib, $value ) = @_;
101  
102 7483 ▶ if ( $attrib eq "dbm_ext" or $attrib eq "dbm_lockfile" )
Branch: 1 branch
BranchTrueFalseTotal
if ($attrib eq "dbm_ext" or $attrib eq "dbm_lockfile") 0 7483 7483
Condition33%1/3
$attrib eq "dbm_ext" or $attrib eq "dbm_lockfile"
l!l&&r!l&&!r
007483
MC/DC0%0/2
$attrib eq "dbm_ext" or $attrib eq "dbm_lockfile"
$attrib eq "dbm_ext" $attrib eq "dbm_lockfile"
Truth table33%1/3
A or B
A= $attrib eq "dbm_ext"B= $attrib eq "dbm_lockfile"
ABresult
1X1
011
000
103 {
104 0 ( my $newattrib = $attrib ) =~ s/^dbm_/f_/g;
105 0 ▶ carp "Attribute '$attrib' is depreciated, use '$newattrib' instead" if ($^W);
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 0 0
106 0 $attrib = $newattrib;
107 }
108  
109 7483 return $dbh->SUPER::validate_STORE_attr( $attrib, $value );
110 }
111  
112 sub validate_FETCH_attr
113 0 ▶{
Subroutine validate_FETCH_attr: not called CC=4 SCAR=30.0
114 0 my ( $dbh, $attrib ) = @_;
115  
116 0 ▶ if ( $attrib eq "dbm_ext" or $attrib eq "dbm_lockfile" )
Branch: 1 branch
BranchTrueFalseTotal
if ($attrib eq "dbm_ext" or $attrib eq "dbm_lockfile") 0 0 0
Condition0%0/3
$attrib eq "dbm_ext" or $attrib eq "dbm_lockfile"
l!l&&r!l&&!r
000
MC/DC0%0/2
$attrib eq "dbm_ext" or $attrib eq "dbm_lockfile"
$attrib eq "dbm_ext" $attrib eq "dbm_lockfile"
Truth table0%0/3
A or B
A= $attrib eq "dbm_ext"B= $attrib eq "dbm_lockfile"
ABresult
1X1
011
000
117 {
118 0 ( my $newattrib = $attrib ) =~ s/^dbm_/f_/g;
119 0 ▶ carp "Attribute '$attrib' is depreciated, use '$newattrib' instead" if ($^W);
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 0 0
120 0 $attrib = $newattrib;
121 }
122  
123 0 return $dbh->SUPER::validate_FETCH_attr($attrib);
124 }
125  
126 sub set_versions
127 1026 ▶{
Subroutine set_versions: called CC=1 SCAR=0.0
128 1026 my $this = $_[0];
129 1026 $this->{dbm_version} = $DBD::DBM::VERSION;
130 1026 return $this->SUPER::set_versions();
131 }
132  
133 sub init_valid_attributes
134 1026 ▶{
Subroutine init_valid_attributes: called CC=1 SCAR=0.0
135 1026 my $dbh = shift;
136  
137 # define valid private attributes
138 #
139 # attempts to set non-valid attrs in connect() or
140 # with $dbh->{attr} will throw errors
141 #
142 # the attrs here *must* start with dbm_ or foo_
143 #
144 # see the STORE methods below for how to check these attrs
145 #
146 $dbh->{dbm_valid_attrs} = {
147 1026 dbm_type => 1, # the global DBM type e.g. SDBM_File
148 dbm_mldbm => 1, # the global MLDBM serializer
149 dbm_cols => 1, # the global column names
150 dbm_version => 1, # verbose DBD::DBM version
151 dbm_store_metadata => 1, # column names, etc.
152 dbm_berkeley_flags => 1, # for BerkeleyDB
153 dbm_valid_attrs => 1, # DBD::DBM::db valid attrs
154 dbm_readonly_attrs => 1, # DBD::DBM::db r/o attrs
155 dbm_meta => 1, # DBD::DBM public access for f_meta
156 dbm_tables => 1, # DBD::DBM public access for f_meta
157 dbm_updatable_key => 1,
158 };
159 $dbh->{dbm_readonly_attrs} = {
160 1026 dbm_version => 1, # verbose DBD::DBM version
161 dbm_valid_attrs => 1, # DBD::DBM::db valid attrs
162 dbm_readonly_attrs => 1, # DBD::DBM::db r/o attrs
163 dbm_meta => 1, # DBD::DBM public access for f_meta
164 };
165  
166 1026 $dbh->{dbm_meta} = "dbm_tables";
167  
168 1026 return $dbh->SUPER::init_valid_attributes();
169 }
170  
171 sub init_default_attributes
172 2052 ▶{
Subroutine init_default_attributes: called CC=1 SCAR=0.0
173 2052 my ( $dbh, $phase ) = @_;
174  
175 2052 $dbh->SUPER::init_default_attributes($phase);
176 2052 $dbh->{f_lockfile} = '.lck';
177  
178 2052 return $dbh;
179 }
180  
181 sub get_dbm_versions
182 16 ▶{
Subroutine get_dbm_versions: called CC=8 SCAR=28.8
183 16 my ( $dbh, $table ) = @_;
184 16 ▶ $table ||= '';
Condition50%1/2
$table ||= ""
l!l
016
MC/DC0%0/1
$table ||= ""
$table
Truth table50%1/2
A
A= $table
Aresult
11
00
185  
186 16 my $meta;
187 16 my $class = $dbh->{ImplementorClass};
188 16 $class =~ s/::db$/::Table/;
189 16 ▶ $table and ( undef, $meta ) = $class->get_table_meta( $dbh, $table, 1 );
Branch: 1 branch
BranchTrueFalseTotal
$table and (undef, $meta) = $class->get_table_meta($dbh, $table, 1) 0 16 16
190 16 ▶ $meta or ( $meta = {} and $class->bootstrap_table_meta( $dbh, $meta, $table ) );
Branch: 1 branch
BranchTrueFalseTotal
$meta or $meta = {} and $class->bootstrap_table_meta($dbh, $meta, $table) 0 16 16
Condition33%2/6
$meta || ($meta = {}) && $class->bootstrap_table_meta($dbh, $meta, $table)
l!l
0160
$meta = {} and $class->bootstrap_table_meta($dbh, $meta, $table)
!ll
0160
MC/DC0%0/3
$meta || ($meta = {}) && $class->bootstrap_table_meta($dbh, $meta, $table)
$meta $meta = {} $class->bootstrap_table_meta($dbh, $meta, $table)
Truth table0%0/4
A || B and C
A= $metaB= $meta = {}C= $class->bootstrap_table_meta($dbh, $meta, $table)
ABCresult
1XX1
0111
00X0
0100
191  
192 16 my $dver;
193 16 my $dtype = $meta->{dbm_type};
194 16 eval {
195 16 $dver = $meta->{dbm_type}->VERSION();
196  
197 # *) when we're still alive here, everything went ok - no need to check for $@
198 16 $dtype .= " ($dver)";
199 };
200 16 ▶ if ( $meta->{dbm_mldbm} )
Branch: 1 branch
BranchTrueFalseTotal
if ($meta->{"dbm_mldbm"}) 0 16 16
201 {
202 0 $dtype .= ' + MLDBM';
203 0 eval {
204 0 $dver = MLDBM->VERSION();
205 0 $dtype .= " ($dver)"; # (*)
206 };
207 0 eval {
208 0 my $ser_class = "MLDBM::Serializer::" . $meta->{dbm_mldbm};
209 0 ▶ DBD::DBM::_CLASS($ser_class)
Branch: 1 branch
BranchTrueFalseTotal
&DBD::DBM::_CLASS($ser_class) or croak("Invalid dbm_mldbm '${ser_class}': expected a module name") 0 0 0
210 or croak "Invalid dbm_mldbm '$ser_class': expected a module name";
211 0 Module::Load::load $ser_class;
212 0 $dver = $ser_class->VERSION();
213 0 $dtype .= ' + ' . $ser_class; # (*)
214 0 ▶ $dver and $dtype .= " ($dver)"; # (*)
Branch: 1 branch
BranchTrueFalseTotal
$dver and $dtype .= " ($dver)" 0 0 0
215 };
216 }
217 16 return sprintf( "%s using %s", $dbh->{dbm_version}, $dtype );
218 }
219  
220 # you may need to over-ride some DBD::File::db methods here
221 # but you can probably get away with just letting it do the work
222 # in most cases
223  
224 #####################
225 package DBD::DBM::st;
226 #####################
227 431 our $imp_data_size = 0;
228 431 our @ISA = qw(DBD::File::st);
229  
230 sub FETCH
231 3818 ▶{
Subroutine FETCH: called CC=3 SCAR=11.0
232 3818 my ( $sth, $attr ) = @_;
233  
234 3818 ▶ if ( $attr eq "NULLABLE" )
Branch: 1 branch
BranchTrueFalseTotal
if ($attr eq "NULLABLE") 553 3265 3818
235 {
236 553 my @colnames = $sth->sql_get_colnames();
237  
238 # XXX only BerkeleyDB fails having NULL values for non-MLDBM databases,
239 # none accept it for key - but it requires more knowledge between
240 # queries and tables storage to return fully correct information
241 553 ▶ $attr eq "NULLABLE" and return [ map { 0 } @colnames ];
Branch: 1 branch
BranchTrueFalseTotal
$attr eq "NULLABLE" and return [map({0;} @colnames)] 553 0 553
242 }
243  
244 3265 return $sth->SUPER::FETCH($attr);
245 } # FETCH
246  
247 sub dbm_schema
248 0 ▶{
Subroutine dbm_schema: not called CC=3 SCAR=24.8
249 0 my ( $sth, $tname ) = @_;
250 0 ▶ return $sth->set_err( $DBI::stderr, 'No table name supplied!' ) unless $tname;
Branch: 1 branch
BranchTrueFalseTotal
unless $tname 0 0 0
251 my $tbl_meta = $sth->{Database}->func( $tname, "f_schema", "get_sql_engine_meta" )
252 0 ▶ or return $sth->set_err( $sth->{Database}->err(), $sth->{Database}->errstr() );
Branch: 1 branch
BranchTrueFalseTotal
my $tbl_meta = $sth->{"Database"}->func($tname, "f_schema", "get_sql_engine_meta") or return $sth->set_err($sth->{"Database"}->err, $sth->{"Database"}->errstr) 0 0 0
253 0 return $tbl_meta->{$tname}->{f_schema};
254 }
255 # you could put some :st private methods here
256  
257 # you may need to over-ride some DBD::File::st methods here
258 # but you can probably get away with just letting it do the work
259 # in most cases
260  
261 ############################
262 package DBD::DBM::Statement;
263 ############################
264  
265 431 our @ISA = qw(DBD::File::Statement);
266  
267 ########################
268 package DBD::DBM::Table;
269 ########################
270 431 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
271 431 ▶use Fcntl;
Subroutine BEGIN: called CC=1 SCAR=0.0
272 431 ▶use Module::Load ();
Subroutine BEGIN: called CC=1 SCAR=0.0
273  
274 431 our @ISA = qw(DBD::File::Table);
275  
276 431 ▶my $dirfext = $^O eq 'VMS' ? '.sdbm_dir' : '.dir';
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'VMS' ? : 0 431 431
277  
278 431 my %reset_on_modify = (
279 dbm_type => "dbm_tietype",
280 dbm_mldbm => "dbm_tietype",
281 );
282 431 __PACKAGE__->register_reset_on_modify( \%reset_on_modify );
283  
284 my %compat_map = (
285 431 ( map { $_ => "dbm_$_" } qw(type mldbm store_metadata) ),
286 dbm_ext => 'f_ext',
287 dbm_file => 'f_file',
288 dbm_lockfile => ' f_lockfile',
289 );
290 431 __PACKAGE__->register_compat_map( \%compat_map );
291  
292 sub bootstrap_table_meta
293 686 ▶{
Subroutine bootstrap_table_meta: called CC=17 SCAR=39.0
294 686 my ( $self, $dbh, $meta, $table ) = @_;
295  
296 686 ▶ $meta->{dbm_type} ||= $dbh->{dbm_type} || 'SDBM_File';
Condition80%4/5
$meta->{"dbm_type"} ||= $dbh->{"dbm_type"} || "SDBM_File"
l!l&&r!l&&!r
106760
$dbh->{'dbm_type'} || 'SDBM_File'
l!l
502174
MC/DC0%0/2
$meta->{"dbm_type"} ||= $dbh->{"dbm_type"} || "SDBM_File"
$meta->{"dbm_type"} $dbh->{'dbm_type'}
Truth table66%2/3
A ||= B
A= $meta->{"dbm_type"}B= $dbh->{'dbm_type'}
ABresult
1X1
011
000
297 686 ▶ $meta->{dbm_mldbm} ||= $dbh->{dbm_mldbm} if ( $dbh->{dbm_mldbm} );
Branch: 1 branch
BranchTrueFalseTotal
if $dbh->{"dbm_mldbm"} 0 686 686
Condition0%0/3
$meta->{"dbm_mldbm"} ||= $dbh->{"dbm_mldbm"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$meta->{"dbm_mldbm"} ||= $dbh->{"dbm_mldbm"}
$meta->{"dbm_mldbm"} $dbh->{"dbm_mldbm"}
Truth table0%0/3
A ||= B
A= $meta->{"dbm_mldbm"}B= $dbh->{"dbm_mldbm"}
ABresult
1X1
011
000
298 686 ▶ $meta->{dbm_berkeley_flags} ||= $dbh->{dbm_berkeley_flags};
Condition33%1/3
$meta->{"dbm_berkeley_flags"} ||= $dbh->{"dbm_berkeley_flags"}
l!l&&r!l&&!r
00686
MC/DC0%0/2
$meta->{"dbm_berkeley_flags"} ||= $dbh->{"dbm_berkeley_flags"}
$meta->{"dbm_berkeley_flags"} $dbh->{"dbm_berkeley_flags"}
Truth table33%1/3
A ||= B
A= $meta->{"dbm_berkeley_flags"}B= $dbh->{"dbm_berkeley_flags"}
ABresult
1X1
011
000
299  
300 686 ▶ $meta->{f_ext} //= $dbh->{f_ext};
Condition66%2/3
$meta->{"f_ext"} //= $dbh->{"f_ext"}
l!l&&r!l&&!r
100676
MC/DC50%1/2
$meta->{"f_ext"} //= $dbh->{"f_ext"}
$meta->{"f_ext"} $dbh->{"f_ext"}
Truth table66%2/3
A //= B
A= $meta->{"f_ext"}B= $dbh->{"f_ext"}
ABresult
1X1
011
000
301 686 ▶ unless ( defined( $meta->{f_ext} ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $meta->{"f_ext"}) 676 10 686
302 {
303 676 my $ext;
304 676 ▶ if ( $meta->{dbm_type} eq 'SDBM_File' or $meta->{dbm_type} eq 'ODBM_File' )
Branch: 2 branches
BranchTrueFalseTotal
if ($meta->{'dbm_type'} eq 'SDBM_File' or $meta->{'dbm_type'} eq 'ODBM_File') { } 660 16 676
elsif ($meta->{'dbm_type'} eq 'NDBM_File') { } 0 16 16
Condition66%2/3
$meta->{"dbm_type"} eq "SDBM_File" or $meta->{"dbm_type"} eq "ODBM_File"
l!l&&r!l&&!r
660016
MC/DC50%1/2
$meta->{"dbm_type"} eq "SDBM_File" or $meta->{"dbm_type"} eq "ODBM_File"
$meta->{"dbm_type"} eq "SDBM_File" $meta->{"dbm_type"} eq "ODBM_File"
Truth table66%2/3
A or B
A= $meta->{"dbm_type"} eq "SDBM_File"B= $meta->{"dbm_type"} eq "ODBM_File"
ABresult
1X1
011
000
305 {
306 660 $ext = '.pag/r';
307 }
308 elsif ( $meta->{dbm_type} eq 'NDBM_File' )
309 {
310 # XXX NDBM_File on FreeBSD (and elsewhere?) may actually be Berkeley
311 # behind the scenes and so create a single .db file.
312 0 ▶ if ( $^O =~ /bsd/i or lc($^O) eq 'darwin' )
Branch: 2 branches
BranchTrueFalseTotal
if ($^O =~ /bsd/i or lc $^O eq 'darwin') { } 0 0 0
elsif ($^O eq 'SunOS' or $^O eq 'Solaris' or $^O eq 'AIX') { } 0 0 0
Condition0%0/3
$^O =~ /bsd/i or lc $^O eq "darwin"
l!l&&r!l&&!r
000
MC/DC0%0/2
$^O =~ /bsd/i or lc $^O eq "darwin"
$^O =~ /bsd/i lc $^O eq "darwin"
Truth table0%0/3
A or B
A= $^O =~ /bsd/iB= lc $^O eq "darwin"
ABresult
1X1
011
000
313 {
314 0 $ext = '.db/r';
315 }
316 ▶ elsif ( $^O eq 'SunOS' or $^O eq 'Solaris' or $^O eq 'AIX' )
Condition0%0/6
$^O eq "SunOS" or $^O eq "Solaris" or $^O eq "AIX"
l!l&&r!l&&!r
000
$^O eq "SunOS" or $^O eq "Solaris"
l!l&&r!l&&!r
000
MC/DC0%0/3
$^O eq "SunOS" or $^O eq "Solaris" or $^O eq "AIX"
$^O eq "SunOS" $^O eq "Solaris" $^O eq "AIX"
Truth table0%0/4
A or B or C
A= $^O eq "SunOS"B= $^O eq "Solaris"C= $^O eq "AIX"
ABCresult
1XX1
01X1
0011
0000
317 {
318 0 $ext = '.pag/r'; # here it's implemented like dbm - just a bit improved
319 }
320 # else wrapped GDBM
321 }
322 676 ▶ defined($ext) and $meta->{f_ext} = $ext;
Branch: 1 branch
BranchTrueFalseTotal
defined $ext and $meta->{"f_ext"} = $ext 660 16 676
323 }
324  
325 686 $self->SUPER::bootstrap_table_meta( $dbh, $meta, $table );
326 }
327  
328 sub init_table_meta
329 560 ▶{
Subroutine init_table_meta: called CC=11 SCAR=24.8
330 560 my ( $self, $dbh, $meta, $table ) = @_;
331  
332 560 $meta->{f_dontopen} = 1;
333  
334 560 ▶ unless ( defined( $meta->{dbm_tietype} ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $meta->{"dbm_tietype"}) 530 30 560
335 {
336 530 my $tie_type = $meta->{dbm_type};
337 530 ▶ DBD::DBM::_CLASS($tie_type)
Branch: 1 branch
BranchTrueFalseTotal
&DBD::DBM::_CLASS($tie_type) or croak("Invalid dbm_type '${tie_type}': expected a module name") 514 16 530
338 or croak "Invalid dbm_type '$tie_type': expected a module name";
339 514 Module::Load::load $tie_type;
340 514 ▶ $tie_type eq 'BerkeleyDB' and $tie_type = 'BerkeleyDB::Hash';
Branch: 1 branch
BranchTrueFalseTotal
$tie_type eq "BerkeleyDB" and $tie_type = "BerkeleyDB::Hash" 0 514 514
341  
342 514 ▶ if ( $meta->{dbm_mldbm} )
Branch: 1 branch
BranchTrueFalseTotal
if ($meta->{"dbm_mldbm"}) 0 514 514
343 {
344 0 Module::Load::load "MLDBM";
345 0 $meta->{dbm_usedb} = $tie_type;
346 0 $tie_type = 'MLDBM';
347 }
348  
349 514 $meta->{dbm_tietype} = $tie_type;
350 }
351  
352 544 ▶ unless ( defined( $meta->{dbm_store_metadata} ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $meta->{"dbm_store_metadata"}) 514 30 544
353 {
354 514 my $store = $dbh->{dbm_store_metadata};
355 514 ▶ defined($store) or $store = 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $store or $store = 1 0 514 514
356 514 $meta->{dbm_store_metadata} = $store;
357 }
358  
359 544 ▶ unless ( defined( $meta->{col_names} ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $meta->{"col_names"}) 526 18 544
360 {
361 526 ▶ defined( $dbh->{dbm_cols} ) and $meta->{col_names} = $dbh->{dbm_cols};
Branch: 1 branch
BranchTrueFalseTotal
defined $dbh->{"dbm_cols"} and $meta->{"col_names"} = $dbh->{"dbm_cols"} 0 526 526
362 }
363  
364 544 ▶ unless ( defined( $meta->{dbm_updatable_key} ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $meta->{"dbm_updatable_key"}) 544 0 544
365 {
366 544 ▶ defined( $dbh->{dbm_updatable_key} ) and $meta->{dbm_updatable_key} = $dbh->{dbm_updatable_key};
Branch: 1 branch
BranchTrueFalseTotal
defined $dbh->{"dbm_updatable_key"} and $meta->{"dbm_updatable_key"} = $dbh->{"dbm_updatable_key"} 12 532 544
367 }
368  
369 544 $self->SUPER::init_table_meta( $dbh, $meta, $table );
370 }
371  
372 sub open_data
373 888 ▶{
Subroutine open_data: called CC=24 SCAR=39.2
374 888 my ( $className, $meta, $attrs, $flags ) = @_;
375 888 $className->SUPER::open_data( $meta, $attrs, $flags );
376  
377 791 ▶ unless ( $flags->{dropMode} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($flags->{"dropMode"}) 686 105 791
378 {
379 # TIEING
380 #
381 # XXX allow users to pass in a pre-created tied object
382 #
383 686 my @tie_args;
384 686 ▶ if ( $meta->{dbm_type} eq 'BerkeleyDB' )
Branch: 1 branch
BranchTrueFalseTotal
if ($meta->{'dbm_type'} eq 'BerkeleyDB') { } 0 686 686
385 {
386 0 my $DB_CREATE = BerkeleyDB::DB_CREATE();
387 0 my $DB_RDONLY = BerkeleyDB::DB_RDONLY();
388 0 my %tie_flags;
389 0 ▶ if ( my $f = $meta->{dbm_berkeley_flags} )
Branch: 1 branch
BranchTrueFalseTotal
if (my $f = $meta->{"dbm_berkeley_flags"}) 0 0 0
390 {
391 0 ▶ defined( $f->{DB_CREATE} ) and $DB_CREATE = delete $f->{DB_CREATE};
Branch: 1 branch
BranchTrueFalseTotal
defined $f->{"DB_CREATE"} and $DB_CREATE = delete $f->{"DB_CREATE"} 0 0 0
392 0 ▶ defined( $f->{DB_RDONLY} ) and $DB_RDONLY = delete $f->{DB_RDONLY};
Branch: 1 branch
BranchTrueFalseTotal
defined $f->{"DB_RDONLY"} and $DB_RDONLY = delete $f->{"DB_RDONLY"} 0 0 0
393 0 %tie_flags = %$f;
394 }
395 0 ▶ my $open_mode = $flags->{lockMode} || $flags->{createMode} ? $DB_CREATE : $DB_RDONLY;
Branch: 1 branch
BranchTrueFalseTotal
$flags->{'lockMode'} || $flags->{'createMode'} ? : 0 0 0
Condition0%0/3
$flags->{"lockMode"} or $flags->{"createMode"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$flags->{"lockMode"} or $flags->{"createMode"}
$flags->{"lockMode"} $flags->{"createMode"}
Truth table0%0/3
A or B
A= $flags->{"lockMode"}B= $flags->{"createMode"}
ABresult
1X1
011
000
396 @tie_args = (
397 -Filename => $meta->{f_fqbn},
398 0 -Flags => $open_mode,
399 %tie_flags
400 );
401 }
402 else
403 {
404 686 my $open_mode = O_RDONLY;
405 686 ▶ $flags->{lockMode} and $open_mode = O_RDWR;
Branch: 1 branch
BranchTrueFalseTotal
$flags->{"lockMode"} and $open_mode = 2 482 204 686
406 686 ▶ $flags->{createMode} and $open_mode = O_RDWR | O_CREAT | O_TRUNC;
Branch: 1 branch
BranchTrueFalseTotal
$flags->{"createMode"} and $open_mode = 578 119 567 686
407  
408 686 @tie_args = ( $meta->{f_fqbn}, $open_mode, 0666 );
409 }
410  
411 686 ▶ if ( $meta->{dbm_mldbm} )
Branch: 1 branch
BranchTrueFalseTotal
if ($meta->{"dbm_mldbm"}) 0 686 686
412 {
413 0 $MLDBM::UseDB = $meta->{dbm_usedb};
414 0 $MLDBM::Serializer = $meta->{dbm_mldbm};
415 0 ▶ DBD::DBM::_CLASS($MLDBM::Serializer)
Branch: 1 branch
BranchTrueFalseTotal
&DBD::DBM::_CLASS($MLDBM::Serializer) or croak("Invalid dbm_mldbm '$MLDBM::Serializer': expected a module name") 0 0 0
416 or croak "Invalid dbm_mldbm '${MLDBM::Serializer}': expected a module name";
417 }
418  
419 686 $meta->{hash} = {};
420 686 my $tie_class = $meta->{dbm_tietype};
421 686 eval { tie %{ $meta->{hash} }, $tie_class, @tie_args };
422 686 ▶ $@ and croak "Cannot tie(\%h $tie_class @tie_args): $@";
Branch: 1 branch
BranchTrueFalseTotal
$@ and croak("Cannot tie(%h $tie_class @tie_args): $@") 0 686 686
423 686 ▶ -f $meta->{f_fqfn} or croak( "No such file: '" . $meta->{f_fqfn} . "'" );
Branch: 1 branch
BranchTrueFalseTotal
-f $meta->{"f_fqfn"} or croak(q[No such file: '] . $meta->{"f_fqfn"} . q[']) 686 0 686
424 }
425  
426 791 ▶ unless ( $flags->{createMode} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($flags->{"createMode"}) 672 119 791
427 {
428 672 my ( $meta_data, $schema, $col_names );
429 672 ▶ if ( $meta->{dbm_store_metadata} )
Branch: 1 branch
BranchTrueFalseTotal
if ($meta->{"dbm_store_metadata"}) 672 0 672
430 {
431 672 $meta_data = $col_names = $meta->{hash}->{"_metadata \0"};
432 672 ▶ if ( $meta_data and $meta_data =~ m~<dbd_metadata>(.+)</dbd_metadata>~is )
Branch: 1 branch
BranchTrueFalseTotal
if ($meta_data and $meta_data =~ m[<dbd_metadata>(.+)</dbd_metadata>]is) 567 105 672
Condition66%2/3
$meta_data and $meta_data =~ m[<dbd_metadata>(.+)</dbd_metadata>]is
!ll&&!rl&&r
1050567
MC/DC50%1/2
$meta_data and $meta_data =~ m[<dbd_metadata>(.+)</dbd_metadata>]is
$meta_data $meta_data =~ m[<dbd_metadata>(.+)</dbd_metadata>]is
Truth table66%2/3
A and B
A= $meta_dataB= $meta_data =~ m[<dbd_metadata>(.+)</dbd_metadata>]is
ABresult
0X0
100
111
433 {
434 567 $schema = $col_names = $1;
435 567 $schema =~ s~.*<schema>(.+)</schema>.*~$1~is;
436 567 $col_names =~ s~.*<col_names>(.+)</col_names>.*~$1~is;
437 }
438 }
439 672 ▶ $col_names ||= $meta->{col_names} || [ 'k', 'v' ];
Condition80%4/5
$col_names ||= $meta->{"col_names"} || ["k", "v"]
l!l&&r!l&&!r
5671050
$meta->{'col_names'} || ['k', 'v']
l!l
5847
MC/DC0%0/2
$col_names ||= $meta->{"col_names"} || ["k", "v"]
$col_names $meta->{'col_names'}
Truth table66%2/3
A ||= B
A= $col_namesB= $meta->{'col_names'}
ABresult
1X1
011
000
440 672 ▶ $col_names = [ split /,/, $col_names ] if ( ref $col_names ne 'ARRAY' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $col_names ne "ARRAY" 567 105 672
441 672 ▶ if ( $meta->{dbm_store_metadata} and not $meta->{hash}->{"_metadata \0"} )
Branch: 1 branch
BranchTrueFalseTotal
if ($meta->{"dbm_store_metadata"} and not $meta->{"hash"}{"_metadata \0"}) 105 567 672
Condition66%2/3
$meta->{"dbm_store_metadata"} and not $meta->{"hash"}{"_metadata \0"}
!ll&&!rl&&r
0567105
MC/DC50%1/2
$meta->{"dbm_store_metadata"} and not $meta->{"hash"}{"_metadata \0"}
$meta->{"dbm_store_metadata"} not $meta->{"hash"}{"_metadata \0"}
Truth table66%2/3
A and not(B)
A= $meta->{"dbm_store_metadata"}B= not $meta->{"hash"}{"_metadata \0"}
ABresult
0X0
100
111
442 {
443 105 ▶ $schema or $schema = '';
Branch: 1 branch
BranchTrueFalseTotal
$schema or $schema = "" 0 105 105
444 $meta->{hash}->{"_metadata \0"} =
445 "<dbd_metadata>"
446 . "<schema>$schema</schema>"
447 . "<col_names>"
448 105 . join( ",", @{$col_names} )
449 . "</col_names>"
450 . "</dbd_metadata>";
451 }
452  
453 672 $meta->{schema} = $schema;
454 672 $meta->{col_names} = $col_names;
455 }
456 }
457  
458 # you must define drop
459 # it is called from execute of a SQL DROP statement
460 #
461 sub drop ($$)
462 105 ▶{
Subroutine drop: called CC=4 SCAR=14.8
463 105 my ( $self, $data ) = @_;
464 105 my $meta = $self->{meta};
465 105 ▶ $meta->{hash} and untie %{ $meta->{hash} };
Branch: 1 branch
BranchTrueFalseTotal
$meta->{"hash"} and untie %{$$meta{"hash"};} 105 0 105
466 105 $self->SUPER::drop($data);
467 # XXX extra_files
468 -f $meta->{f_fqbn} . $dirfext
469 and $meta->{f_ext} eq '.pag/r'
470 105 ▶ and unlink( $meta->{f_fqbn} . $dirfext );
Branch: 1 branch
BranchTrueFalseTotal
-f $meta->{"f_fqbn"} . $dirfext and $meta->{"f_ext"} eq ".pag/r" and unlink $meta->{"f_fqbn"} . $dirfext 105 0 105
Condition33%1/3
-f $meta->{"f_fqbn"} . $dirfext and $meta->{"f_ext"} eq ".pag/r"
!ll&&!rl&&r
00105
MC/DC0%0/2
-f $meta->{"f_fqbn"} . $dirfext and $meta->{"f_ext"} eq ".pag/r"
-f $meta->{"f_fqbn"} . $dirfext $meta->{"f_ext"} eq ".pag/r"
Truth table33%1/3
A and B
A= -f $meta->{"f_fqbn"} . $dirfextB= $meta->{"f_ext"} eq ".pag/r"
ABresult
0X0
100
111
471 105 return 1;
472 }
473  
474 # you must define fetch_row, it is called on all fetches;
475 # it MUST return undef when no rows are left to fetch;
476 # checking for $ary[0] is specific to hashes so you'll
477 # probably need some other kind of check for nothing-left.
478 # as Janis might say: "undef's just another word for
479 # nothing left to fetch" :-)
480 #
481 sub fetch_row ($$)
482 995 ▶{
Subroutine fetch_row: called CC=8 SCAR=21.0
483 995 my ( $self, $data ) = @_;
484 995 my $meta = $self->{meta};
485 # fetch with %each
486 #
487 995 my @ary = each %{ $meta->{hash} };
488 $meta->{dbm_store_metadata}
489 and $ary[0]
490 and $ary[0] eq "_metadata \0"
491 995 ▶ and @ary = each %{ $meta->{hash} };
Branch: 1 branch
BranchTrueFalseTotal
$meta->{"dbm_store_metadata"} and $ary[0] and $ary[0] eq "_metadata \0" and @ary = each %{$$meta{"hash"};} 317 678 995
Condition83%5/6
$meta->{"dbm_store_metadata"} and $ary[0] and $ary[0] eq "_metadata \0"
!ll&&!rl&&r
281397317
$meta->{"dbm_store_metadata"} and $ary[0]
!ll&&!rl&&r
0281714
MC/DC66%2/3
$meta->{"dbm_store_metadata"} and $ary[0] and $ary[0] eq "_metadata \0"
$meta->{"dbm_store_metadata"} $ary[0] $ary[0] eq "_metadata \0"
Truth table75%3/4
A and B and C
A= $meta->{"dbm_store_metadata"}B= $ary[0]C= $ary[0] eq "_metadata \0"
ABCresult
0XX0
10X0
1100
1111
492  
493 995 my ( $key, $val ) = @ary;
494 995 ▶ unless ($key)
Branch: 1 branch
BranchTrueFalseTotal
unless ($key) 281 714 995
495 {
496 281 delete $self->{row};
497 281 return;
498 }
499 714 ▶ my @row = ( ref($val) eq 'ARRAY' ) ? ( $key, @$val ) : ( $key, $val );
Branch: 1 branch
BranchTrueFalseTotal
ref $val eq 'ARRAY' ? : 0 714 714
500 714 ▶ $self->{row} = @row ? \@row : undef;
Branch: 1 branch
BranchTrueFalseTotal
@row ? : 714 0 714
501 714 ▶ return wantarray ? @row : \@row;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 714 714
502 }
503  
504 # you must define push_row except insert_new_row and update_specific_row is defined
505 # it is called on inserts and updates as primitive
506 #
507 sub insert_new_row ($$$)
508 250 ▶{
Subroutine insert_new_row: called CC=4 SCAR=14.0
509 250 my ( $self, $data, $row_aryref ) = @_;
510 250 my $meta = $self->{meta};
511 250 my $ncols = scalar( @{ $meta->{col_names} } );
512 250 my $nitems = scalar( @{$row_aryref} );
513 250 ▶ $ncols == $nitems
Branch: 1 branch
BranchTrueFalseTotal
$ncols == $nitems or croak("You tried to insert $nitems, but table is created with $ncols columns") 250 0 250
514 or croak "You tried to insert $nitems, but table is created with $ncols columns";
515  
516 250 my $key = shift @$row_aryref;
517 250 my $exists;
518 250 eval { $exists = exists( $meta->{hash}->{$key} ); };
519 250 ▶ $exists and croak "Row with PK '$key' already exists";
Branch: 1 branch
BranchTrueFalseTotal
$exists and croak("Row with PK '${key}' already exists") 0 250 250
520  
521 250 ▶ $meta->{hash}->{$key} = $meta->{dbm_mldbm} ? $row_aryref : $row_aryref->[0];
Branch: 1 branch
BranchTrueFalseTotal
$meta->{'dbm_mldbm'} ? : 0 250 250
522  
523 250 return 1;
524 }
525  
526 # this is where you grab the column names from a CREATE statement
527 # if you don't need to do that, it must be defined but can be empty
528 #
529 sub push_names ($$$)
530 119 ▶{
Subroutine push_names: called CC=6 SCAR=18.7
531 119 my ( $self, $data, $row_aryref ) = @_;
532 119 my $meta = $self->{meta};
533  
534 # some sanity checks ...
535 119 my $ncols = scalar(@$row_aryref);
536 119 ▶ $ncols < 2 and croak "At least 2 columns are required for DBD::DBM tables ...";
Branch: 1 branch
BranchTrueFalseTotal
$ncols < 2 and croak("At least 2 columns are required for DBD::DBM tables ...") 0 119 119
537 !$meta->{dbm_mldbm}
538 119 ▶ and $ncols > 2
Branch: 1 branch
BranchTrueFalseTotal
not $meta->{"dbm_mldbm"} and $ncols > 2 and croak("Without serializing with MLDBM only 2 columns are supported, you give $ncols") 0 119 119
Condition33%1/3
not $meta->{"dbm_mldbm"} and $ncols > 2
!ll&&!rl&&r
01190
MC/DC0%0/2
not $meta->{"dbm_mldbm"} and $ncols > 2
not $meta->{"dbm_mldbm"} $ncols > 2
Truth table33%1/3
not(A) and B
A= not $meta->{"dbm_mldbm"}B= $ncols > 2
ABresult
0X0
100
111
539 and croak "Without serializing with MLDBM only 2 columns are supported, you give $ncols";
540 119 $meta->{col_names} = $row_aryref;
541 119 ▶ return unless $meta->{dbm_store_metadata};
Branch: 1 branch
BranchTrueFalseTotal
unless $meta->{"dbm_store_metadata"} 0 119 119
542  
543 119 my $stmt = $data->{sql_stmt};
544 119 my $col_names = join( ',', @{$row_aryref} );
545 119 my $schema = $data->{Database}->{Statement};
546 119 $schema =~ s/^[^\(]+\((.+)\)$/$1/s;
547 119 ▶ $schema = $stmt->schema_str() if ( $stmt->can('schema_str') );
Branch: 1 branch
BranchTrueFalseTotal
if $stmt->can("schema_str") 0 119 119
548 119 $meta->{hash}->{"_metadata \0"} =
549 "<dbd_metadata>"
550 . "<schema>$schema</schema>"
551 . "<col_names>$col_names</col_names>"
552 . "</dbd_metadata>";
553 }
554  
555 # fetch_one_row, delete_one_row, update_one_row
556 # are optimized for hash-style lookup without looping;
557 # if you don't need them, omit them, they're optional
558 # but, in that case you may need to define
559 # truncate() and seek(), see below
560 #
561 sub fetch_one_row ($$;$)
562 266 ▶{
Subroutine fetch_one_row: called CC=5 SCAR=16.7
563 266 my ( $self, $key_only, $key ) = @_;
564 266 my $meta = $self->{meta};
565 266 ▶ $key_only and return $meta->{col_names}->[0];
Branch: 1 branch
BranchTrueFalseTotal
$key_only and return $meta->{"col_names"}[0] 230 36 266
566 36 ▶ exists $meta->{hash}->{$key} or return;
Branch: 1 branch
BranchTrueFalseTotal
exists $meta->{"hash"}{$key} or return 36 0 36
567 36 my $val = $meta->{hash}->{$key};
568 36 ▶ $val = ( ref($val) eq 'ARRAY' ) ? $val : [$val];
Branch: 1 branch
BranchTrueFalseTotal
ref $val eq 'ARRAY' ? : 0 36 36
569 36 my $row = [ $key, @$val ];
570 36 ▶ return wantarray ? @{$row} : $row;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 36 36
571 }
572  
573 sub delete_one_row ($$$)
574 56 ▶{
Subroutine delete_one_row: called CC=1 SCAR=0.0
575 56 my ( $self, $data, $aryref ) = @_;
576 56 my $meta = $self->{meta};
577 56 delete $meta->{hash}->{ $aryref->[0] };
578 }
579  
580 sub update_one_row ($$$)
581 0 ▶{
Subroutine update_one_row: not called CC=4 SCAR=30.0
582 0 my ( $self, $data, $aryref ) = @_;
583 0 my $meta = $self->{meta};
584 0 my $key = shift @$aryref;
585 0 ▶ defined $key or return;
Branch: 1 branch
BranchTrueFalseTotal
defined $key or return 0 0 0
586 0 ▶ my $row = ( ref($aryref) eq 'ARRAY' ) ? $aryref : [$aryref];
Branch: 1 branch
BranchTrueFalseTotal
ref $aryref eq 'ARRAY' ? : 0 0 0
587 0 ▶ $meta->{hash}->{$key} = $meta->{dbm_mldbm} ? $row : $row->[0];
Branch: 1 branch
BranchTrueFalseTotal
$meta->{'dbm_mldbm'} ? : 0 0 0
588 }
589  
590 sub update_specific_row ($$$$)
591 158 ▶{
Subroutine update_specific_row: called CC=9 SCAR=22.6
592 158 my ( $self, $data, $aryref, $origary ) = @_;
593 158 my $meta = $self->{meta};
594 158 my $key = shift @$origary;
595 158 my $newkey = shift @$aryref;
596 158 ▶ return unless ( defined $key );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $key 0 158 158
597  
598 158 ▶ if ( my $mode = $meta->{dbm_updatable_key} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mode = $meta->{"dbm_updatable_key"}) 8 150 158
599 8 ▶ my $method = $mode == 1 ? \&carp : \&croak;
Branch: 1 branch
BranchTrueFalseTotal
$mode == 1 ? : 4 4 8
600 8 my $exists;
601 8 ▶ eval { $exists = $key ne $newkey && exists( $meta->{hash}->{$newkey} ); };
Condition33%1/3
$key ne $newkey && exists $meta->{'hash'}{$newkey}
!ll&&!rl&&r
008
MC/DC0%0/2
$key ne $newkey && exists $meta->{'hash'}{$newkey}
$key ne $newkey exists $meta->{'hash'}{$newkey}
Truth table33%1/3
A && B
A= $key ne $newkeyB= exists $meta->{'hash'}{$newkey}
ABresult
0X0
100
111
602 8 ▶ $exists and $method->("Row with PK '$newkey' already exists");
Branch: 1 branch
BranchTrueFalseTotal
$exists and &$method("Row with PK '${newkey}' already exists") 8 0 8
603 }
604  
605 154 ▶ $key eq $newkey or delete $meta->{hash}->{$key};
Branch: 1 branch
BranchTrueFalseTotal
$key eq $newkey or delete $meta->{"hash"}{$key} 146 8 154
606 154 ▶ my $row = ( ref($aryref) eq 'ARRAY' ) ? $aryref : [$aryref];
Branch: 1 branch
BranchTrueFalseTotal
ref $aryref eq 'ARRAY' ? : 154 0 154
607 154 ▶ $meta->{hash}->{$newkey} = $meta->{dbm_mldbm} ? $row : $row->[0];
Branch: 1 branch
BranchTrueFalseTotal
$meta->{'dbm_mldbm'} ? : 0 154 154
608 }
609  
610 # you may not need to explicitly DESTROY the ::Table
611 # put cleanup code to run when the execute is done
612 #
613 sub DESTROY ($)
614 791 ▶{
Subroutine DESTROY: called CC=2 SCAR=7.0
615 791 my $self = shift;
616 791 my $meta = $self->{meta};
617 791 ▶ $meta->{hash} and untie %{ $meta->{hash} };
Branch: 1 branch
BranchTrueFalseTotal
$meta->{"hash"} and untie %{$$meta{"hash"};} 791 0 791
618  
619 791 $self->SUPER::DESTROY();
620 }
621  
622 # truncate() and seek() must be defined to satisfy DBI::SQL::Nano
623 # *IF* you define the *_one_row methods above, truncate() and
624 # seek() can be empty or you can use them without actually
625 # truncating or seeking anything but if you don't define the
626 # *_one_row methods, you may need to define these
627  
628 # if you need to do something after a series of
629 # deletes or updates, you can put it in truncate()
630 # which is called at the end of executing
631 #
632 sub truncate ($$)
633 0 ▶{
Subroutine truncate: not called CC=1 SCAR=6.9
634 # my ( $self, $data ) = @_;
635 0 return 1;
636 }
637  
638 # seek() is only needed if you use IO::File
639 # though it could be used for other non-file operations
640 # that you need to do before "writes" or truncate()
641 #
642 sub seek ($$$$)
643 250 ▶{
Subroutine seek: called CC=1 SCAR=0.0
644 # my ( $self, $data, $pos, $whence ) = @_;
645 250 return 1;
646 }
647  
648 # Th, th, th, that's all folks! See DBD::File and DBD::CSV for other
649 # examples of creating pure perl DBDs. I hope this helped.
650 # Now it's time to go forth and create your own DBD!
651 # Remember to check in with dbi-dev@perl.org before you get too far.
652 # We may be able to make suggestions or point you to other related
653 # projects.
654  
655 431 1;
656 __END__
« blib/lib/DBI/ProxyServer.pm ↑ Summary blib/lib/DBI/DBD/SqlEngine.pm »