diff options
author | Geert Bosch <geert@mongodb.com> | 2016-07-27 00:40:35 -0400 |
---|---|---|
committer | Geert Bosch <geert@mongodb.com> | 2016-08-01 20:47:00 -0400 |
commit | d62fb03017e6982825a3c3114de1d963f628716f (patch) | |
tree | c7e066ae0a8989bc6fcebb8e387cc331cd2e210e /src/mongo/db/catalog/capped_utils.cpp | |
parent | 72bbaf4f5c3ab1c76dd9b67ce83be46c44092a80 (diff) | |
download | mongo-d62fb03017e6982825a3c3114de1d963f628716f.tar.gz |
SERVER-24823 Add support for remaining admin commands
Diffstat (limited to 'src/mongo/db/catalog/capped_utils.cpp')
-rw-r--r-- | src/mongo/db/catalog/capped_utils.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/mongo/db/catalog/capped_utils.cpp b/src/mongo/db/catalog/capped_utils.cpp index bfaf21c823a..8728658544d 100644 --- a/src/mongo/db/catalog/capped_utils.cpp +++ b/src/mongo/db/catalog/capped_utils.cpp @@ -32,6 +32,7 @@ #include "mongo/db/catalog/capped_utils.h" +#include "mongo/base/error_codes.h" #include "mongo/db/background.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/collection_catalog_entry.h" @@ -47,6 +48,7 @@ #include "mongo/db/query/plan_yield_policy.h" #include "mongo/db/repl/replication_coordinator_global.h" #include "mongo/db/service_context.h" +#include "mongo/db/views/view.h" #include "mongo/util/scopeguard.h" namespace mongo { @@ -67,6 +69,9 @@ Status emptyCapped(OperationContext* txn, const NamespaceString& collectionName) massert(13429, "no such database", db); Collection* collection = db->getCollection(collectionName); + uassert(ErrorCodes::CommandNotSupportedOnView, + str::stream() << "emptyCapped not supported on view: " << collectionName.ns(), + collection || !db->getViewCatalog()->lookup(txn, collectionName.ns())); massert(28584, "no such collection", collection); BackgroundOperation::assertNoBgOpInProgForNs(collectionName.ns()); @@ -95,9 +100,15 @@ Status cloneCollectionAsCapped(OperationContext* txn, std::string toNs = db->name() + "." + shortTo; Collection* fromCollection = db->getCollection(fromNs); - if (!fromCollection) + if (!fromCollection) { + if (db->getViewCatalog()->lookup(txn, fromNs)) { + return Status(ErrorCodes::CommandNotSupportedOnView, + str::stream() << "cloneCollectionAsCapped not supported for views: " + << fromNs); + } return Status(ErrorCodes::NamespaceNotFound, str::stream() << "source collection " << fromNs << " does not exist"); + } if (db->getCollection(toNs)) return Status(ErrorCodes::NamespaceExists, "to collection already exists"); |