summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJames Wahlin <james.wahlin@10gen.com>2016-07-18 11:13:53 -0400
committerJames Wahlin <james.wahlin@10gen.com>2016-07-18 11:16:15 -0400
commit4d826acb5648a78d0af0fefac5abe6fbbe7c854a (patch)
treea6ac4d84d74dc1531add500bc6c3abce3a00df51 /src
parentc970ae123e3f86bc84e8484487a946daa982dc1e (diff)
downloadmongo-r3.3.10.tar.gz
Revert "SERVER-24506 listCollections support for views"r3.3.10
This reverts commit bfa627513c781c9e61b25dcf993fcd01aaeed0c3.
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/commands/list_collections.cpp72
1 files changed, 18 insertions, 54 deletions
diff --git a/src/mongo/db/commands/list_collections.cpp b/src/mongo/db/commands/list_collections.cpp
index 23cd2ff6845..b38e3b07c3d 100644
--- a/src/mongo/db/commands/list_collections.cpp
+++ b/src/mongo/db/commands/list_collections.cpp
@@ -48,8 +48,6 @@
#include "mongo/db/query/find_common.h"
#include "mongo/db/service_context.h"
#include "mongo/db/storage/storage_engine.h"
-#include "mongo/db/storage/storage_options.h"
-#include "mongo/db/views/view_catalog.h"
#include "mongo/stdx/memory.h"
namespace mongo {
@@ -107,56 +105,37 @@ boost::optional<vector<StringData>> _getExactNameMatches(const MatchExpression*
* Does not add any information about the system.namespaces collection, or non-existent collections.
*/
void _addWorkingSetMember(OperationContext* txn,
- const BSONObj& maybe,
+ const Collection* collection,
const MatchExpression* matcher,
WorkingSet* ws,
QueuedDataStage* root) {
- if (matcher && !matcher->matchesBSON(maybe)) {
- return;
- }
-
- WorkingSetID id = ws->allocate();
- WorkingSetMember* member = ws->get(id);
- member->keyData.clear();
- member->recordId = RecordId();
- member->obj = Snapshotted<BSONObj>(SnapshotId(), maybe);
- member->transitionToOwnedObj();
- root->pushBack(id);
-}
-
-BSONObj buildViewBson(const ViewDefinition& view) {
- BSONObjBuilder b;
- b.append("name", view.name().coll());
- b.append("type", "view");
- BSONObj options = BSON("viewOn" << view.viewOn().coll() << "pipeline" << view.pipeline());
- b.append("options", options);
- BSONObj info = BSON("readOnly" << true);
- b.append("info", info);
- return b.obj();
-}
-
-BSONObj buildCollectionBson(OperationContext* txn, const Collection* collection) {
-
if (!collection) {
- return {};
+ return;
}
StringData collectionName = collection->ns().coll();
if (collectionName == "system.namespaces") {
- return {};
+ return;
}
BSONObjBuilder b;
b.append("name", collectionName);
- b.append("type", "collection");
CollectionOptions options = collection->getCatalogEntry()->getCollectionOptions(txn);
b.append("options", options.toBSON());
- BSONObj info = BSON("readOnly" << storageGlobalParams.readOnly);
- b.append("info", info);
+ BSONObj maybe = b.obj();
+ if (matcher && !matcher->matchesBSON(maybe)) {
+ return;
+ }
- return b.obj();
+ WorkingSetID id = ws->allocate();
+ WorkingSetMember* member = ws->get(id);
+ member->keyData.clear();
+ member->recordId = RecordId();
+ member->obj = Snapshotted<BSONObj>(SnapshotId(), maybe);
+ member->transitionToOwnedObj();
+ root->pushBack(id);
}
class CmdListCollections : public Command {
@@ -233,7 +212,7 @@ public:
ScopedTransaction scopedXact(txn, MODE_IS);
AutoGetDb autoDb(txn, dbname, MODE_S);
- Database* db = autoDb.getDb();
+ const Database* db = autoDb.getDb();
auto ws = make_unique<WorkingSet>();
auto root = make_unique<QueuedDataStage>(txn, ws.get());
@@ -242,27 +221,12 @@ public:
if (auto collNames = _getExactNameMatches(matcher.get())) {
for (auto&& collName : *collNames) {
auto nss = NamespaceString(db->name(), collName);
- Collection* collection = db->getCollection(nss);
- BSONObj collBson = buildCollectionBson(txn, collection);
- if (!collBson.isEmpty()) {
- _addWorkingSetMember(txn, collBson, matcher.get(), ws.get(), root.get());
- }
+ _addWorkingSetMember(
+ txn, db->getCollection(nss), matcher.get(), ws.get(), root.get());
}
} else {
for (auto&& collection : *db) {
- BSONObj collBson = buildCollectionBson(txn, collection);
- if (!collBson.isEmpty()) {
- _addWorkingSetMember(txn, collBson, matcher.get(), ws.get(), root.get());
- }
- }
- }
- auto viewCatalog = db->getViewCatalog();
- if (viewCatalog) {
- for (auto& view : *viewCatalog) {
- BSONObj viewBson = buildViewBson(*(view.second.get()));
- if (!viewBson.isEmpty()) {
- _addWorkingSetMember(txn, viewBson, matcher.get(), ws.get(), root.get());
- }
+ _addWorkingSetMember(txn, collection, matcher.get(), ws.get(), root.get());
}
}
}