| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# $Id: DBI.pm 82 2020-05-30 06:14:27Z stro $ |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package CPAN::SQLite::DBI; |
|
4
|
8
|
|
|
8
|
|
3331
|
use strict; |
|
|
8
|
|
|
|
|
21
|
|
|
|
8
|
|
|
|
|
240
|
|
|
5
|
8
|
|
|
8
|
|
46
|
use warnings; |
|
|
8
|
|
|
|
|
17
|
|
|
|
8
|
|
|
|
|
394
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.218'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
8
|
|
|
8
|
|
47
|
use English qw/-no_match_vars/; |
|
|
8
|
|
|
|
|
14
|
|
|
|
8
|
|
|
|
|
40
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require File::Spec; |
|
12
|
8
|
|
|
8
|
|
12665
|
use DBI; |
|
|
8
|
|
|
|
|
105588
|
|
|
|
8
|
|
|
|
|
555
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
8
|
|
|
8
|
|
62
|
use parent 'Exporter'; |
|
|
8
|
|
|
|
|
21
|
|
|
|
8
|
|
|
|
|
72
|
|
|
15
|
|
|
|
|
|
|
our ($dbh, $tables, @EXPORT_OK); |
|
16
|
|
|
|
|
|
|
@EXPORT_OK = qw($dbh $tables); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$tables = { |
|
19
|
|
|
|
|
|
|
'info' => { |
|
20
|
|
|
|
|
|
|
'primary' => { |
|
21
|
|
|
|
|
|
|
'status' => q!INTEGER NOT NULL PRIMARY KEY!, |
|
22
|
|
|
|
|
|
|
}, |
|
23
|
|
|
|
|
|
|
'other' => {}, |
|
24
|
|
|
|
|
|
|
'key' => [], |
|
25
|
|
|
|
|
|
|
'name' => 'status', |
|
26
|
|
|
|
|
|
|
'id' => 'status', |
|
27
|
|
|
|
|
|
|
}, |
|
28
|
|
|
|
|
|
|
mods => { |
|
29
|
|
|
|
|
|
|
primary => { mod_id => q{INTEGER NOT NULL PRIMARY KEY} }, |
|
30
|
|
|
|
|
|
|
other => { |
|
31
|
|
|
|
|
|
|
mod_name => q{VARCHAR(100) NOT NULL}, |
|
32
|
|
|
|
|
|
|
dist_id => q{INTEGER NOT NULL}, |
|
33
|
|
|
|
|
|
|
mod_abs => q{TEXT}, |
|
34
|
|
|
|
|
|
|
mod_vers => q{VARCHAR(10)}, |
|
35
|
|
|
|
|
|
|
}, |
|
36
|
|
|
|
|
|
|
key => [qw/dist_id mod_name/], |
|
37
|
|
|
|
|
|
|
name => 'mod_name', |
|
38
|
|
|
|
|
|
|
id => 'mod_id', |
|
39
|
|
|
|
|
|
|
has_a => { dists => 'dist_id' }, |
|
40
|
|
|
|
|
|
|
}, |
|
41
|
|
|
|
|
|
|
dists => { |
|
42
|
|
|
|
|
|
|
primary => { dist_id => q{INTEGER NOT NULL PRIMARY KEY} }, |
|
43
|
|
|
|
|
|
|
other => { |
|
44
|
|
|
|
|
|
|
dist_name => q{VARCHAR(90) NOT NULL}, |
|
45
|
|
|
|
|
|
|
auth_id => q{INTEGER NOT NULL}, |
|
46
|
|
|
|
|
|
|
dist_file => q{VARCHAR(110) NOT NULL}, |
|
47
|
|
|
|
|
|
|
dist_vers => q{VARCHAR(20)}, |
|
48
|
|
|
|
|
|
|
dist_abs => q{TEXT}, |
|
49
|
|
|
|
|
|
|
}, |
|
50
|
|
|
|
|
|
|
key => [qw/auth_id dist_name/], |
|
51
|
|
|
|
|
|
|
name => 'dist_name', |
|
52
|
|
|
|
|
|
|
id => 'dist_id', |
|
53
|
|
|
|
|
|
|
has_a => { auths => 'auth_id' }, |
|
54
|
|
|
|
|
|
|
has_many => { mods => 'dist_id', }, |
|
55
|
|
|
|
|
|
|
}, |
|
56
|
|
|
|
|
|
|
auths => { |
|
57
|
|
|
|
|
|
|
primary => { auth_id => q{INTEGER NOT NULL PRIMARY KEY} }, |
|
58
|
|
|
|
|
|
|
other => { |
|
59
|
|
|
|
|
|
|
cpanid => q{VARCHAR(20) NOT NULL}, |
|
60
|
|
|
|
|
|
|
fullname => q{VARCHAR(40) NOT NULL}, |
|
61
|
|
|
|
|
|
|
email => q{TEXT}, |
|
62
|
|
|
|
|
|
|
}, |
|
63
|
|
|
|
|
|
|
key => [qw/cpanid/], |
|
64
|
|
|
|
|
|
|
has_many => { dists => 'dist_id' }, |
|
65
|
|
|
|
|
|
|
name => 'cpanid', |
|
66
|
|
|
|
|
|
|
id => 'auth_id', |
|
67
|
|
|
|
|
|
|
}, |
|
68
|
|
|
|
|
|
|
}; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub new { |
|
71
|
953
|
|
|
953
|
0
|
1230730
|
my ($class, %args) = @_; |
|
72
|
953
|
|
33
|
|
|
2420
|
my $db_dir = $args{db_dir} || $args{CPAN}; |
|
73
|
953
|
|
|
|
|
9558
|
my $db = File::Spec->catfile($db_dir, $args{db_name}); |
|
74
|
953
|
|
66
|
|
|
3327
|
$dbh ||= DBI->connect( |
|
75
|
|
|
|
|
|
|
"DBI:SQLite:$db", |
|
76
|
|
|
|
|
|
|
'', '', |
|
77
|
|
|
|
|
|
|
{ |
|
78
|
|
|
|
|
|
|
RaiseError => 1, |
|
79
|
|
|
|
|
|
|
AutoCommit => 0, |
|
80
|
|
|
|
|
|
|
sqlite_use_immediate_transaction => 0, |
|
81
|
|
|
|
|
|
|
}); |
|
82
|
953
|
50
|
|
|
|
84322
|
die "Cannot connect to $db" unless $dbh; |
|
83
|
953
|
|
|
|
|
7040
|
$dbh->{AutoCommit} = 0; |
|
84
|
|
|
|
|
|
|
|
|
85
|
953
|
|
|
|
|
2171
|
my $objs; |
|
86
|
953
|
|
|
|
|
3086
|
foreach my $table (keys %$tables) { |
|
87
|
3812
|
|
|
|
|
7198
|
my $cl = $class . '::' . $table; |
|
88
|
3812
|
|
|
|
|
8420
|
$objs->{$table} = $cl->make(table => $table); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
953
|
|
|
|
|
2580
|
for my $table (keys %$tables) { |
|
92
|
3812
|
|
|
|
|
5503
|
foreach my $type (qw(primary other)) { |
|
93
|
7624
|
|
|
|
|
9293
|
foreach my $column (keys %{ $tables->{$table}->{$type} }) { |
|
|
7624
|
|
|
|
|
16637
|
|
|
94
|
15248
|
|
|
|
|
17984
|
push @{ $tables->{$table}->{columns} }, $column; |
|
|
15248
|
|
|
|
|
31566
|
|
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
953
|
|
|
|
|
8157
|
return bless { objs => $objs }, $class; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub make { |
|
103
|
3812
|
|
|
3812
|
0
|
7710
|
my ($class, %args) = @_; |
|
104
|
3812
|
|
|
|
|
5440
|
my $table = $args{table}; |
|
105
|
3812
|
50
|
|
|
|
6827
|
die qq{No table exists corresponding to '$class'} unless $table; |
|
106
|
3812
|
|
|
|
|
5235
|
my $info = $tables->{$table}; |
|
107
|
3812
|
50
|
|
|
|
6240
|
die qq{No information available for table '$table'} unless $info; |
|
108
|
|
|
|
|
|
|
my $self = { |
|
109
|
|
|
|
|
|
|
table => $table, |
|
110
|
|
|
|
|
|
|
columns => $info->{columns}, |
|
111
|
|
|
|
|
|
|
id => $info->{id}, |
|
112
|
|
|
|
|
|
|
name => $info->{name}, |
|
113
|
3812
|
|
|
|
|
11282
|
}; |
|
114
|
3812
|
|
|
|
|
6562
|
foreach (qw(name has_a has_many)) { |
|
115
|
11436
|
100
|
|
|
|
21216
|
next unless defined $info->{$_}; |
|
116
|
7624
|
|
|
|
|
13341
|
$self->{$_} = $info->{$_}; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
3812
|
|
|
|
|
10867
|
return bless $self, $class; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub db_error { |
|
122
|
0
|
|
|
0
|
0
|
|
my ($obj, $sth) = @_; |
|
123
|
0
|
0
|
|
|
|
|
return unless $dbh; |
|
124
|
0
|
0
|
|
|
|
|
if ($sth) { |
|
125
|
0
|
|
|
|
|
|
$sth->finish; |
|
126
|
0
|
|
|
|
|
|
undef $sth; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
0
|
|
|
|
|
|
return $obj->{error_msg} = q{Database error: } . $dbh->errstr; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 NAME |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
CPAN::SQLite::DBI - DBI information for the CPAN::SQLite database |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 VERSION |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
version 0.218 |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This module is used by L and |
|
144
|
|
|
|
|
|
|
L to set up some basic database |
|
145
|
|
|
|
|
|
|
information. It exports two variables: |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=over 3 |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item C<$tables> |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This is a hash reference whose keys are the table names, with |
|
152
|
|
|
|
|
|
|
corresponding values being hash references whose keys are the |
|
153
|
|
|
|
|
|
|
columns of the table and values being the associated data types. |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item C<$dbh> |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This is a L database handle used to connect to the |
|
158
|
|
|
|
|
|
|
database. |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=back |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
The main method of this module is C, which is used |
|
163
|
|
|
|
|
|
|
to make the tables of the database. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
L and L |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |