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
|
|
387
|
use strict; |
|
59
|
|
|
|
|
124
|
|
|
59
|
|
|
|
|
1751
|
|
16
|
59
|
|
|
59
|
|
291
|
use warnings; |
|
59
|
|
|
|
|
114
|
|
|
59
|
|
|
|
|
2146
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package MongoDB::Op::_ListIndexes; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Encapsulate index list operation; returns array ref of index documents |
21
|
|
|
|
|
|
|
|
22
|
59
|
|
|
59
|
|
292
|
use version; |
|
59
|
|
|
|
|
122
|
|
|
59
|
|
|
|
|
381
|
|
23
|
|
|
|
|
|
|
our $VERSION = 'v2.2.2'; |
24
|
|
|
|
|
|
|
|
25
|
59
|
|
|
59
|
|
4370
|
use Moo; |
|
59
|
|
|
|
|
127
|
|
|
59
|
|
|
|
|
316
|
|
26
|
|
|
|
|
|
|
|
27
|
59
|
|
|
59
|
|
16851
|
use MongoDB::Error; |
|
59
|
|
|
|
|
147
|
|
|
59
|
|
|
|
|
6303
|
|
28
|
59
|
|
|
59
|
|
393
|
use MongoDB::Op::_Command; |
|
59
|
|
|
|
|
127
|
|
|
59
|
|
|
|
|
1490
|
|
29
|
59
|
|
|
59
|
|
303
|
use MongoDB::Op::_Query; |
|
59
|
|
|
|
|
118
|
|
|
59
|
|
|
|
|
1668
|
|
30
|
59
|
|
|
59
|
|
326
|
use MongoDB::ReadConcern; |
|
59
|
|
|
|
|
134
|
|
|
59
|
|
|
|
|
1439
|
|
31
|
59
|
|
|
59
|
|
324
|
use MongoDB::ReadPreference; |
|
59
|
|
|
|
|
122
|
|
|
59
|
|
|
|
|
1661
|
|
32
|
59
|
|
|
|
|
513
|
use Types::Standard qw( |
33
|
|
|
|
|
|
|
InstanceOf |
34
|
59
|
|
|
59
|
|
344
|
); |
|
59
|
|
|
|
|
136
|
|
35
|
59
|
|
|
59
|
|
41466
|
use Tie::IxHash; |
|
59
|
|
|
|
|
128
|
|
|
59
|
|
|
|
|
1187
|
|
36
|
59
|
|
|
59
|
|
266
|
use Safe::Isa; |
|
59
|
|
|
|
|
161
|
|
|
59
|
|
|
|
|
6869
|
|
37
|
59
|
|
|
|
|
406
|
use MongoDB::_Types qw( |
38
|
|
|
|
|
|
|
ReadPreference |
39
|
59
|
|
|
59
|
|
365
|
); |
|
59
|
|
|
|
|
114
|
|
40
|
|
|
|
|
|
|
|
41
|
59
|
|
|
59
|
|
67995
|
use namespace::clean; |
|
59
|
|
|
|
|
127
|
|
|
59
|
|
|
|
|
424
|
|
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; |