line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBD::Cassandra::db; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TVDW'; |
3
|
|
|
|
|
|
|
$DBD::Cassandra::db::VERSION = '0.56_003'; # TRIAL |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$DBD::Cassandra::db::VERSION = '0.56003';# ABSTRACT: DBD::Cassandra database handle |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
14
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
8
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
9
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use Devel::GlobalDestruction; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# This cargocult comes straight from DBI::DBD docs. No idea what it does. |
14
|
|
|
|
|
|
|
$DBD::Cassandra::db::imp_data_size = 0; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub prepare { |
17
|
0
|
|
|
0
|
0
|
|
my ($dbh, $statement, $attribs)= @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
0
|
|
|
|
|
if ($attribs->{server_side_prepare}) { |
20
|
0
|
|
|
|
|
|
my $client= $dbh->{cass_client}; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
my ($error)= $client->call_prepare($statement); |
23
|
0
|
0
|
|
|
|
|
if ($error) { |
24
|
0
|
|
|
|
|
|
return $dbh->set_err($DBI::stderr, $error); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my ($outer, $sth)= DBI::_new_sth($dbh, { Statement => $statement }); |
29
|
0
|
|
0
|
|
|
|
$sth->{cass_consistency}= $attribs->{consistency} || $attribs->{Consistency}; |
30
|
0
|
|
0
|
|
|
|
$sth->{cass_page_size}= $attribs->{perpage} || $attribs->{PerPage} || $attribs->{per_page}; |
31
|
0
|
|
|
|
|
|
$sth->{cass_async}= $attribs->{async}; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return $outer; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub commit { |
37
|
0
|
|
|
0
|
0
|
|
my ($dbh)= @_; |
38
|
0
|
0
|
|
|
|
|
if ($dbh->FETCH('Warn')) { |
39
|
0
|
|
|
|
|
|
warn "Commit ineffective while AutoCommit is on"; |
40
|
|
|
|
|
|
|
} |
41
|
0
|
|
|
|
|
|
0; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub rollback { |
45
|
0
|
|
|
0
|
0
|
|
my ($dbh)= @_; |
46
|
0
|
0
|
|
|
|
|
if ($dbh->FETCH('Warn')) { |
47
|
0
|
|
|
|
|
|
warn "Rollback ineffective while AutoCommit is on"; |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
0; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub STORE { |
53
|
0
|
|
|
0
|
|
|
my ($dbh, $attr, $val)= @_; |
54
|
0
|
0
|
|
|
|
|
if ($attr eq 'AutoCommit') { |
55
|
0
|
0
|
|
|
|
|
if (!$val) { die "DBD::Cassandra does not support transactions"; } |
|
0
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return 1; |
57
|
|
|
|
|
|
|
} |
58
|
0
|
0
|
|
|
|
|
if ($attr =~ m/\Acass_/) { |
59
|
0
|
|
|
|
|
|
$dbh->{$attr}= $val; |
60
|
0
|
|
|
|
|
|
return 1; |
61
|
|
|
|
|
|
|
} |
62
|
0
|
|
|
|
|
|
return $dbh->SUPER::STORE($attr, $val); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub FETCH { |
66
|
0
|
|
|
0
|
|
|
my ($dbh, $attr)= @_; |
67
|
0
|
0
|
|
|
|
|
return 1 if $attr eq 'AutoCommit'; |
68
|
0
|
0
|
|
|
|
|
return $dbh->{$attr} if $attr =~ m/\Acass_/; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Sort of a workaround for unrecoverable errors in st.pm |
71
|
0
|
0
|
|
|
|
|
if ($attr eq 'Active') { |
72
|
0
|
|
|
|
|
|
return $dbh->{cass_client}->is_active; |
73
|
|
|
|
|
|
|
} |
74
|
0
|
|
|
|
|
|
return $dbh->SUPER::FETCH($attr); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub disconnect { |
78
|
0
|
|
|
0
|
0
|
|
my ($dbh)= @_; |
79
|
0
|
|
|
|
|
|
$dbh->STORE('Active', 0); |
80
|
|
|
|
|
|
|
|
81
|
0
|
0
|
|
|
|
|
return if in_global_destruction; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
$dbh->{cass_client}->shutdown; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub ping { |
87
|
0
|
|
|
0
|
0
|
|
my ($dbh)= @_; |
88
|
0
|
|
|
|
|
|
return $dbh->FETCH('Active'); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub x_wait_for_schema_agreement { |
92
|
0
|
|
|
0
|
0
|
|
my ($dbh)= @_; |
93
|
0
|
|
|
|
|
|
my ($error)= $dbh->{cass_client}->call_wait_for_schema_agreement; |
94
|
0
|
0
|
|
|
|
|
if ($error) { |
95
|
0
|
|
|
|
|
|
return $dbh->set_err($DBI::stderr, $error); |
96
|
|
|
|
|
|
|
} |
97
|
0
|
|
|
|
|
|
return 1; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |