summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/drop_indexes.cpp
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2016-07-20 00:24:36 -0400
committerGeert Bosch <geert@mongodb.com>2016-07-24 16:29:36 -0400
commit7f17bd8ee649787d6a2ba02dfa3bb5da7ff0bb41 (patch)
tree522b36c03d5c5a82b85b3bc15f69e7a5e1009c5d /src/mongo/db/commands/drop_indexes.cpp
parent1af80cb7d16a8c791aba667758d5fea22384814b (diff)
downloadmongo-7f17bd8ee649787d6a2ba02dfa3bb5da7ff0bb41.tar.gz
SERVER-24823 Add admin commands, durable system.views catalog
Consolidate disallowed commands in views_all_commands.js testing.
Diffstat (limited to 'src/mongo/db/commands/drop_indexes.cpp')
-rw-r--r--src/mongo/db/commands/drop_indexes.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp
index 2b334a51e87..fb98444202e 100644
--- a/src/mongo/db/commands/drop_indexes.cpp
+++ b/src/mongo/db/commands/drop_indexes.cpp
@@ -124,22 +124,27 @@ public:
BSONObjBuilder& result) {
DBDirectClient db(txn);
- const NamespaceString toDeleteNs = parseNsCollectionRequired(dbname, jsobj);
+ const NamespaceString toReIndexNs = parseNsCollectionRequired(dbname, jsobj);
- LOG(0) << "CMD: reIndex " << toDeleteNs << endl;
+ LOG(0) << "CMD: reIndex " << toReIndexNs << endl;
ScopedTransaction transaction(txn, MODE_IX);
Lock::DBLock dbXLock(txn->lockState(), dbname, MODE_X);
- OldClientContext ctx(txn, toDeleteNs.ns());
+ OldClientContext ctx(txn, toReIndexNs.ns());
- Collection* collection = ctx.db()->getCollection(toDeleteNs.ns());
+ Collection* collection = ctx.db()->getCollection(toReIndexNs.ns());
+ auto view = ctx.db()->getViewCatalog()->lookup(toReIndexNs.ns());
if (!collection) {
- errmsg = "ns not found";
- return false;
+ if (view)
+ return appendCommandStatus(
+ result, {ErrorCodes::CommandNotSupportedOnView, "can't re-index a view"});
+ else
+ return appendCommandStatus(
+ result, {ErrorCodes::NamespaceNotFound, "collection does not exist"});
}
- BackgroundOperation::assertNoBgOpInProgForNs(toDeleteNs.ns());
+ BackgroundOperation::assertNoBgOpInProgForNs(toReIndexNs.ns());
vector<BSONObj> all;
{