line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBD::Cassandra::st; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TVDW'; |
3
|
|
|
|
|
|
|
$DBD::Cassandra::st::VERSION = '0.57'; |
4
|
|
|
|
|
|
|
# ABSTRACT: DBD::Cassandra statement handle |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
13
|
use 5.010; |
|
1
|
|
|
|
|
2
|
|
7
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
16
|
|
8
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
639
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Documentation-driven cargocult |
11
|
|
|
|
|
|
|
$DBD::Cassandra::st::imp_data_size = 0; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub bind_param { |
14
|
0
|
|
|
0
|
0
|
|
my ($sth, $pNum, $val, $attr)= @_; |
15
|
0
|
|
0
|
|
|
|
my $params= ($sth->{cass_params} ||= []); |
16
|
0
|
|
|
|
|
|
$params->[$pNum-1] = $val; |
17
|
0
|
|
|
|
|
|
1; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub execute { |
21
|
0
|
|
|
0
|
0
|
|
my ($sth, @bind_values)= @_; |
22
|
|
|
|
|
|
|
|
23
|
0
|
0
|
|
|
|
|
$sth->{cass_bind}= (@bind_values ? \@bind_values : $sth->{cass_params}); |
24
|
0
|
|
|
|
|
|
&start_async; |
25
|
0
|
|
|
|
|
|
$sth->STORE('Active', 1); |
26
|
0
|
0
|
|
|
|
|
if (!$sth->{cass_async}) { |
27
|
0
|
|
|
|
|
|
return &x_finish_async; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
return '0E0'; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub start_async { |
34
|
0
|
|
|
0
|
0
|
|
my ($sth)= @_; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$sth->{cass_future}= $sth->{Database}{cass_client}->future_call_execute($sth->{Statement}, $sth->{cass_bind}, { |
37
|
|
|
|
|
|
|
consistency => $sth->{cass_consistency}, |
38
|
|
|
|
|
|
|
page_size => $sth->{cass_page_size}, |
39
|
|
|
|
|
|
|
page => $sth->{cass_next_page}, |
40
|
0
|
|
|
|
|
|
}); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub x_finish_async { |
44
|
0
|
|
|
0
|
0
|
|
my ($sth)= @_; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $future= delete $sth->{cass_future}; |
47
|
0
|
0
|
|
|
|
|
if (!$future) { return '0E0'; } |
|
0
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my ($error, $result)= $future->(); |
50
|
0
|
0
|
|
|
|
|
if ($error) { |
51
|
0
|
|
|
|
|
|
$sth->STORE('Active', 0); |
52
|
0
|
|
|
|
|
|
return $sth->set_err($DBI::stderr, $error); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
0
|
|
|
|
my $rows= ($result && $result->rows) || []; |
56
|
0
|
|
0
|
|
|
|
my $names= ($result && $result->column_names) || []; |
57
|
0
|
|
0
|
|
|
|
my $page= ($result && $result->next_page); |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$sth->{rows}= $rows; |
60
|
0
|
|
|
|
|
|
$sth->{row_count}= 0+@$rows; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
0
|
|
|
|
if (!@$rows && !@$names) { |
63
|
|
|
|
|
|
|
# This is a weird Cassandra corner-case, triggered by doing 'list permissions' etc when there are none. |
64
|
|
|
|
|
|
|
# Our code is fine with it, but DBI wants to have at least one column. So let's give it one. |
65
|
0
|
|
|
|
|
|
@$names= ('no_column_names_returned_by_cassandra'); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
$sth->STORE('NUM_OF_FIELDS', 0+@$names); |
69
|
0
|
|
|
|
|
|
$sth->{NAME}= $names; |
70
|
0
|
|
|
|
|
|
$sth->{cass_next_page}= $page; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
0
|
|
|
|
return ((0+@$rows) || '0E0'); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub execute_for_fetch { |
76
|
0
|
|
|
0
|
0
|
|
die 'Not implemented'; #TODO |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub bind_param_array { |
80
|
0
|
|
|
0
|
0
|
|
die 'Not implemented'; #TODO |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub fetchrow_arrayref { |
84
|
0
|
|
|
0
|
0
|
|
my ($sth)= @_; |
85
|
0
|
0
|
|
|
|
|
if ($sth->{cass_future}) { |
86
|
0
|
0
|
|
|
|
|
return undef unless &x_finish_async; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
my $row= shift @{$sth->{rows}}; |
|
0
|
|
|
|
|
|
|
90
|
0
|
0
|
0
|
|
|
|
if (!$row && $sth->{cass_next_page}) { |
91
|
0
|
|
|
|
|
|
&start_async; |
92
|
0
|
0
|
|
|
|
|
if (!&x_finish_async) { |
93
|
0
|
|
|
|
|
|
return undef; |
94
|
|
|
|
|
|
|
} |
95
|
0
|
|
|
|
|
|
$row= shift @{$sth->{rows}}; |
|
0
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
} |
97
|
0
|
0
|
|
|
|
|
if ($row) { |
98
|
0
|
0
|
|
|
|
|
if ($sth->FETCH('ChopBlanks')) { |
99
|
0
|
|
|
|
|
|
map { $_ =~ s/\s+$//; } @$row; |
|
0
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
return $sth->_set_fbav($row); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
$sth->STORE('Active', 0); |
106
|
0
|
|
|
|
|
|
return undef; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
*fetch = \&fetchrow_arrayref; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub rows { |
112
|
0
|
|
|
0
|
0
|
|
my $sth= shift; |
113
|
0
|
0
|
|
|
|
|
if ($sth->{cass_future}) { |
114
|
0
|
0
|
|
|
|
|
return undef unless &x_finish_async; |
115
|
|
|
|
|
|
|
} |
116
|
0
|
|
|
|
|
|
return $sth->{row_count}; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub FETCH { |
120
|
0
|
|
|
0
|
|
|
my ($sth, $attr)= @_; |
121
|
0
|
0
|
0
|
|
|
|
if ($attr =~ /\A(?:NAME|NUM_OF_FIELDS)\z/ && $sth->{cass_future}) { |
122
|
0
|
0
|
|
|
|
|
return undef unless &x_finish_async; |
123
|
0
|
0
|
|
|
|
|
return $sth->{$attr} if $attr eq 'NAME'; |
124
|
|
|
|
|
|
|
} |
125
|
0
|
|
|
|
|
|
return $sth->SUPER::FETCH($attr); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
__END__ |