| 1 | 1 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package DR::Tarantool::LLSyncClient; | ||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use IO::Socket::UNIX; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use IO::Socket::INET; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | require DR::Tarantool; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | my $LE = $] > 5.01 ? '<' : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | $Carp::Internal{ (__PACKAGE__) }++; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | sub connect { | ||||||||||||||||||||||||||||
| 16 | 0 | ▶ | my ($class, %opts) = @_; | ||||||||||||||||||||||||||
|
Subroutine
connect: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 0 | ▶ | my $host = $opts{host} || 'localhost'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'host'} || 'localhost'
MC/DC0%0/1
$opts{'host'} || 'localhost'
$opts{'host'}
Truth table0%0/2
A
A= $opts{'host'}
| |||||||||||||||||||||||||||||
| 19 | 0 | ▶ | my $port = $opts{port} or croak 'port is undefined'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 0 | ▶ | my $reconnect_period = $opts{reconnect_period} || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'reconnect_period'} || 0
MC/DC0%0/1
$opts{'reconnect_period'} || 0
$opts{'reconnect_period'}
Truth table0%0/2
A
A= $opts{'reconnect_period'}
| |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | my $reconnect_always = $opts{reconnect_always} || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'reconnect_always'} || 0
MC/DC0%0/1
$opts{'reconnect_always'} || 0
$opts{'reconnect_always'}
Truth table0%0/2
A
A= $opts{'reconnect_always'}
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | my $raise_error = 1; | |||||||||||||||||||||||||||
| 26 | 0 | ▶ | if (exists $opts{raise_error}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | $raise_error = $opts{raise_error} ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | my $self = bless { | ||||||||||||||||||||||||||
|
Condition0%0/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table0%0/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||
| 31 | host => $host, | ||||||||||||||||||||||||||||
| 32 | port => $port, | ||||||||||||||||||||||||||||
| 33 | raise_error => $raise_error, | ||||||||||||||||||||||||||||
| 34 | reconnect_period => $reconnect_period, | ||||||||||||||||||||||||||||
| 35 | id => 0, | ||||||||||||||||||||||||||||
| 36 | } => ref ($class) || $class; | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | unless ($self->_connect()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | unless ($reconnect_always) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | return undef unless $self->{raise_error}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 0 | croak "Can't connect to $self->{host}:$self->{port}: $@"; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | 0 | ▶ | unless ($reconnect_period) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | return undef unless $self->{raise_error}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | croak "Can't connect to $self->{host}:$self->{port}: $@"; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | 0 | return $self; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | sub _connect { | ||||||||||||||||||||||||||||
| 53 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_connect: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if ($self->{host} eq 'unix/' or $self->{port} =~ /\D/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"host"} eq "unix/" or $self->{"port"} =~ /\D/
MC/DC0%0/2
$self->{"host"} eq "unix/" or $self->{"port"} =~ /\D/
$self->{"host"} eq "unix/"
$self->{"port"} =~ /\D/
Truth table0%0/3
A or B
A= $self->{"host"} eq "unix/"B= $self->{"port"} =~ /\D/
| |||||||||||||||||||||||||||||
| 56 | 0 | return $self->{fh} = IO::Socket::UNIX->new(Peer => $self->{port}); | |||||||||||||||||||||||||||
| 57 | } else { | ||||||||||||||||||||||||||||
| 58 | return $self->{fh} = IO::Socket::INET->new( | ||||||||||||||||||||||||||||
| 59 | PeerHost => $self->{host}, | ||||||||||||||||||||||||||||
| 60 | PeerPort => $self->{port}, | ||||||||||||||||||||||||||||
| 61 | 0 | Proto => 'tcp', | |||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | sub _req_id { | ||||||||||||||||||||||||||||
| 67 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_req_id: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | return $self->{id}++ if $self->{id} < 0x7FFF_FFFE; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 0 | return $self->{id} = 0; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | sub _request { | ||||||||||||||||||||||||||||
| 73 | 0 | ▶ | my ($self, $id, $pkt ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_request: not called CC=19 SCAR=56.4
| |||||||||||||||||||||||||||||
| 74 | 0 | ▶ | until($self->{fh}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | unless ($self->{reconnect_period}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | 0 | $self->{last_error_string} = "Connection isn't established"; | |||||||||||||||||||||||||||
| 77 | 0 | ▶ | croak $self->{last_error_string} if $self->{raise_error}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 0 | return undef; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | 0 | ▶ | next if $self->_connect; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | sleep $self->{reconnect_period}; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | my $len = length $pkt; | |||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | # send request | ||||||||||||||||||||||||||||
| 87 | 0 | ▶ | while($len > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 1 | ▶ | no warnings; # closed socket | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 89 | 0 | my $slen = syswrite $self->{fh}, $pkt; | |||||||||||||||||||||||||||
| 90 | 0 | ▶ | unless(defined $slen) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | 0 | ▶ | next if $!{EINTR}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | 0 | goto SOCKET_ERROR; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | 0 | $len -= $slen; | |||||||||||||||||||||||||||
| 95 | 0 | substr $pkt, 0, $slen, ''; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | $pkt = ''; | |||||||||||||||||||||||||||
| 99 | 0 | ▶ | while(12 > length $pkt) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | 1 | ▶ | no warnings; # closed socket | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 101 | 0 | my $rl = sysread $self->{fh}, $pkt, 12 - length $pkt, length $pkt; | |||||||||||||||||||||||||||
| 102 | 0 | ▶ | unless (defined $rl) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 0 | ▶ | next if $!{EINTR}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | 0 | goto SOCKET_ERROR; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | my (undef, $blen) = unpack "L$LE L$LE", $pkt; | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 0 | ▶ | while(12 + $blen > length $pkt) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | 1 | ▶ | no warnings; # closed socket | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 112 | my $rl = sysread $self->{fh}, | ||||||||||||||||||||||||||||
| 113 | 0 | $pkt, 12 + $blen - length $pkt, length $pkt; | |||||||||||||||||||||||||||
| 114 | 0 | ▶ | unless (defined $rl) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 0 | ▶ | next if $!{EINTR}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | 0 | goto SOCKET_ERROR; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 0 | my $res = DR::Tarantool::_pkt_parse_response( $pkt ); | |||||||||||||||||||||||||||
| 121 | 0 | ▶ | if ($res->{status} ne 'ok') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 0 | $self->{last_error_string} = $res->{errstr}; | |||||||||||||||||||||||||||
| 123 | 0 | $self->{last_code} = $res->{code}; | |||||||||||||||||||||||||||
| 124 | # disconnect | ||||||||||||||||||||||||||||
| 125 | 0 | ▶ | delete $self->{fh} if $res->{status} =~ /^(fatal|buffer)$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 126 | 0 | ▶ | croak $self->{last_error_string} if $self->{raise_error}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | 0 | return undef; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 0 | ▶ | $self->{last_error_string} = $res->{errstr} || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$res->{'errstr'} || ''
MC/DC0%0/1
$res->{'errstr'} || ''
$res->{'errstr'}
Truth table0%0/2
A
A= $res->{'errstr'}
| |||||||||||||||||||||||||||||
| 131 | 0 | $self->{last_code} = $res->{code}; | |||||||||||||||||||||||||||
| 132 | 0 | return $res; | |||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | SOCKET_ERROR: | ||||||||||||||||||||||||||||
| 136 | 0 | delete $self->{fh}; | |||||||||||||||||||||||||||
| 137 | 0 | $self->{last_error_string} = $!; | |||||||||||||||||||||||||||
| 138 | 0 | $self->{last_code} = undef; | |||||||||||||||||||||||||||
| 139 | 0 | ▶ | croak $self->{last_error_string} if $self->{raise_error}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | 0 | return undef; | |||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | sub ping :method { | ||||||||||||||||||||||||||||
| 144 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
ping: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 145 | 0 | ▶ | unless ($self->{fh}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 0 | $self->_connect; | |||||||||||||||||||||||||||
| 147 | 0 | $self->{last_code} = -1; | |||||||||||||||||||||||||||
| 148 | 0 | $self->{last_error_string} = "Connection isn't established"; | |||||||||||||||||||||||||||
| 149 | 0 | ▶ | return 0 unless $self->{fh}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | 0 | my $id = $self->_req_id; | |||||||||||||||||||||||||||
| 152 | 0 | my $pkt = DR::Tarantool::_pkt_ping( $id ); | |||||||||||||||||||||||||||
| 153 | 0 | my $res = eval { $self->_request( $id, $pkt ); }; | |||||||||||||||||||||||||||
| 154 | 0 | ▶ | return 0 unless $res and $res->{status} eq 'ok'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res and $res->{"status"} eq "ok"
MC/DC0%0/2
$res and $res->{"status"} eq "ok"
$res
$res->{"status"} eq "ok"
Truth table0%0/3
A and B
A= $resB= $res->{"status"} eq "ok"
| |||||||||||||||||||||||||||||
| 155 | 0 | return 1; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | sub call_lua :method { | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
call_lua: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 162 | 0 | my $proc = shift; | |||||||||||||||||||||||||||
| 163 | 0 | my $tuple = shift; | |||||||||||||||||||||||||||
| 164 | 0 | $self->_check_tuple( $tuple ); | |||||||||||||||||||||||||||
| 165 | 0 | ▶ | my $flags = pop || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
pop() || 0
MC/DC0%0/1
pop() || 0
pop()
Truth table0%0/2
A
A= pop()
| |||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 0 | my $id = $self->_req_id; | |||||||||||||||||||||||||||
| 168 | 0 | my $pkt = DR::Tarantool::_pkt_call_lua($id, $flags, $proc, $tuple); | |||||||||||||||||||||||||||
| 169 | 0 | return $self->_request( $id, $pkt ); | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | sub select :method { | ||||||||||||||||||||||||||||
| 173 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
select: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 174 | 0 | $self->_check_number( my $ns = shift ); | |||||||||||||||||||||||||||
| 175 | 0 | $self->_check_number( my $idx = shift ); | |||||||||||||||||||||||||||
| 176 | 0 | $self->_check_tuple_list( my $keys = shift ); | |||||||||||||||||||||||||||
| 177 | 0 | ▶ | $self->_check_number( my $limit = shift || 0x7FFFFFFF ); | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 2147483647
MC/DC0%0/1
shift() || 2147483647
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 178 | 0 | ▶ | $self->_check_number( my $offset = shift || 0 ); | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 0 | my $id = $self->_req_id; | |||||||||||||||||||||||||||
| 181 | 0 | my $pkt = | |||||||||||||||||||||||||||
| 182 | DR::Tarantool::_pkt_select($id, $ns, $idx, $offset, $limit, $keys); | ||||||||||||||||||||||||||||
| 183 | 0 | return $self->_request( $id, $pkt ); | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | sub insert :method { | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
insert: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 189 | 0 | $self->_check_number( my $space = shift ); | |||||||||||||||||||||||||||
| 190 | 0 | $self->_check_tuple( my $tuple = shift ); | |||||||||||||||||||||||||||
| 191 | 0 | ▶ | $self->_check_number( my $flags = pop || 0 ); | ||||||||||||||||||||||||||
|
Condition0%0/2
pop() || 0
MC/DC0%0/1
pop() || 0
pop()
Truth table0%0/2
A
A= pop()
| |||||||||||||||||||||||||||||
| 192 | 0 | ▶ | croak "insert: tuple must be ARRAYREF" unless ref $tuple eq 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | 0 | ▶ | $flags ||= 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$flags ||= 0
MC/DC0%0/1
$flags ||= 0
$flags
Truth table0%0/2
A
A= $flags
| |||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 0 | my $id = $self->_req_id; | |||||||||||||||||||||||||||
| 196 | 0 | my $pkt = DR::Tarantool::_pkt_insert( $id, $space, $flags, $tuple ); | |||||||||||||||||||||||||||
| 197 | 0 | return $self->_request( $id, $pkt ); | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | sub update :method { | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
update: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 203 | 0 | $self->_check_number( my $ns = shift ); | |||||||||||||||||||||||||||
| 204 | 0 | $self->_check_tuple( my $key = shift ); | |||||||||||||||||||||||||||
| 205 | 0 | $self->_check_operations( my $operations = shift ); | |||||||||||||||||||||||||||
| 206 | 0 | ▶ | $self->_check_number( my $flags = pop || 0 ); | ||||||||||||||||||||||||||
|
Condition0%0/2
pop() || 0
MC/DC0%0/1
pop() || 0
pop()
Truth table0%0/2
A
A= pop()
| |||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 0 | my $id = $self->_req_id; | |||||||||||||||||||||||||||
| 209 | 0 | my $pkt = DR::Tarantool::_pkt_update($id, $ns, $flags, $key, $operations); | |||||||||||||||||||||||||||
| 210 | 0 | return $self->_request( $id, $pkt ); | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | sub delete :method { | ||||||||||||||||||||||||||||
| 215 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 216 | 0 | my $ns = shift; | |||||||||||||||||||||||||||
| 217 | 0 | my $key = shift; | |||||||||||||||||||||||||||
| 218 | 0 | $self->_check_tuple( $key ); | |||||||||||||||||||||||||||
| 219 | 0 | ▶ | my $flags = pop || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
pop() || 0
MC/DC0%0/1
pop() || 0
pop()
Truth table0%0/2
A
A= pop()
| |||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 0 | my $id = $self->_req_id; | |||||||||||||||||||||||||||
| 222 | 0 | my $pkt = DR::Tarantool::_pkt_delete($id, $ns, $flags, $key); | |||||||||||||||||||||||||||
| 223 | 0 | return $self->_request( $id, $pkt ); | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | sub _check_tuple { | ||||||||||||||||||||||||||||
| 229 | 0 | ▶ | my ($self, $tuple) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_check_tuple: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 230 | 0 | ▶ | croak 'Tuple must be ARRAYREF' unless 'ARRAY' eq ref $tuple; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | sub _check_tuple_list { | ||||||||||||||||||||||||||||
| 234 | 0 | ▶ | my ($self, $list) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_check_tuple_list: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 235 | 0 | ▶ | croak 'Tuplelist must be ARRAYREF of ARRAYREF' unless 'ARRAY' eq ref $list; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 236 | 0 | ▶ | croak 'Tuplelist is empty' unless @$list; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | 0 | $self->_check_tuple($_) for @$list; | |||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | sub _check_number { | ||||||||||||||||||||||||||||
| 241 | 0 | ▶ | my ($self, $number) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_check_number: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 242 | 0 | ▶ | croak "argument must be number" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $number and $number =~ /^\d+$/
MC/DC0%0/2
defined $number and $number =~ /^\d+$/
defined $number
$number =~ /^\d+$/
Truth table0%0/3
A and B
A= defined $numberB= $number =~ /^\d+$/
| |||||||||||||||||||||||||||||
| 243 | unless defined $number and $number =~ /^\d+$/; | ||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | sub _check_operation { | ||||||||||||||||||||||||||||
| 247 | 0 | ▶ | my ($self, $op) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_check_operation: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 248 | 0 | ▶ | croak 'Operation must be ARRAYREF' unless 'ARRAY' eq ref $op; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 249 | 0 | ▶ | croak 'Wrong update operation: too short arglist' unless @$op >= 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | 0 | ▶ | croak "Wrong operation: $op->[1]" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$op->[1] and $op->[1] =~ /^(delete|set|insert|add|and|or|xor|substr)$/
MC/DC0%0/2
$op->[1] and $op->[1] =~ /^(delete|set|insert|add|and|or|xor|substr)$/
$op->[1]
$op->[1] =~ /^(delete|set|insert|add|and|or|xor|substr)$/
Truth table0%0/3
A and B
A= $op->[1]B= $op->[1] =~ /^(delete|set|insert|add|and|or|xor|substr)$/
| |||||||||||||||||||||||||||||
| 251 | unless $op->[1] and | ||||||||||||||||||||||||||||
| 252 | $op->[1] =~ /^(delete|set|insert|add|and|or|xor|substr)$/; | ||||||||||||||||||||||||||||
| 253 | 0 | $self->_check_number($op->[0]); | |||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | sub _check_operations { | ||||||||||||||||||||||||||||
| 257 | 0 | ▶ | my ($self, $list) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_check_operations: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 258 | 0 | ▶ | croak 'Operations list must be ARRAYREF of ARRAYREF' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 259 | unless 'ARRAY' eq ref $list; | ||||||||||||||||||||||||||||
| 260 | 0 | ▶ | croak 'Operations list is empty' unless @$list; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 261 | 0 | $self->_check_operation( $_ ) for @$list; | |||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | sub last_error_string { | ||||||||||||||||||||||||||||
| 266 | 0 | ▶ | return $_[0]->{last_error_string}; | ||||||||||||||||||||||||||
|
Subroutine
last_error_string: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | sub last_code { | ||||||||||||||||||||||||||||
| 270 | 0 | ▶ | return $_[0]->{last_code}; | ||||||||||||||||||||||||||
|
Subroutine
last_code: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | sub raise_error { | ||||||||||||||||||||||||||||
| 274 | 0 | ▶ | return $_[0]->{raise_error}; | ||||||||||||||||||||||||||
|
Subroutine
raise_error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 1 | 1; | |||||||||||||||||||||||||||