summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/drop_indexes.cpp
diff options
context:
space:
mode:
authorMaria van Keulen <maria@mongodb.com>2017-03-07 12:00:08 -0500
committerMaria van Keulen <maria@mongodb.com>2017-03-07 12:00:08 -0500
commit589a5c169ced8f6e9ddcd3d182ae1b75db6b7d79 (patch)
treec7a090ffdd56a91ae677e2492c61b820af44f964 /src/mongo/db/catalog/drop_indexes.cpp
parent3cba97198638df3750e3b455e2ad57af7ee536ae (diff)
downloadmongo-589a5c169ced8f6e9ddcd3d182ae1b75db6b7d79.tar.gz
SERVER-27938 Rename all OperationContext variables to opCtx
This commit is an automated rename of all whole word instances of txn, _txn, and txnPtr to opCtx, _opCtx, and opCtxPtr, respectively in all .cpp and .h files in src/mongo.
Diffstat (limited to 'src/mongo/db/catalog/drop_indexes.cpp')
-rw-r--r--src/mongo/db/catalog/drop_indexes.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/mongo/db/catalog/drop_indexes.cpp b/src/mongo/db/catalog/drop_indexes.cpp
index 78739b6e4da..55c559912df 100644
--- a/src/mongo/db/catalog/drop_indexes.cpp
+++ b/src/mongo/db/catalog/drop_indexes.cpp
@@ -48,7 +48,7 @@
namespace mongo {
namespace {
-Status wrappedRun(OperationContext* txn,
+Status wrappedRun(OperationContext* opCtx,
const StringData& dbname,
const std::string& toDeleteNs,
Database* const db,
@@ -61,7 +61,7 @@ Status wrappedRun(OperationContext* txn,
// If db/collection does not exist, short circuit and return.
if (!db || !collection) {
- if (db && db->getViewCatalog()->lookup(txn, toDeleteNs)) {
+ if (db && db->getViewCatalog()->lookup(opCtx, toDeleteNs)) {
return {ErrorCodes::CommandNotSupportedOnView,
str::stream() << "Cannot drop indexes on view " << toDeleteNs};
}
@@ -69,11 +69,11 @@ Status wrappedRun(OperationContext* txn,
return Status(ErrorCodes::NamespaceNotFound, "ns not found");
}
- OldClientContext ctx(txn, toDeleteNs);
+ OldClientContext ctx(opCtx, toDeleteNs);
BackgroundOperation::assertNoBgOpInProgForNs(toDeleteNs);
IndexCatalog* indexCatalog = collection->getIndexCatalog();
- anObjBuilder->appendNumber("nIndexesWas", indexCatalog->numIndexesTotal(txn));
+ anObjBuilder->appendNumber("nIndexesWas", indexCatalog->numIndexesTotal(opCtx));
BSONElement f = jsobj.getField("index");
@@ -81,7 +81,7 @@ Status wrappedRun(OperationContext* txn,
std::string indexToDelete = f.valuestr();
if (indexToDelete == "*") {
- Status s = indexCatalog->dropAllIndexes(txn, false);
+ Status s = indexCatalog->dropAllIndexes(opCtx, false);
if (!s.isOK()) {
return s;
}
@@ -89,7 +89,8 @@ Status wrappedRun(OperationContext* txn,
return Status::OK();
}
- IndexDescriptor* desc = collection->getIndexCatalog()->findIndexByName(txn, indexToDelete);
+ IndexDescriptor* desc =
+ collection->getIndexCatalog()->findIndexByName(opCtx, indexToDelete);
if (desc == NULL) {
return Status(ErrorCodes::IndexNotFound,
str::stream() << "index not found with name [" << indexToDelete << "]");
@@ -99,7 +100,7 @@ Status wrappedRun(OperationContext* txn,
return Status(ErrorCodes::InvalidOptions, "cannot drop _id index");
}
- Status s = indexCatalog->dropIndex(txn, desc);
+ Status s = indexCatalog->dropIndex(opCtx, desc);
if (!s.isOK()) {
return s;
}
@@ -110,7 +111,7 @@ Status wrappedRun(OperationContext* txn,
if (f.type() == Object) {
std::vector<IndexDescriptor*> indexes;
collection->getIndexCatalog()->findIndexesByKeyPattern(
- txn, f.embeddedObject(), false, &indexes);
+ opCtx, f.embeddedObject(), false, &indexes);
if (indexes.empty()) {
return Status(ErrorCodes::IndexNotFound,
str::stream() << "can't find index with key: " << f.embeddedObject());
@@ -130,7 +131,7 @@ Status wrappedRun(OperationContext* txn,
return Status(ErrorCodes::InvalidOptions, "cannot drop _id index");
}
- Status s = indexCatalog->dropIndex(txn, desc);
+ Status s = indexCatalog->dropIndex(opCtx, desc);
if (!s.isOK()) {
return s;
}
@@ -142,35 +143,35 @@ Status wrappedRun(OperationContext* txn,
}
} // namespace
-Status dropIndexes(OperationContext* txn,
+Status dropIndexes(OperationContext* opCtx,
const NamespaceString& nss,
const BSONObj& idxDescriptor,
BSONObjBuilder* result) {
StringData dbName = nss.db();
MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
- ScopedTransaction transaction(txn, MODE_IX);
- AutoGetDb autoDb(txn, dbName, MODE_X);
+ ScopedTransaction transaction(opCtx, MODE_IX);
+ AutoGetDb autoDb(opCtx, dbName, MODE_X);
- bool userInitiatedWritesAndNotPrimary = txn->writesAreReplicated() &&
- !repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(txn, nss);
+ bool userInitiatedWritesAndNotPrimary = opCtx->writesAreReplicated() &&
+ !repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(opCtx, nss);
if (userInitiatedWritesAndNotPrimary) {
return {ErrorCodes::NotMaster,
str::stream() << "Not primary while dropping indexes in " << nss.ns()};
}
- WriteUnitOfWork wunit(txn);
- Status status = wrappedRun(txn, dbName, nss.ns(), autoDb.getDb(), idxDescriptor, result);
+ WriteUnitOfWork wunit(opCtx);
+ Status status = wrappedRun(opCtx, dbName, nss.ns(), autoDb.getDb(), idxDescriptor, result);
if (!status.isOK()) {
return status;
}
getGlobalServiceContext()->getOpObserver()->onDropIndex(
- txn, dbName.toString() + ".$cmd", idxDescriptor);
+ opCtx, dbName.toString() + ".$cmd", idxDescriptor);
wunit.commit();
}
- MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "dropIndexes", dbName);
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(opCtx, "dropIndexes", dbName);
return Status::OK();
}