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
|
|
30313
|
use strict; |
|
13
|
|
|
|
|
35
|
|
|
13
|
|
|
|
|
463
|
|
7
|
13
|
|
|
13
|
|
84
|
use warnings; |
|
13
|
|
|
|
|
32
|
|
|
13
|
|
|
|
|
492
|
|
8
|
13
|
|
|
13
|
|
94
|
use base qw(ClearPress::driver); |
|
13
|
|
|
|
|
37
|
|
|
13
|
|
|
|
|
1433
|
|
9
|
13
|
|
|
13
|
|
172
|
use Carp; |
|
13
|
|
|
|
|
33
|
|
|
13
|
|
|
|
|
931
|
|
10
|
13
|
|
|
13
|
|
94
|
use English qw(-no_match_vars); |
|
13
|
|
|
|
|
36
|
|
|
13
|
|
|
|
|
105
|
|
11
|
13
|
|
|
13
|
|
5620
|
use Readonly; |
|
13
|
|
|
|
|
34
|
|
|
13
|
|
|
|
|
5642
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = q[477.1.2]; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Readonly::Scalar our $TYPES => { |
16
|
|
|
|
|
|
|
'primary key' => 'integer primary key autoincrement', |
17
|
|
|
|
|
|
|
'char(128)' => 'text', |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
sub dbh { |
20
|
445
|
|
|
445
|
1
|
2267
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
445
|
100
|
|
|
|
2598
|
if(!$self->{dbh}) { |
23
|
|
|
|
|
|
|
my $dsn = sprintf q(DBI:SQLite:dbname=%s), |
24
|
16
|
|
50
|
|
|
397
|
$self->{dbname} || q[]; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
eval { |
27
|
16
|
|
|
|
|
261
|
$self->{dbh} = DBI->connect($dsn, q[], q[], |
28
|
|
|
|
|
|
|
{RaiseError => 1, |
29
|
|
|
|
|
|
|
AutoCommit => 0}); |
30
|
16
|
50
|
|
|
|
54
|
} 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
|
|
|
|
|
124399
|
$self->{dbh}->rollback(); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
445
|
|
|
|
|
3541
|
return $self->{dbh}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub create { |
45
|
17
|
|
|
17
|
1
|
90
|
my ($self, $query, @args) = @_; |
46
|
17
|
|
|
|
|
66
|
my $dbh = $self->dbh(); |
47
|
|
|
|
|
|
|
|
48
|
17
|
|
|
|
|
354
|
$dbh->do($query, {}, @args); |
49
|
|
|
|
|
|
|
|
50
|
17
|
|
|
|
|
16870
|
my ($table) = $query =~ /INTO\s+([[:lower:][:digit:]_]+)/smix; |
51
|
17
|
|
|
|
|
66
|
my $sequence = q[SELECT seq FROM sqlite_sequence WHERE name=?]; |
52
|
17
|
|
|
|
|
291
|
my $idref = $dbh->selectall_arrayref($sequence, {}, $table); |
53
|
|
|
|
|
|
|
|
54
|
17
|
|
|
|
|
3488
|
return $idref->[0]->[0]; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub types { |
58
|
407
|
|
|
407
|
1
|
3880
|
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__ |