line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Fixture::DBI::Util::SQLite; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
909
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
296
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.09'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub make_database { |
9
|
0
|
|
|
0
|
1
|
|
my ( $class, $dbh ) = @_; |
10
|
|
|
|
|
|
|
|
11
|
0
|
|
|
|
|
|
my $rows = $dbh->selectall_arrayref( |
12
|
|
|
|
|
|
|
q|SELECT name, type, tbl_name, sql FROM sqlite_master WHERE sql IS NOT NULL ORDER BY type|, |
13
|
|
|
|
|
|
|
+{ Slice => +{} }, |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
my @database; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
### retrieve table and view |
19
|
0
|
|
|
|
|
|
push( @database, |
20
|
0
|
0
|
|
|
|
|
map { +{ schema => $_->{name}, data => $_->{sql}, } } |
21
|
0
|
0
|
|
|
|
|
sort { $a->{type} cmp $b->{type} || $a->{name} cmp $b->{name} } |
22
|
0
|
|
|
|
|
|
grep { $_->{type} eq 'table' || $_->{type} eq 'view' } @$rows ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
### retrive trigger |
25
|
0
|
|
|
|
|
|
push( |
26
|
|
|
|
|
|
|
@database, |
27
|
0
|
|
|
|
|
|
sort { $a->{trigger} cmp $b->{trigger} } |
28
|
|
|
|
|
|
|
map { |
29
|
0
|
|
|
|
|
|
+{ |
30
|
|
|
|
|
|
|
trigger => $_->{name}, |
31
|
|
|
|
|
|
|
refer => $_->{tbl_name}, |
32
|
|
|
|
|
|
|
data => $_->{sql}, |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
0
|
|
|
|
|
|
grep { $_->{type} eq 'trigger' } @$rows |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
### retrive index |
39
|
0
|
|
|
|
|
|
push( |
40
|
|
|
|
|
|
|
@database, |
41
|
0
|
|
|
|
|
|
sort { $a->{index} cmp $b->{index} } |
42
|
|
|
|
|
|
|
map { |
43
|
0
|
|
|
|
|
|
+{ |
44
|
|
|
|
|
|
|
index => $_->{name}, |
45
|
|
|
|
|
|
|
refer => $_->{tbl_name}, |
46
|
|
|
|
|
|
|
data => $_->{sql}, |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
grep { $_->{type} eq 'index' } @$rows |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return \@database; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |