summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/drop_collection.cpp
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 00:22:50 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 10:56:02 -0400
commit9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch)
tree3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/catalog/drop_collection.cpp
parent01965cf52bce6976637ecb8f4a622aeb05ab256a (diff)
downloadmongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/catalog/drop_collection.cpp')
-rw-r--r--src/mongo/db/catalog/drop_collection.cpp75
1 files changed, 38 insertions, 37 deletions
diff --git a/src/mongo/db/catalog/drop_collection.cpp b/src/mongo/db/catalog/drop_collection.cpp
index cb932432dab..67bfb70ae45 100644
--- a/src/mongo/db/catalog/drop_collection.cpp
+++ b/src/mongo/db/catalog/drop_collection.cpp
@@ -48,54 +48,55 @@
#include "mongo/util/log.h"
namespace mongo {
- Status dropCollection(OperationContext* txn,
- const NamespaceString& collectionName,
- BSONObjBuilder& result) {
- if (!serverGlobalParams.quiet) {
- log() << "CMD: drop " << collectionName;
- }
+Status dropCollection(OperationContext* txn,
+ const NamespaceString& collectionName,
+ BSONObjBuilder& result) {
+ if (!serverGlobalParams.quiet) {
+ log() << "CMD: drop " << collectionName;
+ }
- std::string dbname = collectionName.db().toString();
+ std::string dbname = collectionName.db().toString();
- MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
- ScopedTransaction transaction(txn, MODE_IX);
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
+ ScopedTransaction transaction(txn, MODE_IX);
- AutoGetDb autoDb(txn, dbname, MODE_X);
- Database* const db = autoDb.getDb();
- Collection* coll = db ? db->getCollection(collectionName) : nullptr;
+ AutoGetDb autoDb(txn, dbname, MODE_X);
+ Database* const db = autoDb.getDb();
+ Collection* coll = db ? db->getCollection(collectionName) : nullptr;
- // If db/collection does not exist, short circuit and return.
- if ( !db || !coll ) {
- return Status(ErrorCodes::NamespaceNotFound, "ns not found");
- }
- OldClientContext context(txn, collectionName);
+ // If db/collection does not exist, short circuit and return.
+ if (!db || !coll) {
+ return Status(ErrorCodes::NamespaceNotFound, "ns not found");
+ }
+ OldClientContext context(txn, collectionName);
- bool userInitiatedWritesAndNotPrimary = txn->writesAreReplicated() &&
- !repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(collectionName);
+ bool userInitiatedWritesAndNotPrimary = txn->writesAreReplicated() &&
+ !repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(collectionName);
- if (userInitiatedWritesAndNotPrimary) {
- return Status(ErrorCodes::NotMaster,
- str::stream() << "Not primary while dropping collection "
- << collectionName.ns());
- }
+ if (userInitiatedWritesAndNotPrimary) {
+ return Status(ErrorCodes::NotMaster,
+ str::stream() << "Not primary while dropping collection "
+ << collectionName.ns());
+ }
- int numIndexes = coll->getIndexCatalog()->numIndexesTotal(txn);
+ int numIndexes = coll->getIndexCatalog()->numIndexesTotal(txn);
- BackgroundOperation::assertNoBgOpInProgForNs(collectionName.ns());
+ BackgroundOperation::assertNoBgOpInProgForNs(collectionName.ns());
- WriteUnitOfWork wunit(txn);
- Status s = db->dropCollection(txn, collectionName.ns());
+ WriteUnitOfWork wunit(txn);
+ Status s = db->dropCollection(txn, collectionName.ns());
- result.append("ns", collectionName);
+ result.append("ns", collectionName);
- if ( !s.isOK() ) {
- return s;
- }
+ if (!s.isOK()) {
+ return s;
+ }
- result.append("nIndexesWas", numIndexes);
+ result.append("nIndexesWas", numIndexes);
- wunit.commit();
- } MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "drop", collectionName.ns());
- return Status::OK();
+ wunit.commit();
}
-} // namespace mongo
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "drop", collectionName.ns());
+ return Status::OK();
+}
+} // namespace mongo