line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Couchbase::Client::Compat; |
2
|
1
|
|
|
1
|
|
602
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
use base qw(Couchbase::Client); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
85
|
|
5
|
1
|
|
|
1
|
|
10
|
use Couchbase::Client::Errors; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
86
|
|
6
|
1
|
|
|
1
|
|
4
|
use base qw(Exporter); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
477
|
|
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
|
584
|
my ($requests,$response,$op) = @_; |
21
|
|
|
|
|
|
|
|
22
|
2
|
100
|
|
|
|
6
|
if(wantarray) { |
23
|
|
|
|
|
|
|
#ugh, really? |
24
|
1
|
|
|
|
|
1
|
my @retvals; |
25
|
1
|
|
|
|
|
3
|
foreach my $req (@$requests) { |
26
|
3
|
50
|
|
|
|
8
|
my $key = ref $req eq 'ARRAY' ? $req->[0] : $req; |
27
|
3
|
|
|
|
|
5
|
my $retval = return_for_op($response->{$key}, $op); |
28
|
3
|
|
|
|
|
5
|
push @retvals, $retval; |
29
|
|
|
|
|
|
|
} |
30
|
1
|
|
|
|
|
4
|
return @retvals; |
31
|
|
|
|
|
|
|
} else { |
32
|
|
|
|
|
|
|
#scalar: |
33
|
1
|
|
|
|
|
5
|
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
|
1083
|
my ($retval, $op) = @_; |
42
|
|
|
|
|
|
|
|
43
|
16
|
|
|
|
|
29
|
my $errval = $retval->errnum; |
44
|
|
|
|
|
|
|
|
45
|
16
|
100
|
|
|
|
27
|
if ($errval) { |
46
|
5
|
|
|
|
|
6
|
$errval = $ErrorMap{$errval}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
16
|
100
|
100
|
|
|
44
|
if ($retval->errnum && (!defined $errval)) { |
50
|
|
|
|
|
|
|
# Fatal error: |
51
|
1
|
|
|
|
|
4
|
return undef; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
15
|
100
|
|
|
|
55
|
if ($op =~ /^(?:get|incr|decr)$/) { |
55
|
10
|
|
|
|
|
34
|
return $retval->value; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
5
|
100
|
|
|
|
9
|
if ($op eq 'gets') { |
59
|
1
|
|
|
|
|
5
|
return [$retval->cas, $retval->value]; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
4
|
50
|
|
|
|
15
|
if ($op =~ /^(?:set|cas|add|append|prepend|replace|remove|delete)/) { |
63
|
4
|
|
|
|
|
14
|
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
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
149
|
|
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__ |