summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/collection_to_capped.cpp
diff options
context:
space:
mode:
authormatt dannenberg <matt.dannenberg@10gen.com>2014-04-28 06:38:03 -0400
committermatt dannenberg <matt.dannenberg@10gen.com>2014-04-28 08:14:43 -0400
commitff276366a823fdbd73be5594244b4bdb4e63e1a0 (patch)
treed1c28b3460c0ccc660b4b32f431f2deb2193c9cd /src/mongo/db/commands/collection_to_capped.cpp
parent6b0e83f0cf1d4e777986b1fc64f0d3133315bf18 (diff)
downloadmongo-ff276366a823fdbd73be5594244b4bdb4e63e1a0.tar.gz
SERVER-13750 prevent invariant failure when ConvertToCappeding a nonexistent collection
Diffstat (limited to 'src/mongo/db/commands/collection_to_capped.cpp')
-rw-r--r--src/mongo/db/commands/collection_to_capped.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/mongo/db/commands/collection_to_capped.cpp b/src/mongo/db/commands/collection_to_capped.cpp
index 6e9c1f64056..7df06e876ed 100644
--- a/src/mongo/db/commands/collection_to_capped.cpp
+++ b/src/mongo/db/commands/collection_to_capped.cpp
@@ -186,12 +186,16 @@ namespace mongo {
virtual std::vector<BSONObj> stopIndexBuilds(Database* db,
const BSONObj& cmdObj) {
- std::string coll = cmdObj.firstElement().valuestr();
- std::string ns = db->name() + "." + coll;
+ std::string collName = cmdObj.firstElement().valuestr();
+ std::string ns = db->name() + "." + collName;
IndexCatalog::IndexKillCriteria criteria;
criteria.ns = ns;
- return IndexBuilder::killMatchingIndexBuilds(db->getCollection(ns), criteria);
+ Collection* coll = db->getCollection(ns);
+ if (coll) {
+ return IndexBuilder::killMatchingIndexBuilds(coll, criteria);
+ }
+ return std::vector<BSONObj>();
}
bool run(const string& dbname, BSONObj& jsobj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl ) {