summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Rossi <sam.rossi@mongodb.com>2016-09-20 13:40:46 -0400
committerSam Rossi <sam.rossi@mongodb.com>2016-09-22 15:26:52 -0400
commitc080a9b3f208ff3e2530e1a3ff543ff526f91728 (patch)
tree31f90489c050d25fc555e432ba48839f1f7d3f1a /src
parent7b10330723bf46be4fe0a88677f7627a6c0668c1 (diff)
downloadmongo-c080a9b3f208ff3e2530e1a3ff543ff526f91728.tar.gz
SERVER-25942 Don't validate views in listCollections unless they are being returned
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/commands/list_collections.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/mongo/db/commands/list_collections.cpp b/src/mongo/db/commands/list_collections.cpp
index 65eab818051..0590ad108ff 100644
--- a/src/mongo/db/commands/list_collections.cpp
+++ b/src/mongo/db/commands/list_collections.cpp
@@ -31,6 +31,9 @@
#include <vector>
#include "mongo/base/checked_cast.h"
+#include "mongo/bson/bsonmisc.h"
+#include "mongo/bson/bsonobj.h"
+#include "mongo/bson/simple_bsonobj_comparator.h"
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/collection_catalog_entry.h"
@@ -39,6 +42,7 @@
#include "mongo/db/catalog/database_catalog_entry.h"
#include "mongo/db/clientcursor.h"
#include "mongo/db/commands.h"
+#include "mongo/db/commands/list_collections_filter.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/exec/queued_data_stage.h"
#include "mongo/db/exec/working_set.h"
@@ -264,12 +268,18 @@ public:
}
}
- db->getViewCatalog()->iterate(txn, [&](const ViewDefinition& view) {
- BSONObj viewBson = buildViewBson(view);
- if (!viewBson.isEmpty()) {
- _addWorkingSetMember(txn, viewBson, matcher.get(), ws.get(), root.get());
- }
- });
+ // Skipping views is only necessary for internal cloning operations.
+ bool skipViews = filterElt.type() == mongo::Object &&
+ SimpleBSONObjComparator::kInstance.evaluate(
+ filterElt.Obj() == ListCollectionsFilter::makeTypeCollectionFilter());
+ if (!skipViews) {
+ db->getViewCatalog()->iterate(txn, [&](const ViewDefinition& view) {
+ BSONObj viewBson = buildViewBson(view);
+ if (!viewBson.isEmpty()) {
+ _addWorkingSetMember(txn, viewBson, matcher.get(), ws.get(), root.get());
+ }
+ });
+ }
}
const NamespaceString cursorNss = NamespaceString::makeListCollectionsNSS(dbname);