line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Couchbase::Client::Compat; |
2
|
1
|
|
|
1
|
|
768
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
5
|
use base qw(Couchbase::Client); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
98
|
|
5
|
1
|
|
|
1
|
|
14
|
use Couchbase::Client::Errors; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
106
|
|
6
|
1
|
|
|
1
|
|
4
|
use base qw(Exporter); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
547
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw(return_for_multi_wrap return_for_op); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#These errors are 'negative replies', all others are 'error' replies. |
11
|
|
|
|
|
|
|
our %ErrorMap = ( |
12
|
|
|
|
|
|
|
COUCHBASE_NOT_STORED, 0, |
13
|
|
|
|
|
|
|
COUCHBASE_KEY_EEXISTS, 0, |
14
|
|
|
|
|
|
|
COUCHBASE_KEY_ENOENT, 0, |
15
|
|
|
|
|
|
|
COUCHBASE_DELTA_BADVAL, 0, |
16
|
|
|
|
|
|
|
COUCHBASE_E2BIG, 0, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub return_for_multi_wrap { |
20
|
2
|
|
|
2
|
0
|
1166
|
my ($requests,$response,$op) = @_; |
21
|
|
|
|
|
|
|
|
22
|
2
|
100
|
|
|
|
7
|
if(wantarray) { |
23
|
|
|
|
|
|
|
#ugh, really? |
24
|
1
|
|
|
|
|
2
|
my @retvals; |
25
|
1
|
|
|
|
|
3
|
foreach my $req (@$requests) { |
26
|
3
|
50
|
|
|
|
8
|
my $key = ref $req eq 'ARRAY' ? $req->[0] : $req; |
27
|
3
|
|
|
|
|
9
|
my $retval = return_for_op($response->{$key}, $op); |
28
|
3
|
|
|
|
|
9
|
push @retvals, $retval; |
29
|
|
|
|
|
|
|
} |
30
|
1
|
|
|
|
|
6
|
return @retvals; |
31
|
|
|
|
|
|
|
} else { |
32
|
|
|
|
|
|
|
#scalar: |
33
|
1
|
|
|
|
|
6
|
while (my ($k,$v) = each %$response) { |
34
|
3
|
|
|
|
|
9
|
$response->{$k} = return_for_op($v, $op); |
35
|
|
|
|
|
|
|
} |
36
|
1
|
|
|
|
|
4
|
return $response; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub return_for_op { |
41
|
16
|
|
|
16
|
0
|
2187
|
my ($retval, $op) = @_; |
42
|
|
|
|
|
|
|
|
43
|
16
|
|
|
|
|
69
|
my $errval = $retval->errnum; |
44
|
|
|
|
|
|
|
|
45
|
16
|
100
|
|
|
|
36
|
if ($errval) { |
46
|
5
|
|
|
|
|
10
|
$errval = $ErrorMap{$errval}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
16
|
100
|
100
|
|
|
63
|
if ($retval->errnum && (!defined $errval)) { |
50
|
|
|
|
|
|
|
# Fatal error: |
51
|
1
|
|
|
|
|
5
|
return undef; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
15
|
100
|
|
|
|
60
|
if ($op =~ /^(?:get|incr|decr)$/) { |
55
|
10
|
|
|
|
|
48
|
return $retval->value; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
5
|
100
|
|
|
|
12
|
if ($op eq 'gets') { |
59
|
1
|
|
|
|
|
9
|
return [$retval->cas, $retval->value]; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
4
|
50
|
|
|
|
20
|
if ($op =~ /^(?:set|cas|add|append|prepend|replace|remove|delete)/) { |
63
|
4
|
|
|
|
|
38
|
return int($retval->errnum == 0); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub new { |
69
|
0
|
|
|
0
|
1
|
|
my ($cls,$options) = @_; |
70
|
0
|
|
|
|
|
|
my $o = $cls->SUPER::new($options); |
71
|
0
|
|
|
|
|
|
bless $o, $cls; |
72
|
0
|
|
|
|
|
|
return $o; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
foreach my $sub (qw( |
77
|
|
|
|
|
|
|
get gets |
78
|
|
|
|
|
|
|
set append prepend replace add |
79
|
|
|
|
|
|
|
remove delete |
80
|
|
|
|
|
|
|
incr decr cas)) { |
81
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
205
|
|
82
|
|
|
|
|
|
|
*{$sub} = sub { |
83
|
0
|
|
|
0
|
|
|
my $self = shift; |
84
|
0
|
|
|
|
|
|
my $ret = $self->${\"SUPER::$sub"}(@_); |
|
0
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
$ret = return_for_op($ret, $sub); |
86
|
0
|
|
|
|
|
|
return $ret; |
87
|
|
|
|
|
|
|
}; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $multi = "$sub\_multi"; |
90
|
|
|
|
|
|
|
*{$multi} = sub { |
91
|
0
|
|
|
0
|
|
|
my $self = shift; |
92
|
0
|
|
|
|
|
|
my $ret = $self->${\"SUPER::$multi"}(@_); |
|
0
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
return return_for_multi_wrap(\@_, $ret, $sub) |
94
|
|
|
|
|
|
|
}; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |