| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright 2014 - present MongoDB, Inc. |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
|
4
|
|
|
|
|
|
|
# you may not use this file except in compliance with the License. |
|
5
|
|
|
|
|
|
|
# You may obtain a copy of the License at |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software |
|
10
|
|
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
|
11
|
|
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
12
|
|
|
|
|
|
|
# See the License for the specific language governing permissions and |
|
13
|
|
|
|
|
|
|
# limitations under the License. |
|
14
|
|
|
|
|
|
|
|
|
15
|
59
|
|
|
59
|
|
370
|
use strict; |
|
|
59
|
|
|
|
|
122
|
|
|
|
59
|
|
|
|
|
1745
|
|
|
16
|
59
|
|
|
59
|
|
282
|
use warnings; |
|
|
59
|
|
|
|
|
122
|
|
|
|
59
|
|
|
|
|
2005
|
|
|
17
|
|
|
|
|
|
|
package MongoDB::Op::_Delete; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Encapsulate a delete operation; returns a MongoDB::DeleteResult |
|
20
|
|
|
|
|
|
|
|
|
21
|
59
|
|
|
59
|
|
288
|
use version; |
|
|
59
|
|
|
|
|
243
|
|
|
|
59
|
|
|
|
|
330
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = 'v2.2.2'; |
|
23
|
|
|
|
|
|
|
|
|
24
|
59
|
|
|
59
|
|
3974
|
use Moo; |
|
|
59
|
|
|
|
|
125
|
|
|
|
59
|
|
|
|
|
333
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
59
|
|
|
59
|
|
37159
|
use MongoDB::DeleteResult; |
|
|
59
|
|
|
|
|
163
|
|
|
|
59
|
|
|
|
|
1903
|
|
|
27
|
59
|
|
|
59
|
|
449
|
use MongoDB::_Protocol; |
|
|
59
|
|
|
|
|
124
|
|
|
|
59
|
|
|
|
|
1448
|
|
|
28
|
59
|
|
|
|
|
300
|
use MongoDB::_Types qw( |
|
29
|
|
|
|
|
|
|
Boolish |
|
30
|
|
|
|
|
|
|
Document |
|
31
|
59
|
|
|
59
|
|
288
|
); |
|
|
59
|
|
|
|
|
121
|
|
|
32
|
59
|
|
|
|
|
407
|
use Types::Standard qw( |
|
33
|
|
|
|
|
|
|
Maybe |
|
34
|
59
|
|
|
59
|
|
34302
|
); |
|
|
59
|
|
|
|
|
121
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
59
|
|
|
59
|
|
36843
|
use namespace::clean; |
|
|
59
|
|
|
|
|
134
|
|
|
|
59
|
|
|
|
|
281
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has filter => ( |
|
39
|
|
|
|
|
|
|
is => 'ro', |
|
40
|
|
|
|
|
|
|
required => 1, |
|
41
|
|
|
|
|
|
|
isa => Document, |
|
42
|
|
|
|
|
|
|
); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has just_one => ( |
|
45
|
|
|
|
|
|
|
is => 'ro', |
|
46
|
|
|
|
|
|
|
required => 1, |
|
47
|
|
|
|
|
|
|
isa => Boolish, |
|
48
|
|
|
|
|
|
|
); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has collation => ( |
|
51
|
|
|
|
|
|
|
is => 'ro', |
|
52
|
|
|
|
|
|
|
isa => Maybe( [Document] ), |
|
53
|
|
|
|
|
|
|
); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
with $_ for qw( |
|
56
|
|
|
|
|
|
|
MongoDB::Role::_PrivateConstructor |
|
57
|
|
|
|
|
|
|
MongoDB::Role::_CollectionOp |
|
58
|
|
|
|
|
|
|
MongoDB::Role::_SingleBatchDocWrite |
|
59
|
|
|
|
|
|
|
); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub execute { |
|
62
|
0
|
|
|
0
|
0
|
|
my ( $self, $link ) = @_; |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
if ( defined $self->collation ) { |
|
65
|
0
|
0
|
|
|
|
|
MongoDB::UsageError->throw( |
|
66
|
|
|
|
|
|
|
"MongoDB host '" . $link->address . "' doesn't support collation" ) |
|
67
|
|
|
|
|
|
|
if !$link->supports_collation; |
|
68
|
0
|
0
|
|
|
|
|
MongoDB::UsageError->throw( |
|
69
|
|
|
|
|
|
|
"Unacknowledged deletes that specify a collation are not allowed") |
|
70
|
|
|
|
|
|
|
if ! $self->_should_use_acknowledged_write; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $filter = |
|
74
|
|
|
|
|
|
|
ref( $self->filter ) eq 'ARRAY' |
|
75
|
0
|
0
|
|
|
|
|
? { @{ $self->filter } } |
|
|
0
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
: $self->filter; |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
my $op_doc = { |
|
|
|
0
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
q => $filter, |
|
80
|
|
|
|
|
|
|
limit => $self->just_one ? 1 : 0, |
|
81
|
|
|
|
|
|
|
( defined $self->collation ? ( collation => $self->collation ) : () ), |
|
82
|
|
|
|
|
|
|
}; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
return ( |
|
85
|
|
|
|
|
|
|
! $self->_should_use_acknowledged_write |
|
86
|
|
|
|
|
|
|
? ( |
|
87
|
|
|
|
|
|
|
$self->_send_legacy_op_noreply( |
|
88
|
|
|
|
|
|
|
$link, |
|
89
|
|
|
|
|
|
|
MongoDB::_Protocol::write_delete( |
|
90
|
|
|
|
|
|
|
$self->full_name, |
|
91
|
|
|
|
|
|
|
$self->bson_codec->encode_one( $self->filter ), |
|
92
|
|
|
|
|
|
|
{ just_one => $self->just_one ? 1 : 0 } |
|
93
|
|
|
|
|
|
|
), |
|
94
|
|
|
|
|
|
|
$op_doc, |
|
95
|
|
|
|
|
|
|
"MongoDB::DeleteResult", |
|
96
|
|
|
|
|
|
|
"delete", |
|
97
|
|
|
|
|
|
|
) |
|
98
|
|
|
|
|
|
|
) |
|
99
|
|
|
|
|
|
|
: $link->supports_write_commands |
|
100
|
|
|
|
|
|
|
? ( |
|
101
|
|
|
|
|
|
|
$self->_send_write_command( |
|
102
|
|
|
|
|
|
|
$link, |
|
103
|
|
|
|
|
|
|
[ |
|
104
|
|
|
|
|
|
|
delete => $self->coll_name, |
|
105
|
|
|
|
|
|
|
deletes => [$op_doc], |
|
106
|
0
|
0
|
|
|
|
|
@{ $self->write_concern->as_args }, |
|
|
0
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
], |
|
108
|
|
|
|
|
|
|
$op_doc, |
|
109
|
|
|
|
|
|
|
"MongoDB::DeleteResult" |
|
110
|
|
|
|
|
|
|
)->assert |
|
111
|
|
|
|
|
|
|
) |
|
112
|
|
|
|
|
|
|
: ( |
|
113
|
|
|
|
|
|
|
$self->_send_legacy_op_with_gle( |
|
114
|
|
|
|
|
|
|
$link, |
|
115
|
|
|
|
|
|
|
MongoDB::_Protocol::write_delete( |
|
116
|
|
|
|
|
|
|
$self->full_name, |
|
117
|
|
|
|
|
|
|
$self->bson_codec->encode_one( $self->filter ), |
|
118
|
|
|
|
|
|
|
{ just_one => $self->just_one ? 1 : 0 } |
|
119
|
|
|
|
|
|
|
), |
|
120
|
|
|
|
|
|
|
$op_doc, |
|
121
|
|
|
|
|
|
|
"MongoDB::DeleteResult", |
|
122
|
|
|
|
|
|
|
"delete", |
|
123
|
|
|
|
|
|
|
)->assert |
|
124
|
|
|
|
|
|
|
) |
|
125
|
|
|
|
|
|
|
); |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub _parse_cmd { |
|
129
|
0
|
|
|
0
|
|
|
my ( $self, $res ) = @_; |
|
130
|
0
|
|
0
|
|
|
|
return ( deleted_count => $res->{n} || 0 ); |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
BEGIN { |
|
134
|
59
|
|
|
59
|
|
32072
|
no warnings 'once'; |
|
|
59
|
|
|
|
|
125
|
|
|
|
59
|
|
|
|
|
2638
|
|
|
135
|
59
|
|
|
59
|
|
1763
|
*_parse_gle = \&_parse_cmd; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |