line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
######### |
2
|
|
|
|
|
|
|
# Author: rmp |
3
|
|
|
|
|
|
|
# Created: 2006-10-31 |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
package ClearPress::driver::SQLite; |
6
|
13
|
|
|
13
|
|
25976
|
use strict; |
|
13
|
|
|
|
|
30
|
|
|
13
|
|
|
|
|
355
|
|
7
|
13
|
|
|
13
|
|
68
|
use warnings; |
|
13
|
|
|
|
|
23
|
|
|
13
|
|
|
|
|
380
|
|
8
|
13
|
|
|
13
|
|
88
|
use base qw(ClearPress::driver); |
|
13
|
|
|
|
|
26
|
|
|
13
|
|
|
|
|
1135
|
|
9
|
13
|
|
|
13
|
|
88
|
use Carp; |
|
13
|
|
|
|
|
30
|
|
|
13
|
|
|
|
|
744
|
|
10
|
13
|
|
|
13
|
|
92
|
use English qw(-no_match_vars); |
|
13
|
|
|
|
|
34
|
|
|
13
|
|
|
|
|
87
|
|
11
|
13
|
|
|
13
|
|
4734
|
use Readonly; |
|
13
|
|
|
|
|
28
|
|
|
13
|
|
|
|
|
5002
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = q[476.4.2]; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Readonly::Scalar our $TYPES => { |
16
|
|
|
|
|
|
|
'primary key' => 'integer primary key autoincrement', |
17
|
|
|
|
|
|
|
'char(128)' => 'text', |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
sub dbh { |
20
|
429
|
|
|
429
|
1
|
1130
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
429
|
100
|
|
|
|
1981
|
if(!$self->{dbh}) { |
23
|
|
|
|
|
|
|
my $dsn = sprintf q(DBI:SQLite:dbname=%s), |
24
|
16
|
|
50
|
|
|
127
|
$self->{dbname} || q[]; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
eval { |
27
|
16
|
|
|
|
|
220
|
$self->{dbh} = DBI->connect($dsn, q[], q[], |
28
|
|
|
|
|
|
|
{RaiseError => 1, |
29
|
|
|
|
|
|
|
AutoCommit => 0}); |
30
|
16
|
50
|
|
|
|
38
|
} or do { |
31
|
0
|
|
|
|
|
0
|
croak qq[Failed to connect to $dsn:\n$EVAL_ERROR]; |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
######### |
35
|
|
|
|
|
|
|
# rollback any junk left behind if this is a cached handle |
36
|
|
|
|
|
|
|
# |
37
|
16
|
|
|
|
|
37101
|
$self->{dbh}->rollback(); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
429
|
|
|
|
|
2335
|
return $self->{dbh}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub create { |
45
|
17
|
|
|
17
|
1
|
80
|
my ($self, $query, @args) = @_; |
46
|
17
|
|
|
|
|
66
|
my $dbh = $self->dbh(); |
47
|
|
|
|
|
|
|
|
48
|
17
|
|
|
|
|
252
|
$dbh->do($query, {}, @args); |
49
|
|
|
|
|
|
|
|
50
|
17
|
|
|
|
|
14324
|
my ($table) = $query =~ /INTO\s+([[:lower:][:digit:]_]+)/smix; |
51
|
17
|
|
|
|
|
66
|
my $sequence = q[SELECT seq FROM sqlite_sequence WHERE name=?]; |
52
|
17
|
|
|
|
|
343
|
my $idref = $dbh->selectall_arrayref($sequence, {}, $table); |
53
|
|
|
|
|
|
|
|
54
|
17
|
|
|
|
|
2372
|
return $idref->[0]->[0]; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub types { |
58
|
407
|
|
|
407
|
1
|
3407
|
return $TYPES; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub bounded_select { |
62
|
0
|
|
|
0
|
1
|
|
my ($self, $query, $len, $start) = @_; |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
0
|
|
|
|
if(defined $start && defined $len) { |
|
|
0
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
$query .= qq[ LIMIT $start, $len]; |
66
|
|
|
|
|
|
|
} elsif(defined $len) { |
67
|
0
|
|
|
|
|
|
$query .= qq[ LIMIT $len]; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
return $query; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
__END__ |