diff options
author | Scott Hernandez <scotthernandez@gmail.com> | 2015-01-04 19:59:32 -0500 |
---|---|---|
committer | Scott Hernandez <scotthernandez@gmail.com> | 2015-01-05 11:31:40 -0500 |
commit | d6aca8833cce3c7f23c6da5f170ee24b7ea5f24b (patch) | |
tree | 749c1c175a1ac0f19c8f3ff1fcd620b35be5d8be /src/mongo/db/dbcommands.cpp | |
parent | 3753b0810391b237b543fdc16705d7ba90add3ce (diff) | |
download | mongo-d6aca8833cce3c7f23c6da5f170ee24b7ea5f24b.tar.gz |
SERVER-16711: do not create db for collmod if missing db/collection
Diffstat (limited to 'src/mongo/db/dbcommands.cpp')
-rw-r--r-- | src/mongo/db/dbcommands.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp index 671d5575d71..85b194b8ecd 100644 --- a/src/mongo/db/dbcommands.cpp +++ b/src/mongo/db/dbcommands.cpp @@ -1014,16 +1014,19 @@ namespace mongo { const std::string ns = dbname + "." + collName; ScopedTransaction transaction(txn, MODE_IX); - Lock::DBLock dbXLock(txn->lockState(), dbname, MODE_X); - WriteUnitOfWork wunit(txn); - Client::Context ctx(txn, ns ); + AutoGetDb autoDb(txn, dbname, MODE_X); + Database* const db = autoDb.getDb(); + Collection* coll = db ? db->getCollection(ns) : NULL; - Collection* coll = ctx.db()->getCollection( ns ); - if ( !coll ) { + // If db/collection does not exist, short circuit and return. + if ( !db || !coll ) { errmsg = "ns does not exist"; return false; } + Client::Context ctx(txn, ns); + WriteUnitOfWork wunit(txn); + bool ok = true; BSONForEach( e, jsobj ) { |