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
|
58
|
|
|
58
|
|
416
|
use strict; |
|
58
|
|
|
|
|
147
|
|
|
58
|
|
|
|
|
1922
|
|
16
|
58
|
|
|
58
|
|
328
|
use warnings; |
|
58
|
|
|
|
|
133
|
|
|
58
|
|
|
|
|
2425
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package MongoDB::Op::_ListIndexes; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Encapsulate index list operation; returns array ref of index documents |
21
|
|
|
|
|
|
|
|
22
|
58
|
|
|
58
|
|
334
|
use version; |
|
58
|
|
|
|
|
126
|
|
|
58
|
|
|
|
|
400
|
|
23
|
|
|
|
|
|
|
our $VERSION = 'v2.2.0'; |
24
|
|
|
|
|
|
|
|
25
|
58
|
|
|
58
|
|
4819
|
use Moo; |
|
58
|
|
|
|
|
135
|
|
|
58
|
|
|
|
|
375
|
|
26
|
|
|
|
|
|
|
|
27
|
58
|
|
|
58
|
|
19349
|
use MongoDB::Error; |
|
58
|
|
|
|
|
170
|
|
|
58
|
|
|
|
|
6972
|
|
28
|
58
|
|
|
58
|
|
465
|
use MongoDB::Op::_Command; |
|
58
|
|
|
|
|
135
|
|
|
58
|
|
|
|
|
1685
|
|
29
|
58
|
|
|
58
|
|
367
|
use MongoDB::Op::_Query; |
|
58
|
|
|
|
|
145
|
|
|
58
|
|
|
|
|
1623
|
|
30
|
58
|
|
|
58
|
|
363
|
use MongoDB::ReadConcern; |
|
58
|
|
|
|
|
130
|
|
|
58
|
|
|
|
|
1669
|
|
31
|
58
|
|
|
58
|
|
376
|
use MongoDB::ReadPreference; |
|
58
|
|
|
|
|
142
|
|
|
58
|
|
|
|
|
1747
|
|
32
|
58
|
|
|
|
|
539
|
use Types::Standard qw( |
33
|
|
|
|
|
|
|
InstanceOf |
34
|
58
|
|
|
58
|
|
361
|
); |
|
58
|
|
|
|
|
147
|
|
35
|
58
|
|
|
58
|
|
46446
|
use Tie::IxHash; |
|
58
|
|
|
|
|
146
|
|
|
58
|
|
|
|
|
1263
|
|
36
|
58
|
|
|
58
|
|
314
|
use Safe::Isa; |
|
58
|
|
|
|
|
137
|
|
|
58
|
|
|
|
|
7316
|
|
37
|
58
|
|
|
|
|
455
|
use MongoDB::_Types qw( |
38
|
|
|
|
|
|
|
ReadPreference |
39
|
58
|
|
|
58
|
|
407
|
); |
|
58
|
|
|
|
|
146
|
|
40
|
|
|
|
|
|
|
|
41
|
58
|
|
|
58
|
|
55427
|
use namespace::clean; |
|
58
|
|
|
|
|
145
|
|
|
58
|
|
|
|
|
427
|
|
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; |