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