line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Apache::Voodoo::Debug::Native::SQLite; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = "3.0200"; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
1471
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use DBI; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use base("Apache::Voodoo::Debug::Native::common"); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
683
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
14
|
0
|
|
|
|
|
|
my $self = {}; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
bless $self,$class; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
$self->{version} = '1'; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
return $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub init_db { |
24
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my $dbh = shift; |
27
|
0
|
|
|
|
|
|
my $ac = shift; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# find the name of the connected database file |
30
|
0
|
0
|
|
|
|
|
my @f = grep {$_->[1] eq "main" } @{$dbh->selectall_arrayref("pragma database_list") || $self->db_error()}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# make sure it's owned by apache |
33
|
0
|
|
|
|
|
|
chown($ac->apache_uid,$ac->apache_gid,$f[0]->[2]); |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
$self->{dbh} = $dbh; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
0
|
|
|
|
my $tables = $dbh->selectcol_arrayref(" |
38
|
|
|
|
|
|
|
SELECT |
39
|
|
|
|
|
|
|
name |
40
|
|
|
|
|
|
|
FROM |
41
|
|
|
|
|
|
|
sqlite_master |
42
|
|
|
|
|
|
|
WHERE |
43
|
|
|
|
|
|
|
type='table' AND |
44
|
|
|
|
|
|
|
name NOT LIKE 'sqlite%' |
45
|
|
|
|
|
|
|
") || $self->db_error(); |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
$self->debug($tables); |
48
|
0
|
0
|
|
|
|
|
if (grep {$_ eq 'version'} @{$tables}) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
49
|
0
|
|
0
|
|
|
|
my $res = $dbh->selectall_arrayref("SELECT version FROM version") || $self->db_error(); |
50
|
0
|
0
|
|
|
|
|
if ($res->[0]->[0] eq $self->{version}) { |
51
|
0
|
|
|
|
|
|
return; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
foreach my $table (@{$tables}) { |
|
0
|
|
|
|
|
|
|
56
|
0
|
0
|
|
|
|
|
$dbh->do("DROP TABLE $table") || $self->db_error(); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$self->create_schema(); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub last_insert_id { |
63
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
0
|
|
|
|
my $res = $self->{dbh}->selectall_arrayref("SELECT last_insert_rowid()") || $self->db_error(); |
66
|
0
|
|
|
|
|
|
return $res->[0]->[0]; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub _pkey_syntax { |
70
|
0
|
|
|
0
|
|
|
return "integer not null primary key autoincrement"; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
################################################################################ |
76
|
|
|
|
|
|
|
# Copyright (c) 2005-2010 Steven Edwards (maverick@smurfbane.org). |
77
|
|
|
|
|
|
|
# All rights reserved. |
78
|
|
|
|
|
|
|
# |
79
|
|
|
|
|
|
|
# You may use and distribute Apache::Voodoo under the terms described in the |
80
|
|
|
|
|
|
|
# LICENSE file include in this package. The summary is it's a legalese version |
81
|
|
|
|
|
|
|
# of the Artistic License :) |
82
|
|
|
|
|
|
|
# |
83
|
|
|
|
|
|
|
################################################################################ |