line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::CPANIDX::Tables; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
3252
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
92
|
|
4
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
73
|
|
5
|
2
|
|
|
2
|
|
13
|
use Module::CoreList::DBSchema; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
58
|
|
6
|
2
|
|
|
2
|
|
11
|
use vars qw[$VERSION]; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1054
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$VERSION = '0.36'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $mcdbs = Module::CoreList::DBSchema->new(); |
11
|
|
|
|
|
|
|
my %cl_tables = $mcdbs->tables(); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $tables = { |
14
|
|
|
|
|
|
|
mods => [ |
15
|
|
|
|
|
|
|
'mod_name VARCHAR(300) NOT NULL', |
16
|
|
|
|
|
|
|
'dist_name VARCHAR(190) NOT NULL', |
17
|
|
|
|
|
|
|
'dist_vers VARCHAR(50)', |
18
|
|
|
|
|
|
|
'cpan_id VARCHAR(20) NOT NULL', |
19
|
|
|
|
|
|
|
'mod_vers VARCHAR(30)', |
20
|
|
|
|
|
|
|
], |
21
|
|
|
|
|
|
|
dists => [ |
22
|
|
|
|
|
|
|
'dist_name VARCHAR(190) NOT NULL', |
23
|
|
|
|
|
|
|
'cpan_id VARCHAR(20) NOT NULL', |
24
|
|
|
|
|
|
|
'dist_file VARCHAR(400) NOT NULL', |
25
|
|
|
|
|
|
|
'dist_vers VARCHAR(50)', |
26
|
|
|
|
|
|
|
], |
27
|
|
|
|
|
|
|
auths => [ |
28
|
|
|
|
|
|
|
'cpan_id VARCHAR(20) NOT NULL', |
29
|
|
|
|
|
|
|
'fullname VARCHAR(60) NOT NULL', |
30
|
|
|
|
|
|
|
'email TEXT', |
31
|
|
|
|
|
|
|
], |
32
|
|
|
|
|
|
|
timestamp => [ |
33
|
|
|
|
|
|
|
'timestamp VARCHAR(30) NOT NULL', |
34
|
|
|
|
|
|
|
'lastupdated VARCHAR(30) NOT NULL', |
35
|
|
|
|
|
|
|
], |
36
|
|
|
|
|
|
|
mirrors => [ |
37
|
|
|
|
|
|
|
'hostname VARCHAR(50) NOT NULL', |
38
|
|
|
|
|
|
|
'dst_bandwidth VARCHAR(50)', |
39
|
|
|
|
|
|
|
'dst_contact VARCHAR(60)', |
40
|
|
|
|
|
|
|
'dst_ftp VARCHAR(250)', |
41
|
|
|
|
|
|
|
'dst_http VARCHAR(250)', |
42
|
|
|
|
|
|
|
'dst_location TEXT', |
43
|
|
|
|
|
|
|
'dst_notes TEXT', |
44
|
|
|
|
|
|
|
'dst_organisation TEXT', |
45
|
|
|
|
|
|
|
'dst_rsync VARCHAR(250)', |
46
|
|
|
|
|
|
|
'dst_src VARCHAR(250)', |
47
|
|
|
|
|
|
|
'dst_timezone VARCHAR(20)', |
48
|
|
|
|
|
|
|
'frequency VARCHAR(100)', |
49
|
|
|
|
|
|
|
], |
50
|
|
|
|
|
|
|
perms => [ |
51
|
|
|
|
|
|
|
'mod_name VARCHAR(300) NOT NULL', |
52
|
|
|
|
|
|
|
'cpan_id VARCHAR(20) NOT NULL', |
53
|
|
|
|
|
|
|
'perm VARCHAR(20)', |
54
|
|
|
|
|
|
|
], |
55
|
|
|
|
|
|
|
%cl_tables, |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $indexes = { |
59
|
|
|
|
|
|
|
mods => [ |
60
|
|
|
|
|
|
|
'CREATE INDEX mods_mod_name ON mods ( mod_name )', |
61
|
|
|
|
|
|
|
'CREATE INDEX mods_dist_name ON mods ( dist_name )', |
62
|
|
|
|
|
|
|
'CREATE INDEX mods_dist_vers ON mods ( dist_vers )', |
63
|
|
|
|
|
|
|
'CREATE INDEX mods_all ON mods ( mod_name, dist_name, dist_vers )', |
64
|
|
|
|
|
|
|
], |
65
|
|
|
|
|
|
|
dists => [ |
66
|
|
|
|
|
|
|
'CREATE INDEX dists_dist_name ON dists ( dist_name )', |
67
|
|
|
|
|
|
|
'CREATE INDEX dists_dist_vers ON dists ( dist_vers )', |
68
|
|
|
|
|
|
|
'CREATE INDEX dists_cpan_id ON dists ( cpan_id )', |
69
|
|
|
|
|
|
|
'CREATE INDEX dists_all ON dists ( dist_name, dist_vers )', |
70
|
|
|
|
|
|
|
], |
71
|
|
|
|
|
|
|
auths => [ |
72
|
|
|
|
|
|
|
'CREATE INDEX auths_cpan_id ON auths ( cpan_id )', |
73
|
|
|
|
|
|
|
], |
74
|
|
|
|
|
|
|
perms => [ |
75
|
|
|
|
|
|
|
'CREATE INDEX perms_mod_name ON perms ( mod_name )', |
76
|
|
|
|
|
|
|
'CREATE INDEX perms_cpan_id ON perms ( cpan_id )', |
77
|
|
|
|
|
|
|
], |
78
|
|
|
|
|
|
|
}; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# make the temp mappings |
81
|
|
|
|
|
|
|
foreach my $k ( qw( mirrors mods dists auths perms ), keys %cl_tables ) { |
82
|
|
|
|
|
|
|
$tables->{ 'tmp_' . $k } = $tables->{ $k }; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub table { |
86
|
21
|
50
|
|
21
|
1
|
12258
|
return unless @_; |
87
|
21
|
|
|
|
|
31
|
my $table = shift; |
88
|
21
|
50
|
|
|
|
144
|
$table = shift if $table->isa(__PACKAGE__); |
89
|
21
|
50
|
|
|
|
47
|
return unless $table; |
90
|
21
|
50
|
|
|
|
48
|
return unless exists $tables->{ $table }; |
91
|
21
|
|
|
|
|
58
|
my $sql = 'CREATE TABLE IF NOT EXISTS ' . $table . ' ( '; |
92
|
21
|
|
|
|
|
27
|
$sql .= join ', ', @{ $tables->{$table} }; |
|
21
|
|
|
|
|
100
|
|
93
|
21
|
|
|
|
|
29
|
$sql .= ' )'; |
94
|
21
|
|
|
|
|
65
|
return $sql; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub index { |
98
|
0
|
0
|
|
0
|
1
|
0
|
return unless @_; |
99
|
0
|
|
|
|
|
0
|
my $table = shift; |
100
|
0
|
0
|
|
|
|
0
|
$table = shift if $table->isa(__PACKAGE__); |
101
|
0
|
0
|
|
|
|
0
|
return unless $table; |
102
|
0
|
0
|
|
|
|
0
|
return unless exists $indexes->{ $table }; |
103
|
0
|
|
|
|
|
0
|
return [ @{ $indexes->{ $table } } ]; |
|
0
|
|
|
|
|
0
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub tables { |
107
|
1
|
|
|
1
|
1
|
729
|
return sort keys %{ $tables }; |
|
1
|
|
|
|
|
18
|
|
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
__END__ |