| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Apache::Session::Store::SQLite3; |
|
2
|
|
|
|
|
|
|
$Apache::Session::Store::SQLite3::VERSION = '0.03'; |
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
29
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use base 'Apache::Session::Store::DBI'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
903
|
|
|
6
|
1
|
|
|
1
|
|
809
|
use vars qw($TableName $DataSource $UserName $Password); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
74
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use DBI qw(:sql_types); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
625
|
|
|
9
|
1
|
|
|
1
|
|
7
|
use Apache::Session::Store::DBI; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
723
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub connection { |
|
12
|
3
|
|
|
3
|
0
|
103
|
my $self = shift; |
|
13
|
3
|
|
|
|
|
7
|
my $session = shift; |
|
14
|
|
|
|
|
|
|
|
|
15
|
3
|
100
|
|
|
|
29
|
$self->_connection($session) unless defined $self->{dbh}; |
|
16
|
|
|
|
|
|
|
|
|
17
|
3
|
|
|
|
|
51
|
my $tables = $self->{dbh}->selectall_arrayref(qq[ |
|
18
|
|
|
|
|
|
|
SELECT name |
|
19
|
|
|
|
|
|
|
FROM sqlite_master |
|
20
|
|
|
|
|
|
|
WHERE type = 'table' |
|
21
|
|
|
|
|
|
|
AND name = ? |
|
22
|
|
|
|
|
|
|
], {}, $self->{table_name}); |
|
23
|
|
|
|
|
|
|
|
|
24
|
3
|
100
|
|
|
|
2252
|
$self->{dbh}->do(qq[ |
|
25
|
|
|
|
|
|
|
CREATE TABLE $self->{table_name} ( |
|
26
|
|
|
|
|
|
|
id char(32) NOT NULL, |
|
27
|
|
|
|
|
|
|
a_session LONGBLOB, |
|
28
|
|
|
|
|
|
|
LastUpdated TIMESTAMP, |
|
29
|
|
|
|
|
|
|
PRIMARY KEY (id) |
|
30
|
|
|
|
|
|
|
); |
|
31
|
|
|
|
|
|
|
]) if !@$tables; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _connection { |
|
35
|
2
|
|
|
2
|
|
5
|
my $self = shift; |
|
36
|
2
|
|
|
|
|
4
|
my $session = shift; |
|
37
|
|
|
|
|
|
|
|
|
38
|
2
|
|
33
|
|
|
113
|
$self->{'table_name'} = $session->{args}->{TableName} |
|
39
|
|
|
|
|
|
|
|| $TableName |
|
40
|
|
|
|
|
|
|
|| $Apache::Session::Store::DBI::TableName; |
|
41
|
|
|
|
|
|
|
|
|
42
|
2
|
50
|
|
|
|
10
|
if (exists $session->{args}->{Handle}) { |
|
43
|
0
|
|
|
|
|
0
|
$self->{dbh} = $session->{args}->{Handle}; |
|
44
|
0
|
|
|
|
|
0
|
return; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
2
|
|
33
|
|
|
8
|
my $datasource = $session->{args}->{DataSource} || $DataSource; |
|
48
|
2
|
|
33
|
|
|
9
|
my $username = $session->{args}->{UserName} || $UserName; |
|
49
|
2
|
|
33
|
|
|
39
|
my $password = $session->{args}->{Password} || $Password; |
|
50
|
|
|
|
|
|
|
|
|
51
|
2
|
50
|
|
|
|
23
|
$self->{dbh} = DBI->connect( |
|
52
|
|
|
|
|
|
|
$datasource, |
|
53
|
|
|
|
|
|
|
$username, |
|
54
|
|
|
|
|
|
|
$password, |
|
55
|
|
|
|
|
|
|
{ RaiseError => 1, AutoCommit => 1 } |
|
56
|
|
|
|
|
|
|
) or die $DBI::errstr; |
|
57
|
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
1311
|
$self->{disconnect} = 1; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub insert { |
|
62
|
1
|
|
|
1
|
0
|
342
|
my $self = shift; |
|
63
|
1
|
|
|
|
|
3
|
my $session = shift; |
|
64
|
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
6
|
$self->connection($session); |
|
66
|
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
696383
|
local $self->{dbh}->{RaiseError} = 1; |
|
68
|
|
|
|
|
|
|
|
|
69
|
1
|
50
|
|
|
|
9
|
if (!defined $self->{insert_sth}) { |
|
70
|
1
|
|
|
|
|
43
|
$self->{insert_sth} = $self->{dbh}->prepare_cached(qq[ |
|
71
|
|
|
|
|
|
|
INSERT INTO $self->{'table_name'} (id, a_session, LastUpdated) |
|
72
|
|
|
|
|
|
|
VALUES (?, ?, ?) |
|
73
|
|
|
|
|
|
|
]); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
147
|
$self->{insert_sth}->bind_param(1, $session->{data}->{_session_id}, SQL_CHAR); |
|
77
|
1
|
|
|
|
|
7
|
$self->{insert_sth}->bind_param(2, $session->{serialized}, SQL_BLOB); |
|
78
|
1
|
|
|
|
|
7
|
$self->{insert_sth}->bind_param(3, time, SQL_INTEGER); |
|
79
|
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
26865
|
$self->{insert_sth}->execute; |
|
81
|
1
|
|
|
|
|
44
|
$self->{insert_sth}->finish; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub update { |
|
85
|
1
|
|
|
1
|
0
|
2000
|
my $self = shift; |
|
86
|
1
|
|
|
|
|
4
|
my $session = shift; |
|
87
|
|
|
|
|
|
|
|
|
88
|
1
|
|
|
|
|
6
|
$self->connection($session); |
|
89
|
|
|
|
|
|
|
|
|
90
|
1
|
|
|
|
|
23
|
local $self->{dbh}->{RaiseError} = 1; |
|
91
|
|
|
|
|
|
|
|
|
92
|
1
|
50
|
|
|
|
9
|
if (!defined $self->{update_sth}) { |
|
93
|
1
|
|
|
|
|
14
|
$self->{update_sth} = $self->{dbh}->prepare_cached(qq[ |
|
94
|
|
|
|
|
|
|
UPDATE $self->{'table_name'} |
|
95
|
|
|
|
|
|
|
SET a_session = ?, LastUpdated = ? |
|
96
|
|
|
|
|
|
|
WHERE id = ? |
|
97
|
|
|
|
|
|
|
]); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
779
|
$self->{update_sth}->bind_param(1, $session->{serialized}, SQL_BLOB); |
|
101
|
1
|
|
|
|
|
8
|
$self->{update_sth}->bind_param(2, time, SQL_INTEGER); |
|
102
|
1
|
|
|
|
|
9
|
$self->{update_sth}->bind_param(3, $session->{data}->{_session_id}, SQL_CHAR); |
|
103
|
|
|
|
|
|
|
|
|
104
|
1
|
|
|
|
|
4
|
foreach my $count (1..600) { |
|
105
|
1
|
|
|
|
|
3
|
local $@; |
|
106
|
1
|
50
|
|
|
|
3
|
eval { $self->{update_sth}->execute; 1 } and last; |
|
|
1
|
|
|
|
|
9410
|
|
|
|
1
|
|
|
|
|
28
|
|
|
107
|
0
|
|
|
|
|
0
|
sleep 1; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
1
|
|
|
|
|
55
|
$self->{update_sth}->finish; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |