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
|
|
25832
|
use strict; |
|
13
|
|
|
|
|
33
|
|
|
13
|
|
|
|
|
431
|
|
7
|
13
|
|
|
13
|
|
90
|
use warnings; |
|
13
|
|
|
|
|
32
|
|
|
13
|
|
|
|
|
525
|
|
8
|
13
|
|
|
13
|
|
84
|
use base qw(ClearPress::driver); |
|
13
|
|
|
|
|
31
|
|
|
13
|
|
|
|
|
1343
|
|
9
|
13
|
|
|
13
|
|
184
|
use Carp; |
|
13
|
|
|
|
|
50
|
|
|
13
|
|
|
|
|
989
|
|
10
|
13
|
|
|
13
|
|
106
|
use English qw(-no_match_vars); |
|
13
|
|
|
|
|
33
|
|
|
13
|
|
|
|
|
106
|
|
11
|
13
|
|
|
13
|
|
6158
|
use Readonly; |
|
13
|
|
|
|
|
35
|
|
|
13
|
|
|
|
|
6459
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = q[477.1.4]; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Readonly::Scalar our $TYPES => { |
16
|
|
|
|
|
|
|
'primary key' => 'integer primary key autoincrement', |
17
|
|
|
|
|
|
|
'char(128)' => 'text', |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
sub dbh { |
20
|
457
|
|
|
457
|
1
|
2084
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
457
|
100
|
|
|
|
2813
|
if(!$self->{dbh}) { |
23
|
|
|
|
|
|
|
my $dsn = sprintf q(DBI:SQLite:dbname=%s), |
24
|
16
|
|
50
|
|
|
146
|
$self->{dbname} || q[]; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
eval { |
27
|
16
|
|
|
|
|
228
|
$self->{dbh} = DBI->connect($dsn, q[], q[], |
28
|
|
|
|
|
|
|
{RaiseError => 1, |
29
|
|
|
|
|
|
|
AutoCommit => 0}); |
30
|
16
|
50
|
|
|
|
51
|
} 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
|
|
|
|
|
32376
|
$self->{dbh}->rollback(); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
457
|
|
|
|
|
3002
|
return $self->{dbh}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub create { |
45
|
17
|
|
|
17
|
1
|
111
|
my ($self, $query, @args) = @_; |
46
|
17
|
|
|
|
|
75
|
my $dbh = $self->dbh(); |
47
|
|
|
|
|
|
|
|
48
|
17
|
|
|
|
|
266
|
$dbh->do($query, {}, @args); |
49
|
|
|
|
|
|
|
|
50
|
17
|
|
|
|
|
10528
|
my ($table) = $query =~ /INTO\s+([[:lower:][:digit:]_]+)/smix; |
51
|
17
|
|
|
|
|
73
|
my $sequence = q[SELECT seq FROM sqlite_sequence WHERE name=?]; |
52
|
17
|
|
|
|
|
398
|
my $idref = $dbh->selectall_arrayref($sequence, {}, $table); |
53
|
|
|
|
|
|
|
|
54
|
17
|
|
|
|
|
2887
|
return $idref->[0]->[0]; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub types { |
58
|
407
|
|
|
407
|
1
|
4196
|
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__ |