line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Couchbase::Client::Compat; |
2
|
1
|
|
|
1
|
|
648
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
102
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
3
|
use base qw(Couchbase::Client); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
105
|
|
5
|
1
|
|
|
1
|
|
6
|
use Couchbase::Client::Errors; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
138
|
|
6
|
1
|
|
|
1
|
|
4
|
use base qw(Exporter); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
456
|
|
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
|
1262
|
my ($requests,$response,$op) = @_; |
21
|
|
|
|
|
|
|
|
22
|
2
|
100
|
|
|
|
6
|
if(wantarray) { |
23
|
|
|
|
|
|
|
#ugh, really? |
24
|
1
|
|
|
|
|
3
|
my @retvals; |
25
|
1
|
|
|
|
|
3
|
foreach my $req (@$requests) { |
26
|
3
|
50
|
|
|
|
8
|
my $key = ref $req eq 'ARRAY' ? $req->[0] : $req; |
27
|
3
|
|
|
|
|
7
|
my $retval = return_for_op($response->{$key}, $op); |
28
|
3
|
|
|
|
|
10
|
push @retvals, $retval; |
29
|
|
|
|
|
|
|
} |
30
|
1
|
|
|
|
|
8
|
return @retvals; |
31
|
|
|
|
|
|
|
} else { |
32
|
|
|
|
|
|
|
#scalar: |
33
|
1
|
|
|
|
|
6
|
while (my ($k,$v) = each %$response) { |
34
|
3
|
|
|
|
|
5
|
$response->{$k} = return_for_op($v, $op); |
35
|
|
|
|
|
|
|
} |
36
|
1
|
|
|
|
|
2
|
return $response; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub return_for_op { |
41
|
16
|
|
|
16
|
0
|
2362
|
my ($retval, $op) = @_; |
42
|
|
|
|
|
|
|
|
43
|
16
|
|
|
|
|
64
|
my $errval = $retval->errnum; |
44
|
|
|
|
|
|
|
|
45
|
16
|
100
|
|
|
|
30
|
if ($errval) { |
46
|
5
|
|
|
|
|
9
|
$errval = $ErrorMap{$errval}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
16
|
100
|
100
|
|
|
50
|
if ($retval->errnum && (!defined $errval)) { |
50
|
|
|
|
|
|
|
# Fatal error: |
51
|
1
|
|
|
|
|
4
|
return undef; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
15
|
100
|
|
|
|
65
|
if ($op =~ /^(?:get|incr|decr)$/) { |
55
|
10
|
|
|
|
|
36
|
return $retval->value; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
5
|
100
|
|
|
|
16
|
if ($op eq 'gets') { |
59
|
1
|
|
|
|
|
8
|
return [$retval->cas, $retval->value]; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
4
|
50
|
|
|
|
18
|
if ($op =~ /^(?:set|cas|add|append|prepend|replace|remove|delete)/) { |
63
|
4
|
|
|
|
|
19
|
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
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
foreach my $sub (qw( |
75
|
|
|
|
|
|
|
get gets |
76
|
|
|
|
|
|
|
set append prepend replace add |
77
|
|
|
|
|
|
|
remove delete |
78
|
|
|
|
|
|
|
incr decr cas)) { |
79
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
206
|
|
80
|
|
|
|
|
|
|
*{$sub} = sub { |
81
|
0
|
|
|
0
|
|
|
my $self = shift; |
82
|
0
|
|
|
|
|
|
my $ret = $self->{\"SUPER::$sub"}(@_); |
83
|
0
|
|
|
|
|
|
$ret = return_for_op($ret, $sub); |
84
|
0
|
|
|
|
|
|
return $ret; |
85
|
|
|
|
|
|
|
}; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $multi = "$sub\_multi"; |
88
|
|
|
|
|
|
|
*{$multi} = sub { |
89
|
0
|
|
|
0
|
|
|
my $self = shift; |
90
|
0
|
|
|
|
|
|
my $ret = $self->{\"SUPER::$multi"}(@_); |
91
|
0
|
|
|
|
|
|
return return_for_multi_wrap(\@_, $ret, $sub) |
92
|
|
|
|
|
|
|
}; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |