SQLite/Populate.pm

filter: Statementstmt 46.7% 222 / 475 Branchbran 31.3% 59 / 188 Conditioncond 21.0% 12 / 57 MC/DCmcdc 0.0% 0 / 36 Subroutinesub 80.4% 33 / 41 Podpod 0.0% 0 / 5 totaltotal 40.6% 326 / 802 SCAR 82.2
CC
131
Cov
41%
update
182.0
update
156.0
delete
110.0
CRAP 3710.6
↑ Summary SQLite/State.pm »
1 # $Id: Populate.pm 82 2020-05-30 06:14:27Z stro $
2  
3 package CPAN::SQLite::Populate;
4 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶no warnings qw(redefine);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 8 our $VERSION = '0.218';
9  
10 8 ▶use English qw/-no_match_vars/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 8 ▶use CPAN::SQLite::Util qw($table_id has_hash_data print_debug);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 8 ▶use CPAN::SQLite::DBI::Index;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 8 ▶use CPAN::SQLite::DBI qw($dbh);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 8 ▶use File::Find;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 8 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 8 ▶use File::Spec::Functions;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 8 ▶use File::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 8 ▶use Scalar::Util 'weaken';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 8 our $dbh = $CPAN::SQLite::DBI::dbh;
22 8 my ($setup);
23  
24 my %tbl2obj;
25 8 $tbl2obj{$_} = __PACKAGE__ . '::' . $_ foreach (qw(dists mods auths info));
26 8 my %obj2tbl = reverse %tbl2obj;
27  
28 sub new {
29 4 ▶ my ($class, %args) = @_;
Subroutine new: called CC=7 SCAR=23.2
Pod undocumented
30  
31 4 $setup = $args{setup};
32  
33 4 my $index = $args{index};
34 4 my @tables = qw(dists mods auths info);
35 4 foreach my $table (@tables) {
36 16 my $obj = $index->{$table};
37 16 ▶ die "Please supply a CPAN::SQLite::Index::$table object"
Branch: 1 branch
BranchTrueFalseTotal
unless $obj and ref $obj eq "CPAN::SQLite::Index::$table" 0 16 16
Condition33%1/3
$obj and ref $obj eq "CPAN::SQLite::Index::$table"
!ll&&!rl&&r
0016
MC/DC0%0/2
$obj and ref $obj eq "CPAN::SQLite::Index::$table"
$obj ref $obj eq "CPAN::SQLite::Index::$table"
Truth table33%1/3
A and B
A= $objB= ref $obj eq "CPAN::SQLite::Index::$table"
ABresult
0X0
100
111
38 unless ($obj and ref($obj) eq "CPAN::SQLite::Index::$table");
39 }
40 4 my $state = $args{state};
41 4 ▶ unless ($setup) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($setup) 0 4 4
42 0 ▶ die "Please supply a CPAN::SQLite::State object"
Branch: 1 branch
BranchTrueFalseTotal
unless $state and ref $state eq "CPAN::SQLite::State" 0 0 0
Condition0%0/3
$state and ref $state eq "CPAN::SQLite::State"
!ll&&!rl&&r
000
MC/DC0%0/2
$state and ref $state eq "CPAN::SQLite::State"
$state ref $state eq "CPAN::SQLite::State"
Truth table0%0/3
A and B
A= $stateB= ref $state eq "CPAN::SQLite::State"
ABresult
0X0
100
111
43 unless ($state and ref($state) eq 'CPAN::SQLite::State');
44 }
45 4 my $cdbi = CPAN::SQLite::DBI::Index->new(%args);
46  
47 my $self = {
48 index => $index,
49 state => $state,
50 obj => {},
51 cdbi => $cdbi,
52 db_name => $args{db_name},
53 4 };
54 4 return bless $self, $class;
55 }
56  
57 sub populate {
58 4 ▶ my $self = shift;
Subroutine populate: called CC=5 SCAR=20.9
Pod undocumented
59  
60 4 ▶ if ($setup) {
Branch: 1 branch
BranchTrueFalseTotal
if ($setup) 4 0 4
61 4 ▶ unless ($self->{cdbi}->create_tables(setup => $setup)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"cdbi"}->create_tables("setup", $setup)) 0 4 4
62 0 warn "Creating tables failed";
63 0 return;
64 }
65 }
66 4 ▶ unless ($self->create_objs()) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->create_objs) 0 4 4
67 0 warn "Cannot create objects";
68 0 return;
69 }
70 4 ▶ unless ($self->populate_tables()) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->populate_tables) 0 4 4
71 0 warn "Populating tables failed";
72 0 return;
73 }
74 4 return 1;
75 }
76  
77 sub create_objs {
78 4 ▶ my $self = shift;
Subroutine create_objs: called CC=12 SCAR=28.1
Pod undocumented
79 4 my @tables = qw(dists auths mods info);
80  
81 4 foreach my $table (@tables) {
82 16 my $obj;
83 16 my $pack = $tbl2obj{$table};
84 16 my $index = $self->{index}->{$table};
85 16 ▶ if ($index and ref($index) eq "CPAN::SQLite::Index::$table") {
Branch: 1 branch
BranchTrueFalseTotal
if ($index and ref $index eq "CPAN::SQLite::Index::$table") { } 16 0 16
Condition33%1/3
$index and ref $index eq "CPAN::SQLite::Index::$table"
!ll&&!rl&&r
0016
MC/DC0%0/2
$index and ref $index eq "CPAN::SQLite::Index::$table"
$index ref $index eq "CPAN::SQLite::Index::$table"
Truth table33%1/3
A and B
A= $indexB= ref $index eq "CPAN::SQLite::Index::$table"
ABresult
0X0
100
111
86 16 my $info = $index->{info};
87 16 ▶ if ($table ne 'info') {
Branch: 1 branch
BranchTrueFalseTotal
if ($table ne "info") 12 4 16
88 12 ▶ return unless has_hash_data($info);
Branch: 1 branch
BranchTrueFalseTotal
unless has_hash_data($info) 0 12 12
89 }
90 $obj = $pack->new(
91 info => $info,
92 16 cdbi => $self->{cdbi}->{objs}->{$table});
93 } else {
94 0 $obj = $pack->new(cdbi => $self->{cdbi}->{objs}->{$table});
95 }
96 16 $self->{obj}->{$table} = $obj;
97 }
98  
99 4 foreach my $table (@tables) {
100 16 my $obj = $self->{obj}->{$table};
101 16 foreach (@tables) {
102 64 ▶ next if ref($obj) eq $tbl2obj{$_};
Branch: 1 branch
BranchTrueFalseTotal
if ref $obj eq $tbl2obj{$_} 16 48 64
103 48 $obj->{obj}->{$_} = $self->{obj}->{$_};
104 48 weaken $obj->{obj}->{$_};
105 }
106 }
107  
108 4 ▶ unless ($setup) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($setup) 0 4 4
109 0 my $state = $self->{state};
110 0 my @tables = qw(auths dists mods);
111 0 my @data = qw(ids insert update delete);
112  
113 0 foreach my $table (@tables) {
114 0 my $state_obj = $state->{obj}->{$table};
115 0 my $pop_obj = $self->{obj}->{$table};
116 0 $pop_obj->{$_} = $state_obj->{$_} for (@data);
117 }
118 }
119 4 return 1;
120 }
121  
122 sub populate_tables {
123 4 ▶ my $self = shift;
Subroutine populate_tables: called CC=8 SCAR=27.7
Pod undocumented
124 4 ▶ my @methods = $setup ? qw(insert) : qw(insert update delete);
Branch: 1 branch
BranchTrueFalseTotal
$setup ? : 4 0 4
125  
126 # Reset status
127 4 my $info_obj = $self->{'obj'}->{'info'};
128 4 ▶ unless ($info_obj->delete) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($info_obj->delete) 0 4 4
129 0 print_debug('Fatal error from ', ref($info_obj), ':', $info_obj->{'error_msg'});
130 0 return;
131 }
132  
133 4 my @tables = qw(auths dists mods);
134 4 for my $method (@methods) {
135 4 for my $table (@tables) {
136 12 my $obj = $self->{obj}->{$table};
137 12 ▶ unless ($obj->$method()) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($obj->$method) 0 12 12
138 0 ▶ if (my $error = $obj->{error_msg}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $error = $obj->{'error_msg'}) { } 0 0 0
139 0 print_debug("Fatal error from ", ref($obj), ": ", $error, $/);
140 0 return;
141 } else {
142 0 my $info = $obj->{info_msg};
143 0 print_debug("Info from ", ref($obj), ": ", $info, $/);
144 }
145 }
146 }
147 }
148  
149 # Update status
150 4 ▶ unless ($info_obj->insert) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($info_obj->insert) 0 4 4
151 0 print_debug('Fatal error from ', ref($info_obj), ':', $info_obj->{'error_msg'});
152 0 return;
153 }
154  
155 4 return 1;
156 }
157  
158 package CPAN::SQLite::Populate::auths;
159 8 ▶use parent 'CPAN::SQLite::Populate';
Subroutine BEGIN: called CC=1 SCAR=0.0
160 8 ▶use CPAN::SQLite::Util qw(has_hash_data print_debug);
Subroutine BEGIN: called CC=1 SCAR=0.0
161  
162 sub new {
163 4 ▶ my ($class, %args) = @_;
Subroutine new: called CC=4 SCAR=14.8
164 4 my $info = $args{info};
165 4 ▶ die "No author info available" unless has_hash_data($info);
Branch: 1 branch
BranchTrueFalseTotal
unless has_hash_data($info) 0 4 4
166 4 my $cdbi = $args{cdbi};
167 4 ▶ die "No dbi object available"
Branch: 1 branch
BranchTrueFalseTotal
unless $cdbi and ref $cdbi eq "CPAN::SQLite::DBI::Index::auths" 0 4 4
Condition33%1/3
$cdbi and ref $cdbi eq "CPAN::SQLite::DBI::Index::auths"
!ll&&!rl&&r
004
MC/DC0%0/2
$cdbi and ref $cdbi eq "CPAN::SQLite::DBI::Index::auths"
$cdbi ref $cdbi eq "CPAN::SQLite::DBI::Index::auths"
Truth table33%1/3
A and B
A= $cdbiB= ref $cdbi eq "CPAN::SQLite::DBI::Index::auths"
ABresult
0X0
100
111
168 unless ($cdbi and ref($cdbi) eq 'CPAN::SQLite::DBI::Index::auths');
169 4 my $self = {
170 info => $info,
171 insert => {},
172 update => {},
173 delete => {},
174 ids => {},
175 obj => {},
176 cdbi => $cdbi,
177 error_msg => '',
178 info_msg => '',
179 };
180 4 return bless $self, $class;
181 }
182  
183 sub insert {
184 4 ▶ my $self = shift;
Subroutine insert: called CC=11 SCAR=31.7
185 4 ▶ unless ($dbh) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($CPAN::SQLite::Populate::dbh) 0 4 4
186 0 $self->{error_msg} = q{No db handle available};
187 0 return;
188 }
189 4 my $info = $self->{info};
190 4 my $cdbi = $self->{cdbi};
191 4 ▶ my $data = $setup ? $info : $self->{insert};
Branch: 1 branch
BranchTrueFalseTotal
$setup ? : 4 0 4
192 4 ▶ unless (has_hash_data($data)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (has_hash_data($data)) 0 4 4
193 0 $self->{info_msg} = q{No author data to insert};
194 0 return;
195 }
196 4 my $auth_ids = $self->{ids};
197 4 my @fields = qw(cpanid email fullname);
198 4 ▶ my $sth = $cdbi->sth_insert(\@fields) or do {
Branch: 1 branch
BranchTrueFalseTotal
my $sth = $cdbi->sth_insert(\@fields) or do { $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 4 4
199 0 $self->{error_msg} = $cdbi->{error_msg};
200 0 return;
201 };
202 4 foreach my $cpanid (keys %$data) {
203 14735 my $values = $info->{$cpanid};
204 14735 ▶ next unless ($values and $cpanid);
Branch: 1 branch
BranchTrueFalseTotal
unless $values and $cpanid 0 14735 14735
Condition33%1/3
$values and $cpanid
!ll&&!rl&&r
0014735
MC/DC0%0/2
$values and $cpanid
$values $cpanid
Truth table33%1/3
A and B
A= $valuesB= $cpanid
ABresult
0X0
100
111
205 14735 print_debug("Inserting author $cpanid\n");
206 $sth->execute($cpanid, $values->{email}, $values->{fullname})
207 14735 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute($cpanid, $values->{"email"}, $values->{"fullname"}) or do { $cdbi->db_error($sth); $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 14735 14735
208 0 $cdbi->db_error($sth);
209 0 $self->{error_msg} = $cdbi->{error_msg};
210 0 return;
211 };
212 14735 ▶ $auth_ids->{$cpanid} = $dbh->func('last_insert_rowid') or do {
Branch: 1 branch
BranchTrueFalseTotal
$auth_ids->{$cpanid} = $CPAN::SQLite::Populate::dbh->func("last_insert_rowid") or do { $cdbi->db_error($sth); $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 14735 14735
213 0 $cdbi->db_error($sth);
214 0 $self->{error_msg} = $cdbi->{error_msg};
215 0 return;
216 };
217 }
218 4 $sth->finish();
219 4 undef $sth;
220 4 ▶ $dbh->commit() or do {
Branch: 1 branch
BranchTrueFalseTotal
$CPAN::SQLite::Populate::dbh->commit or do { $cdbi->db_error; $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 4 4
221 0 $cdbi->db_error();
222 0 $self->{error_msg} = $cdbi->{error_msg};
223 0 return;
224 };
225 4 return 1;
226 }
227  
228 sub update {
229 0 ▶ my $self = shift;
Subroutine update: not called CC=9 SCAR=45.0
230 0 ▶ unless ($dbh) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($CPAN::SQLite::Populate::dbh) 0 0 0
231 0 $self->{error_msg} = q{No db handle available};
232 0 return;
233 }
234 0 my $data = $self->{update};
235 0 my $cdbi = $self->{cdbi};
236 0 ▶ unless (has_hash_data($data)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (has_hash_data($data)) 0 0 0
237 0 $self->{info_msg} = q{No author data to update};
238 0 return;
239 }
240  
241 0 my $info = $self->{info};
242 0 my @fields = qw(cpanid email fullname);
243 0 foreach my $cpanid (keys %$data) {
244 0 print_debug("Updating author $cpanid\n");
245 0 ▶ next unless $data->{$cpanid};
Branch: 1 branch
BranchTrueFalseTotal
unless $data->{$cpanid} 0 0 0
246 0 my $sth = $cdbi->sth_update(\@fields, $data->{$cpanid});
247 0 my $values = $info->{$cpanid};
248 0 ▶ next unless ($cpanid and $values);
Branch: 1 branch
BranchTrueFalseTotal
unless $cpanid and $values 0 0 0
Condition0%0/3
$cpanid and $values
!ll&&!rl&&r
000
MC/DC0%0/2
$cpanid and $values
$cpanid $values
Truth table0%0/3
A and B
A= $cpanidB= $values
ABresult
0X0
100
111
249 $sth->execute($cpanid, $values->{email}, $values->{fullname})
250 0 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute($cpanid, $values->{"email"}, $values->{"fullname"}) or do { $cdbi->db_error($sth); $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 0 0
251 0 $cdbi->db_error($sth);
252 0 $self->{error_msg} = $cdbi->{error_msg};
253 0 return;
254 };
255 0 $sth->finish();
256 0 undef $sth;
257 }
258 0 ▶ $dbh->commit() or do {
Branch: 1 branch
BranchTrueFalseTotal
$CPAN::SQLite::Populate::dbh->commit or do { $cdbi->db_error; $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 0 0
259 0 $cdbi->db_error();
260 0 $self->{error_msg} = $cdbi->{error_msg};
261 0 return;
262 };
263 0 return 1;
264 }
265  
266 sub delete {
267 0 ▶ my $self = shift;
Subroutine delete: not called CC=1 SCAR=6.9
268 0 $self->{info_msg} = q{No author data to delete};
269 0 return;
270 }
271  
272 package CPAN::SQLite::Populate::dists;
273 8 ▶use parent 'CPAN::SQLite::Populate';
Subroutine BEGIN: called CC=1 SCAR=0.0
274 8 ▶use CPAN::SQLite::Util qw(has_hash_data print_debug);
Subroutine BEGIN: called CC=1 SCAR=0.0
275  
276 sub new {
277 4 ▶ my ($class, %args) = @_;
Subroutine new: called CC=4 SCAR=14.8
278 4 my $info = $args{info};
279 4 ▶ die "No dist info available" unless has_hash_data($info);
Branch: 1 branch
BranchTrueFalseTotal
unless has_hash_data($info) 0 4 4
280 4 my $cdbi = $args{cdbi};
281 4 ▶ die "No dbi object available"
Branch: 1 branch
BranchTrueFalseTotal
unless $cdbi and ref $cdbi eq "CPAN::SQLite::DBI::Index::dists" 0 4 4
Condition33%1/3
$cdbi and ref $cdbi eq "CPAN::SQLite::DBI::Index::dists"
!ll&&!rl&&r
004
MC/DC0%0/2
$cdbi and ref $cdbi eq "CPAN::SQLite::DBI::Index::dists"
$cdbi ref $cdbi eq "CPAN::SQLite::DBI::Index::dists"
Truth table33%1/3
A and B
A= $cdbiB= ref $cdbi eq "CPAN::SQLite::DBI::Index::dists"
ABresult
0X0
100
111
282 unless ($cdbi and ref($cdbi) eq 'CPAN::SQLite::DBI::Index::dists');
283 4 my $self = {
284 info => $info,
285 insert => {},
286 update => {},
287 delete => {},
288 ids => {},
289 obj => {},
290 cdbi => $cdbi,
291 error_msg => '',
292 info_msg => '',
293 };
294 4 return bless $self, $class;
295 }
296  
297 sub insert {
298 4 ▶ my $self = shift;
Subroutine insert: called CC=15 SCAR=36.8
299 4 ▶ unless ($dbh) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($CPAN::SQLite::Populate::dbh) 0 4 4
300 0 $self->{error_msg} = q{No db handle available};
301 0 return;
302 }
303 4 ▶ return unless my $auth_obj = $self->{obj}->{auths};
Branch: 1 branch
BranchTrueFalseTotal
unless my $auth_obj = $self->{"obj"}{"auths"} 0 4 4
304 4 my $cdbi = $self->{cdbi};
305 4 my $auth_ids = $auth_obj->{ids};
306 4 my $dists = $self->{info};
307 4 ▶ my $data = $setup ? $dists : $self->{insert};
Branch: 1 branch
BranchTrueFalseTotal
$setup ? : 4 0 4
308 4 ▶ unless (has_hash_data($data)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (has_hash_data($data)) 0 4 4
309 0 $self->{info_msg} = q{No dist data to insert};
310 0 return;
311 }
312 4 ▶ unless ($dists and $auth_ids) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dists and $auth_ids) 0 4 4
Condition33%1/3
$dists and $auth_ids
!ll&&!rl&&r
004
MC/DC0%0/2
$dists and $auth_ids
$dists $auth_ids
Truth table33%1/3
A and B
A= $distsB= $auth_ids
ABresult
0X0
100
111
313 0 $self->{error_msg}->{index} = q{No dist index data available};
314 0 return;
315 }
316  
317 4 my $dist_ids = $self->{ids};
318 4 my @fields = qw(auth_id dist_name dist_file dist_vers dist_abs);
319 4 ▶ my $sth = $cdbi->sth_insert(\@fields) or do {
Branch: 1 branch
BranchTrueFalseTotal
my $sth = $cdbi->sth_insert(\@fields) or do { $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 4 4
320 0 $self->{error_msg} = $cdbi->{error_msg};
321 0 return;
322 };
323 4 foreach my $distname (keys %$data) {
324 41927 my $values = $dists->{$distname};
325 41927 my $cpanid = $values->{cpanid};
326 41927 ▶ next unless ($values and $cpanid and $auth_ids->{$cpanid});
Branch: 1 branch
BranchTrueFalseTotal
unless $values and $cpanid and $auth_ids->{$cpanid} 0 41927 41927
Condition33%2/6
$values and $cpanid and $auth_ids->{$cpanid}
!ll&&!rl&&r
0041927
$values and $cpanid
!ll&&!rl&&r
0041927
MC/DC0%0/3
$values and $cpanid and $auth_ids->{$cpanid}
$values $cpanid $auth_ids->{$cpanid}
Truth table25%1/4
A and B and C
A= $valuesB= $cpanidC= $auth_ids->{$cpanid}
ABCresult
0XX0
10X0
1100
1111
327 41927 print_debug("Inserting $distname of $cpanid\n");
328 $sth->execute($auth_ids->{ $values->{cpanid} }, $distname, $values->{dist_file}, $values->{dist_vers}, $values->{dist_abs})
329 41927 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute($$auth_ids{$values->{"cpanid"}}, $distname, $values->{"dist_file"}, $values->{"dist_vers"}, $values->{"dist_abs"}) or do { $cdbi->db_error($sth); $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 41927 41927
330 0 $cdbi->db_error($sth);
331 0 $self->{error_msg} = $cdbi->{error_msg};
332 0 return;
333 };
334 41927 ▶ $dist_ids->{$distname} = $dbh->func('last_insert_rowid') or do {
Branch: 1 branch
BranchTrueFalseTotal
$dist_ids->{$distname} = $CPAN::SQLite::Populate::dbh->func("last_insert_rowid") or do { $cdbi->db_error($sth); $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 41927 41927
335 0 $cdbi->db_error($sth);
336 0 $self->{error_msg} = $cdbi->{error_msg};
337 0 return;
338 };
339 }
340 4 $sth->finish();
341 4 undef $sth;
342 4 ▶ $dbh->commit() or do {
Branch: 1 branch
BranchTrueFalseTotal
$CPAN::SQLite::Populate::dbh->commit or do { $cdbi->db_error; $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 4 4
343 0 $cdbi->db_error();
344 0 $self->{error_msg} = $cdbi->{error_msg};
345 0 return;
346 };
347 4 return 1;
348 }
349  
350 sub update {
351 0 ▶ my $self = shift;
Subroutine update: not called CC=13 SCAR=52.0
352 0 ▶ unless ($dbh) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($CPAN::SQLite::Populate::dbh) 0 0 0
353 0 $self->{error_msg} = q{No db handle available};
354 0 return;
355 }
356 0 my $cdbi = $self->{cdbi};
357 0 my $data = $self->{update};
358 0 ▶ unless (has_hash_data($data)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (has_hash_data($data)) 0 0 0
359 0 $self->{info_msg} = q{No dist data to update};
360 0 return;
361 }
362 0 ▶ return unless my $auth_obj = $self->{obj}->{auths};
Branch: 1 branch
BranchTrueFalseTotal
unless my $auth_obj = $self->{"obj"}{"auths"} 0 0 0
363 0 my $auth_ids = $auth_obj->{ids};
364 0 my $dists = $self->{info};
365 0 ▶ unless ($dists and $auth_ids) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dists and $auth_ids) 0 0 0
Condition0%0/3
$dists and $auth_ids
!ll&&!rl&&r
000
MC/DC0%0/2
$dists and $auth_ids
$dists $auth_ids
Truth table0%0/3
A and B
A= $distsB= $auth_ids
ABresult
0X0
100
111
366 0 $self->{error_msg} = q{No dist index data available};
367 0 return;
368 }
369  
370 0 my @fields = qw(auth_id dist_name dist_file dist_vers dist_abs);
371 0 foreach my $distname (keys %$data) {
372 0 ▶ next unless $data->{$distname};
Branch: 1 branch
BranchTrueFalseTotal
unless $data->{$distname} 0 0 0
373 0 my $sth = $cdbi->sth_update(\@fields, $data->{$distname});
374 0 my $values = $dists->{$distname};
375 0 my $cpanid = $values->{cpanid};
376 0 ▶ next unless ($values and $cpanid and $auth_ids->{$cpanid});
Branch: 1 branch
BranchTrueFalseTotal
unless $values and $cpanid and $auth_ids->{$cpanid} 0 0 0
Condition0%0/6
$values and $cpanid and $auth_ids->{$cpanid}
!ll&&!rl&&r
000
$values and $cpanid
!ll&&!rl&&r
000
MC/DC0%0/3
$values and $cpanid and $auth_ids->{$cpanid}
$values $cpanid $auth_ids->{$cpanid}
Truth table0%0/4
A and B and C
A= $valuesB= $cpanidC= $auth_ids->{$cpanid}
ABCresult
0XX0
10X0
1100
1111
377 0 print_debug("Updating $distname of $cpanid\n");
378 $sth->execute($auth_ids->{ $values->{cpanid} }, $distname, $values->{dist_file}, $values->{dist_vers}, $values->{dist_abs})
379 0 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute($$auth_ids{$values->{"cpanid"}}, $distname, $values->{"dist_file"}, $values->{"dist_vers"}, $values->{"dist_abs"}) or do { $cdbi->db_error($sth); $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 0 0
380 0 $cdbi->db_error($sth);
381 0 $self->{error_msg} = $cdbi->{error_msg};
382 0 return;
383 };
384 0 $sth->finish();
385 0 undef $sth;
386 }
387 0 ▶ $dbh->commit() or do {
Branch: 1 branch
BranchTrueFalseTotal
$CPAN::SQLite::Populate::dbh->commit or do { $cdbi->db_error; $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 0 0
388 0 $cdbi->db_error();
389 0 $self->{error_msg} = $cdbi->{error_msg};
390 0 return;
391 };
392 0 return 1;
393 }
394  
395 sub delete {
396 0 ▶ my $self = shift;
Subroutine delete: not called CC=6 SCAR=37.4
397 0 ▶ unless ($dbh) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($CPAN::SQLite::Populate::dbh) 0 0 0
398 0 $self->{error_msg} = q{No db handle available};
399 0 return;
400 }
401 0 my $cdbi = $self->{cdbi};
402 0 my $data = $self->{delete};
403 0 ▶ unless (has_hash_data($data)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (has_hash_data($data)) 0 0 0
404 0 $self->{info_msg} = q{No dist data to delete};
405 0 return;
406 }
407  
408 0 my $sth = $cdbi->sth_delete('dist_id');
409 0 foreach my $distname (keys %$data) {
410 0 print_debug("Deleting $distname\n");
411 0 ▶ $sth->execute($data->{$distname}) or do {
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute($data->{$distname}) or do { $cdbi->db_error($sth); $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 0 0
412 0 $cdbi->db_error($sth);
413 0 $self->{error_msg} = $cdbi->{error_msg};
414 0 return;
415 };
416 }
417 0 $sth->finish();
418 0 undef $sth;
419 0 ▶ $dbh->commit() or do {
Branch: 1 branch
BranchTrueFalseTotal
$CPAN::SQLite::Populate::dbh->commit or do { $cdbi->db_error; $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 0 0
420 0 $cdbi->db_error();
421 0 $self->{error_msg} = $cdbi->{error_msg};
422 0 return;
423 };
424 0 return 1;
425 }
426  
427 package CPAN::SQLite::Populate::mods;
428 8 ▶use parent 'CPAN::SQLite::Populate';
Subroutine BEGIN: called CC=1 SCAR=0.0
429 8 ▶use CPAN::SQLite::Util qw(has_hash_data print_debug);
Subroutine BEGIN: called CC=1 SCAR=0.0
430  
431 sub new {
432 4 ▶ my ($class, %args) = @_;
Subroutine new: called CC=4 SCAR=14.8
433 4 my $info = $args{info};
434 4 ▶ die "No module info available" unless has_hash_data($info);
Branch: 1 branch
BranchTrueFalseTotal
unless has_hash_data($info) 0 4 4
435 4 my $cdbi = $args{cdbi};
436 4 ▶ die "No dbi object available"
Branch: 1 branch
BranchTrueFalseTotal
unless $cdbi and ref $cdbi eq "CPAN::SQLite::DBI::Index::mods" 0 4 4
Condition33%1/3
$cdbi and ref $cdbi eq "CPAN::SQLite::DBI::Index::mods"
!ll&&!rl&&r
004
MC/DC0%0/2
$cdbi and ref $cdbi eq "CPAN::SQLite::DBI::Index::mods"
$cdbi ref $cdbi eq "CPAN::SQLite::DBI::Index::mods"
Truth table33%1/3
A and B
A= $cdbiB= ref $cdbi eq "CPAN::SQLite::DBI::Index::mods"
ABresult
0X0
100
111
437 unless ($cdbi and ref($cdbi) eq 'CPAN::SQLite::DBI::Index::mods');
438 4 my $self = {
439 info => $info,
440 insert => {},
441 update => {},
442 delete => {},
443 ids => {},
444 obj => {},
445 cdbi => $cdbi,
446 error_msg => '',
447 info_msg => '',
448 };
449 4 return bless $self, $class;
450 }
451  
452 sub insert {
453 4 ▶ my $self = shift;
Subroutine insert: called CC=14 SCAR=35.9
454 4 ▶ unless ($dbh) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($CPAN::SQLite::Populate::dbh) 0 4 4
455 0 $self->{error_msg} = q{No db handle available};
456 0 return;
457 }
458 4 ▶ return unless my $dist_obj = $self->{obj}->{dists};
Branch: 1 branch
BranchTrueFalseTotal
unless my $dist_obj = $self->{"obj"}{"dists"} 0 4 4
459 4 my $cdbi = $self->{cdbi};
460 4 my $dist_ids = $dist_obj->{ids};
461 4 my $mods = $self->{info};
462 4 ▶ my $data = $setup ? $mods : $self->{insert};
Branch: 1 branch
BranchTrueFalseTotal
$setup ? : 4 0 4
463 4 ▶ unless (has_hash_data($data)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (has_hash_data($data)) 0 4 4
464 0 $self->{info_msg} = q{No module data to insert};
465 0 return;
466 }
467 4 ▶ unless ($mods and $dist_ids) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mods and $dist_ids) 0 4 4
Condition33%1/3
$mods and $dist_ids
!ll&&!rl&&r
004
MC/DC0%0/2
$mods and $dist_ids
$mods $dist_ids
Truth table33%1/3
A and B
A= $modsB= $dist_ids
ABresult
0X0
100
111
468 0 $self->{error_msg} = q{No module index data available};
469 0 return;
470 }
471  
472 4 my $mod_ids = $self->{ids};
473 4 my @fields = qw(dist_id mod_name mod_abs
474 mod_vers);
475  
476 4 ▶ my $sth = $cdbi->sth_insert(\@fields) or do {
Branch: 1 branch
BranchTrueFalseTotal
my $sth = $cdbi->sth_insert(\@fields) or do { $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 4 4
477 0 $self->{error_msg} = $cdbi->{error_msg};
478 0 return;
479 };
480 4 foreach my $modname (keys %$data) {
481 235796 my $values = $mods->{$modname};
482 235796 ▶ next unless ($values and $dist_ids->{ $values->{dist_name} });
Branch: 1 branch
BranchTrueFalseTotal
unless $values and $$dist_ids{$values->{"dist_name"}} 0 235796 235796
Condition33%1/3
$values and $$dist_ids{$values->{"dist_name"}}
!ll&&!rl&&r
00235796
MC/DC0%0/2
$values and $$dist_ids{$values->{"dist_name"}}
$values $$dist_ids{$values->{"dist_name"}}
Truth table33%1/3
A and B
A= $valuesB= $$dist_ids{$values->{"dist_name"}}
ABresult
0X0
100
111
483 $sth->execute($dist_ids->{ $values->{dist_name} }, $modname, $values->{mod_abs}, $values->{mod_vers})
484 235796 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute($$dist_ids{$values->{"dist_name"}}, $modname, $values->{"mod_abs"}, $values->{"mod_vers"}) or do { $cdbi->db_error($sth); $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 235796 235796
485 0 $cdbi->db_error($sth);
486 0 $self->{error_msg} = $cdbi->{error_msg};
487 0 return;
488 };
489 235796 ▶ $mod_ids->{$modname} = $dbh->func('last_insert_rowid') or do {
Branch: 1 branch
BranchTrueFalseTotal
$mod_ids->{$modname} = $CPAN::SQLite::Populate::dbh->func("last_insert_rowid") or do { $cdbi->db_error($sth); $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 235796 235796
490 0 $cdbi->db_error($sth);
491 0 $self->{error_msg} = $cdbi->{error_msg};
492 0 return;
493 };
494 }
495 4 $sth->finish();
496 4 undef $sth;
497 4 ▶ $dbh->commit() or do {
Branch: 1 branch
BranchTrueFalseTotal
$CPAN::SQLite::Populate::dbh->commit or do { $cdbi->db_error; $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 4 4
498 0 $cdbi->db_error();
499 0 $self->{error_msg} = $cdbi->{error_msg};
500 0 return;
501 };
502 4 return 1;
503 }
504  
505 sub update {
506 0 ▶ my $self = shift;
Subroutine update: not called CC=12 SCAR=50.5
507 0 ▶ unless ($dbh) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($CPAN::SQLite::Populate::dbh) 0 0 0
508 0 $self->{error_msg} = q{No db handle available};
509 0 return;
510 }
511 0 my $cdbi = $self->{cdbi};
512 0 my $data = $self->{update};
513 0 ▶ unless (has_hash_data($data)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (has_hash_data($data)) 0 0 0
514 0 $self->{info_msg} = q{No module data to update};
515 0 return;
516 }
517 0 ▶ return unless my $dist_obj = $self->{obj}->{dists};
Branch: 1 branch
BranchTrueFalseTotal
unless my $dist_obj = $self->{"obj"}{"dists"} 0 0 0
518 0 my $dist_ids = $dist_obj->{ids};
519 0 my $mods = $self->{info};
520 0 ▶ unless ($dist_ids and $mods) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dist_ids and $mods) 0 0 0
Condition0%0/3
$dist_ids and $mods
!ll&&!rl&&r
000
MC/DC0%0/2
$dist_ids and $mods
$dist_ids $mods
Truth table0%0/3
A and B
A= $dist_idsB= $mods
ABresult
0X0
100
111
521 0 $self->{error_msg} = q{No module index data available};
522 0 return;
523 }
524  
525 0 my @fields = qw(dist_id mod_name mod_abs
526 mod_vers);
527  
528 0 foreach my $modname (keys %$data) {
529 0 ▶ next unless $data->{$modname};
Branch: 1 branch
BranchTrueFalseTotal
unless $data->{$modname} 0 0 0
530 0 print_debug("Updating $modname\n");
531 0 my $sth = $cdbi->sth_update(\@fields, $data->{$modname});
532 0 my $values = $mods->{$modname};
533 0 ▶ next unless ($values and $dist_ids->{ $values->{dist_name} });
Branch: 1 branch
BranchTrueFalseTotal
unless $values and $$dist_ids{$values->{"dist_name"}} 0 0 0
Condition0%0/3
$values and $$dist_ids{$values->{"dist_name"}}
!ll&&!rl&&r
000
MC/DC0%0/2
$values and $$dist_ids{$values->{"dist_name"}}
$values $$dist_ids{$values->{"dist_name"}}
Truth table0%0/3
A and B
A= $valuesB= $$dist_ids{$values->{"dist_name"}}
ABresult
0X0
100
111
534 $sth->execute($dist_ids->{ $values->{dist_name} }, $modname, $values->{mod_abs}, $values->{mod_vers})
535 0 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute($$dist_ids{$values->{"dist_name"}}, $modname, $values->{"mod_abs"}, $values->{"mod_vers"}) or do { $cdbi->db_error($sth); $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 0 0
536 0 $cdbi->db_error($sth);
537 0 $self->{error_msg} = $cdbi->{error_msg};
538 0 return;
539 };
540 0 $sth->finish();
541 0 undef $sth;
542 }
543 0 ▶ $dbh->commit() or do {
Branch: 1 branch
BranchTrueFalseTotal
$CPAN::SQLite::Populate::dbh->commit or do { $cdbi->db_error; $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 0 0
544 0 $cdbi->db_error();
545 0 $self->{error_msg} = $cdbi->{error_msg};
546 0 return;
547 };
548 0 return 1;
549 }
550  
551 sub delete {
552 0 ▶ my $self = shift;
Subroutine delete: not called CC=10 SCAR=47.0
553 0 ▶ unless ($dbh) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($CPAN::SQLite::Populate::dbh) 0 0 0
554 0 $self->{error_msg} = q{No db handle available};
555 0 return;
556 }
557 0 ▶ return unless my $dist_obj = $self->{obj}->{dists};
Branch: 1 branch
BranchTrueFalseTotal
unless my $dist_obj = $self->{"obj"}{"dists"} 0 0 0
558 0 my $cdbi = $self->{cdbi};
559 0 my $data = $dist_obj->{delete};
560 0 ▶ if (has_hash_data($data)) {
Branch: 1 branch
BranchTrueFalseTotal
if (has_hash_data($data)) 0 0 0
561 0 my $sth = $cdbi->sth_delete('dist_id');
562 0 foreach my $distname (keys %$data) {
563 0 ▶ $sth->execute($data->{$distname}) or do {
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute($data->{$distname}) or do { $cdbi->db_error($sth); $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 0 0
564 0 $cdbi->db_error($sth);
565 0 $self->{error_msg} = $cdbi->{error_msg};
566 0 return;
567 };
568 }
569 0 $sth->finish();
570 0 undef $sth;
571 }
572  
573 0 $data = $self->{delete};
574 0 ▶ if (has_hash_data($data)) {
Branch: 1 branch
BranchTrueFalseTotal
if (has_hash_data($data)) 0 0 0
575 0 my $sth = $cdbi->sth_delete('mod_id');
576 0 foreach my $modname (keys %$data) {
577 0 ▶ $sth->execute($data->{$modname}) or do {
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute($data->{$modname}) or do { $cdbi->db_error($sth); $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 0 0
578 0 $cdbi->db_error($sth);
579 0 $self->{error_msg} = $cdbi->{error_msg};
580 0 return;
581 };
582 0 print_debug("Deleting $modname\n");
583 }
584 0 $sth->finish;
585 0 undef $sth;
586 }
587 0 ▶ $dbh->commit() or do {
Branch: 1 branch
BranchTrueFalseTotal
$CPAN::SQLite::Populate::dbh->commit or do { $cdbi->db_error; $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 0 0
588 0 $cdbi->db_error();
589 0 $self->{error_msg} = $cdbi->{error_msg};
590 0 return;
591 };
592 0 return 1;
593 }
594  
595 package CPAN::SQLite::Populate::info;
596 8 ▶use parent 'CPAN::SQLite::Populate';
Subroutine BEGIN: called CC=1 SCAR=0.0
597 8 ▶use CPAN::SQLite::Util qw(has_hash_data print_debug);
Subroutine BEGIN: called CC=1 SCAR=0.0
598  
599 sub new {
600 4 ▶ my ($class, %args) = @_;
Subroutine new: called CC=3 SCAR=11.8
601 4 my $cdbi = $args{cdbi};
602 4 ▶ die "No dbi object available"
Branch: 1 branch
BranchTrueFalseTotal
unless $cdbi and ref $cdbi eq "CPAN::SQLite::DBI::Index::info" 0 4 4
Condition33%1/3
$cdbi and ref $cdbi eq "CPAN::SQLite::DBI::Index::info"
!ll&&!rl&&r
004
MC/DC0%0/2
$cdbi and ref $cdbi eq "CPAN::SQLite::DBI::Index::info"
$cdbi ref $cdbi eq "CPAN::SQLite::DBI::Index::info"
Truth table33%1/3
A and B
A= $cdbiB= ref $cdbi eq "CPAN::SQLite::DBI::Index::info"
ABresult
0X0
100
111
603 unless ($cdbi and ref($cdbi) eq 'CPAN::SQLite::DBI::Index::info');
604 4 my $self = {
605 obj => {},
606 cdbi => $cdbi,
607 error_msg => '',
608 info_msg => '',
609 };
610 4 return bless $self, $class;
611 }
612  
613 sub insert {
614 4 ▶ my $self = shift;
Subroutine insert: called CC=5 SCAR=21.4
615 4 ▶ unless ($dbh) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($CPAN::SQLite::Populate::dbh) 0 4 4
616 0 $self->{error_msg} = q{No db handle available};
617 0 return;
618 }
619 4 my $cdbi = $self->{cdbi};
620  
621 4 ▶ my $sth = $cdbi->sth_insert(['status']) or do {
Branch: 1 branch
BranchTrueFalseTotal
my $sth = $cdbi->sth_insert(["status"]) or do { $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 4 4
622 0 $self->{error_msg} = $cdbi->{error_msg};
623 0 return;
624 };
625 $sth->execute(1)
626 4 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute(1) or do { $cdbi->db_error($sth); $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 4 4
627 0 $cdbi->db_error($sth);
628 0 $self->{error_msg} = $cdbi->{error_msg};
629 0 return;
630 };
631 4 $sth->finish();
632 4 undef $sth;
633 4 ▶ $dbh->commit() or do {
Branch: 1 branch
BranchTrueFalseTotal
$CPAN::SQLite::Populate::dbh->commit or do { $cdbi->db_error; $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 4 4
634 0 $cdbi->db_error();
635 0 $self->{error_msg} = $cdbi->{error_msg};
636 0 return;
637 };
638 4 return 1;
639 }
640  
641 sub update {
642 0 ▶ my $self = shift;
Subroutine update: not called CC=1 SCAR=6.9
643 0 $self->{'error_msg'} = 'update is not a valid call';
644 0 return;
645 }
646  
647 sub delete {
648 4 ▶ my $self = shift;
Subroutine delete: called CC=4 SCAR=17.5
649 4 ▶ unless ($dbh) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($CPAN::SQLite::Populate::dbh) 0 4 4
650 0 $self->{error_msg} = q{No db handle available};
651 0 return;
652 }
653 4 my $cdbi = $self->{cdbi};
654  
655 4 my $sth = $cdbi->sth_delete('status');
656 4 ▶ $sth->execute(1) or do {
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute(1) or do { $cdbi->db_error($sth); $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 4 4
657 0 $cdbi->db_error($sth);
658 0 $self->{error_msg} = $cdbi->{error_msg};
659 0 return;
660 };
661 4 $sth->finish();
662 4 undef $sth;
663 4 ▶ $dbh->commit() or do {
Branch: 1 branch
BranchTrueFalseTotal
$CPAN::SQLite::Populate::dbh->commit or do { $cdbi->db_error; $self->{"error_msg"} = $cdbi->{"error_msg"}; return } 0 4 4
664 0 $cdbi->db_error();
665 0 $self->{error_msg} = $cdbi->{error_msg};
666 0 return;
667 };
668 4 return 1;
669 }
670  
671 package CPAN::SQLite::Populate;
672  
673 sub db_error {
674 0 ▶ my ($obj, $sth) = @_;
Subroutine db_error: not called CC=3 SCAR=24.8
Pod undocumented
675 0 ▶ return unless $dbh;
Branch: 1 branch
BranchTrueFalseTotal
unless $CPAN::SQLite::Populate::dbh 0 0 0
676 0 ▶ if ($sth) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sth) 0 0 0
677 0 $sth->finish;
678 0 undef $sth;
679 }
680 0 return $obj->{error_msg} = q{Database error: } . $dbh->errstr;
681 }
682  
683 8 1;
684  
685 =head1 NAME
686  
687 CPAN::SQLite::Populate - create and populate database tables
688  
689 =head1 VERSION
690  
691 version 0.218
692  
693 =head1 DESCRIPTION
694  
695 This module is responsible for creating the tables
696 (if C<setup> is passed as an option) and then for
697 inserting, updating, or deleting (as appropriate) the
698 relevant information from the indices of
699 I<CPAN::SQLite::Info> and the
700 state information from I<CPAN::SQLite::State>. It does
701 this through the C<insert>, C<update>, and C<delete>
702 methods associated with each table.
703  
704 Note that the tables are created with the C<setup> argument
705 passed into the C<new> method when creating the
706 C<CPAN::SQLite::Index> object; existing tables will be
707 dropped.
708  
709 =head1 TABLES
710  
711 The tables used are described below - the data types correspond
712 to mysql tables, with the corresponding adjustments made if
713 the SQLite database is used.
714  
715 =head2 mods
716  
717 This table contains module information, and is created as
718  
719 mod_id INTEGER NOT NULL PRIMARY KEY
720 mod_name VARCHAR(100) NOT NULL
721 dist_id INTEGER NOT NULL
722 mod_abs TEXT
723 mod_vers VARCHAR(10)
724  
725 =over 3
726  
727 =item * mod_id
728  
729 This is the primary (unique) key of the table.
730  
731 =item * dist_id
732  
733 This key corresponds to the id of the associated distribution
734 in the C<dists> table.
735  
736 =item * mod_name
737  
738 This is the module's name.
739  
740 =item * mod_abs
741  
742 This is a description, if available, of the module.
743  
744 =item * mod_vers
745  
746 This value, if present, gives the version of the module.
747  
748 =back
749  
750 =head2 dists
751  
752 This table contains distribution information, and is created as
753  
754 dist_id INTEGER NOT NULL PRIMARY KEY
755 dist_name VARCHAR(90) NOT NULL
756 auth_id INTEGER NOT NULL
757 dist_file VARCHAR(110) NOT NULL
758 dist_vers VARCHAR(20)
759 dist_abs TEXT
760  
761 =over 3
762  
763 =item * dist_id
764  
765 This is the primary (unique) key of the table.
766  
767 =item * auth_id
768  
769 This corresponds to the CPAN author id of the distribution
770 in the C<auths> table.
771  
772 =item * dist_name
773  
774 This corresponds to the distribution name (eg, for
775 F<My-Distname-0.22.tar.gz>, C<dist_name> will be C<My-Distname>).
776  
777 =item * dist_file
778  
779 This corresponds to the CPAN file name.
780  
781 =item * dist_vers
782  
783 This is the version of the CPAN file (eg, for
784 F<My-Distname-0.22.tar.gz>, C<dist_vers> will be C<0.22>).
785  
786 =item * dist_abs
787  
788 This is a description of the distribution. If not directly
789 supplied, the description for, eg, C<Foo::Bar>, if present, will
790 be used for the C<Foo-Bar> distribution.
791  
792 =back
793  
794 =head2 auths
795  
796 This table contains CPAN author information, and is created as
797  
798 auth_id INTEGER NOT NULL PRIMARY KEY
799 cpanid VARCHAR(20) NOT NULL
800 fullname VARCHAR(40) NOT NULL
801 email TEXT
802  
803 =over 3
804  
805 =item * auth_id
806  
807 This is the primary (unique) key of the table.
808  
809 =item * cpanid
810  
811 This gives the CPAN author id.
812  
813 =item * fullname
814  
815 This is the full name of the author.
816  
817 =item * email
818  
819 This is the supplied email address of the author.
820  
821 =back
822  
823 =head1 SEE ALSO
824  
825 L<CPAN::SQLite::Index>
826  
827 =cut
↑ Summary SQLite/State.pm »