| 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
|
|
418
|
use strict; |
|
|
59
|
|
|
|
|
143
|
|
|
|
59
|
|
|
|
|
1859
|
|
|
16
|
59
|
|
|
59
|
|
337
|
use warnings; |
|
|
59
|
|
|
|
|
151
|
|
|
|
59
|
|
|
|
|
2326
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package MongoDB::Op::_ListIndexes; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Encapsulate index list operation; returns array ref of index documents |
|
21
|
|
|
|
|
|
|
|
|
22
|
59
|
|
|
59
|
|
336
|
use version; |
|
|
59
|
|
|
|
|
152
|
|
|
|
59
|
|
|
|
|
377
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = 'v2.2.1'; |
|
24
|
|
|
|
|
|
|
|
|
25
|
59
|
|
|
59
|
|
4872
|
use Moo; |
|
|
59
|
|
|
|
|
136
|
|
|
|
59
|
|
|
|
|
345
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
59
|
|
|
59
|
|
19484
|
use MongoDB::Error; |
|
|
59
|
|
|
|
|
177
|
|
|
|
59
|
|
|
|
|
6733
|
|
|
28
|
59
|
|
|
59
|
|
465
|
use MongoDB::Op::_Command; |
|
|
59
|
|
|
|
|
155
|
|
|
|
59
|
|
|
|
|
1674
|
|
|
29
|
59
|
|
|
59
|
|
369
|
use MongoDB::Op::_Query; |
|
|
59
|
|
|
|
|
153
|
|
|
|
59
|
|
|
|
|
1604
|
|
|
30
|
59
|
|
|
59
|
|
357
|
use MongoDB::ReadConcern; |
|
|
59
|
|
|
|
|
157
|
|
|
|
59
|
|
|
|
|
1674
|
|
|
31
|
59
|
|
|
59
|
|
421
|
use MongoDB::ReadPreference; |
|
|
59
|
|
|
|
|
150
|
|
|
|
59
|
|
|
|
|
1738
|
|
|
32
|
59
|
|
|
|
|
572
|
use Types::Standard qw( |
|
33
|
|
|
|
|
|
|
InstanceOf |
|
34
|
59
|
|
|
59
|
|
361
|
); |
|
|
59
|
|
|
|
|
175
|
|
|
35
|
59
|
|
|
59
|
|
45766
|
use Tie::IxHash; |
|
|
59
|
|
|
|
|
152
|
|
|
|
59
|
|
|
|
|
1257
|
|
|
36
|
59
|
|
|
59
|
|
304
|
use Safe::Isa; |
|
|
59
|
|
|
|
|
142
|
|
|
|
59
|
|
|
|
|
7158
|
|
|
37
|
59
|
|
|
|
|
410
|
use MongoDB::_Types qw( |
|
38
|
|
|
|
|
|
|
ReadPreference |
|
39
|
59
|
|
|
59
|
|
434
|
); |
|
|
59
|
|
|
|
|
144
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
59
|
|
|
59
|
|
57065
|
use namespace::clean; |
|
|
59
|
|
|
|
|
148
|
|
|
|
59
|
|
|
|
|
410
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has client => ( |
|
44
|
|
|
|
|
|
|
is => 'ro', |
|
45
|
|
|
|
|
|
|
required => 1, |
|
46
|
|
|
|
|
|
|
isa => InstanceOf ['MongoDB::MongoClient'], |
|
47
|
|
|
|
|
|
|
); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has read_preference => ( |
|
50
|
|
|
|
|
|
|
is => 'rw', # rw for Op::_Query which can be modified by Cursor |
|
51
|
|
|
|
|
|
|
required => 1, |
|
52
|
|
|
|
|
|
|
isa => ReadPreference, |
|
53
|
|
|
|
|
|
|
); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
with $_ for qw( |
|
56
|
|
|
|
|
|
|
MongoDB::Role::_PrivateConstructor |
|
57
|
|
|
|
|
|
|
MongoDB::Role::_CollectionOp |
|
58
|
|
|
|
|
|
|
MongoDB::Role::_CommandCursorOp |
|
59
|
|
|
|
|
|
|
); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub execute { |
|
62
|
0
|
|
|
0
|
0
|
|
my ( $self, $link, $topology ) = @_; |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
my $res = |
|
65
|
|
|
|
|
|
|
$link->supports_list_commands |
|
66
|
|
|
|
|
|
|
? $self->_command_list_indexes( $link, $topology ) |
|
67
|
|
|
|
|
|
|
: $self->_legacy_list_indexes( $link, $topology ); |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return $res; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _command_list_indexes { |
|
73
|
0
|
|
|
0
|
|
|
my ( $self, $link, $topology ) = @_; |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $op = MongoDB::Op::_Command->_new( |
|
76
|
|
|
|
|
|
|
db_name => $self->db_name, |
|
77
|
|
|
|
|
|
|
query => Tie::IxHash->new( listIndexes => $self->coll_name, cursor => {} ), |
|
78
|
|
|
|
|
|
|
query_flags => {}, |
|
79
|
|
|
|
|
|
|
bson_codec => $self->bson_codec, |
|
80
|
|
|
|
|
|
|
monitoring_callback => $self->monitoring_callback, |
|
81
|
|
|
|
|
|
|
read_preference => $self->read_preference, |
|
82
|
|
|
|
|
|
|
session => $self->session, |
|
83
|
|
|
|
|
|
|
); |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $res = eval { |
|
86
|
0
|
|
|
|
|
|
$op->execute( $link, $topology ); |
|
87
|
0
|
0
|
|
|
|
|
} or do { |
|
88
|
0
|
|
0
|
|
|
|
my $error = $@ || "Unknown error"; |
|
89
|
0
|
0
|
0
|
|
|
|
unless ( $error->$_isa("MongoDB::DatabaseError") and $error->code == NAMESPACE_NOT_FOUND()) { |
|
90
|
0
|
|
|
|
|
|
die $error; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
0
|
|
|
|
|
|
undef; |
|
93
|
|
|
|
|
|
|
}; |
|
94
|
|
|
|
|
|
|
|
|
95
|
0
|
0
|
|
|
|
|
return $res |
|
96
|
|
|
|
|
|
|
? $self->_build_result_from_cursor($res) |
|
97
|
|
|
|
|
|
|
: $self->_empty_query_result($link); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub _legacy_list_indexes { |
|
101
|
0
|
|
|
0
|
|
|
my ( $self, $link, $topology ) = @_; |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
my $ns = $self->db_name . "." . $self->coll_name; |
|
104
|
0
|
|
0
|
|
|
|
my $op = MongoDB::Op::_Query->_new( |
|
105
|
|
|
|
|
|
|
filter => Tie::IxHash->new( ns => $ns ), |
|
106
|
|
|
|
|
|
|
options => MongoDB::Op::_Query->precondition_options({}), |
|
107
|
|
|
|
|
|
|
bson_codec => $self->bson_codec, |
|
108
|
|
|
|
|
|
|
client => $self->client, |
|
109
|
|
|
|
|
|
|
coll_name => 'system.indexes', |
|
110
|
|
|
|
|
|
|
db_name => $self->db_name, |
|
111
|
|
|
|
|
|
|
full_name => $self->db_name . '.system.indexes', |
|
112
|
|
|
|
|
|
|
read_concern => MongoDB::ReadConcern->new, |
|
113
|
|
|
|
|
|
|
read_preference => $self->read_preference || MongoDB::ReadPreference->new, |
|
114
|
|
|
|
|
|
|
monitoring_callback => $self->monitoring_callback, |
|
115
|
|
|
|
|
|
|
); |
|
116
|
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
return $op->execute( $link, $topology ); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |