line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Fixture::DBI::Util::SQLite; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
354
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
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
|
|
|
|
|
|
|
push( @database, |
20
|
0
|
|
|
|
|
|
map { +{ schema => $_->{name}, data => $_->{sql}, } } |
21
|
0
|
0
|
|
|
|
|
sort { $a->{type} cmp $b->{type} || $a->{name} cmp $b->{name} } |
22
|
0
|
0
|
|
|
|
|
grep { $_->{type} eq 'table' || $_->{type} eq 'view' } @$rows ); |
|
0
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
### retrive trigger |
25
|
|
|
|
|
|
|
push( |
26
|
|
|
|
|
|
|
@database, |
27
|
0
|
|
|
|
|
|
sort { $a->{trigger} cmp $b->{trigger} } |
28
|
|
|
|
|
|
|
map { |
29
|
|
|
|
|
|
|
+{ |
30
|
|
|
|
|
|
|
trigger => $_->{name}, |
31
|
|
|
|
|
|
|
refer => $_->{tbl_name}, |
32
|
|
|
|
|
|
|
data => $_->{sql}, |
33
|
|
|
|
|
|
|
} |
34
|
0
|
|
|
|
|
|
} |
35
|
0
|
|
|
|
|
|
grep { $_->{type} eq 'trigger' } @$rows |
|
0
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
### retrive index |
39
|
|
|
|
|
|
|
push( |
40
|
|
|
|
|
|
|
@database, |
41
|
0
|
|
|
|
|
|
sort { $a->{index} cmp $b->{index} } |
42
|
|
|
|
|
|
|
map { |
43
|
|
|
|
|
|
|
+{ |
44
|
|
|
|
|
|
|
index => $_->{name}, |
45
|
|
|
|
|
|
|
refer => $_->{tbl_name}, |
46
|
|
|
|
|
|
|
data => $_->{sql}, |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
grep { $_->{type} eq 'index' } @$rows |
|
0
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return \@database; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |