diff options
Diffstat (limited to 'src/mongo/db/commands/find_cmd.cpp')
-rw-r--r-- | src/mongo/db/commands/find_cmd.cpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp index d2b5075e283..c3d8e88b227 100644 --- a/src/mongo/db/commands/find_cmd.cpp +++ b/src/mongo/db/commands/find_cmd.cpp @@ -129,7 +129,7 @@ public: return AuthorizationSession::get(client)->checkAuthForFind(nss, hasTerm); } - Status explain(OperationContext* txn, + Status explain(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, ExplainCommon::Verbosity verbosity, @@ -158,9 +158,9 @@ public: // Finish the parsing step by using the QueryRequest to create a CanonicalQuery. - ExtensionsCallbackReal extensionsCallback(txn, &nss); + ExtensionsCallbackReal extensionsCallback(opCtx, &nss); auto statusWithCQ = - CanonicalQuery::canonicalize(txn, std::move(qrStatus.getValue()), extensionsCallback); + CanonicalQuery::canonicalize(opCtx, std::move(qrStatus.getValue()), extensionsCallback); if (!statusWithCQ.isOK()) { return statusWithCQ.getStatus(); } @@ -168,7 +168,7 @@ public: // Acquire locks. If the namespace is a view, we release our locks and convert the query // request into an aggregation command. - AutoGetCollectionOrViewForRead ctx(txn, nss); + AutoGetCollectionOrViewForRead ctx(opCtx, nss); if (ctx.getView()) { // Relinquish locks. The aggregation command will re-acquire them. ctx.releaseLocksForView(); @@ -184,7 +184,7 @@ public: std::string errmsg; try { - agg->run(txn, dbname, viewAggregationCommand.getValue(), 0, errmsg, *out); + agg->run(opCtx, dbname, viewAggregationCommand.getValue(), 0, errmsg, *out); } catch (DBException& error) { if (error.getCode() == ErrorCodes::InvalidPipelineOperator) { return {ErrorCodes::InvalidPipelineOperator, @@ -201,7 +201,7 @@ public: // We have a parsed query. Time to get the execution plan for it. auto statusWithPlanExecutor = - getExecutorFind(txn, collection, nss, std::move(cq), PlanExecutor::YIELD_AUTO); + getExecutorFind(opCtx, collection, nss, std::move(cq), PlanExecutor::YIELD_AUTO); if (!statusWithPlanExecutor.isOK()) { return statusWithPlanExecutor.getStatus(); } @@ -221,7 +221,7 @@ public: * --Save state for getMore, transferring ownership of the executor to a ClientCursor. * --Generate response to send to the client. */ - bool run(OperationContext* txn, + bool run(OperationContext* opCtx, const std::string& dbname, BSONObj& cmdObj, int options, @@ -237,7 +237,7 @@ public: // Although it is a command, a find command gets counted as a query. globalOpCounters.gotQuery(); - if (txn->getClient()->isInDirectClient()) { + if (opCtx->getClient()->isInDirectClient()) { return appendCommandStatus( result, Status(ErrorCodes::IllegalOperation, "Cannot run find command from eval()")); @@ -264,8 +264,8 @@ public: // Validate term before acquiring locks, if provided. if (auto term = qr->getReplicationTerm()) { - auto replCoord = repl::ReplicationCoordinator::get(txn); - Status status = replCoord->updateTerm(txn, *term); + auto replCoord = repl::ReplicationCoordinator::get(opCtx); + Status status = replCoord->updateTerm(opCtx, *term); // Note: updateTerm returns ok if term stayed the same. if (!status.isOK()) { return appendCommandStatus(result, status); @@ -279,11 +279,11 @@ public: // find command parameters, so these fields are redundant. const int ntoreturn = -1; const int ntoskip = -1; - beginQueryOp(txn, nss, cmdObj, ntoreturn, ntoskip); + beginQueryOp(opCtx, nss, cmdObj, ntoreturn, ntoskip); // Finish the parsing step by using the QueryRequest to create a CanonicalQuery. - ExtensionsCallbackReal extensionsCallback(txn, &nss); - auto statusWithCQ = CanonicalQuery::canonicalize(txn, std::move(qr), extensionsCallback); + ExtensionsCallbackReal extensionsCallback(opCtx, &nss); + auto statusWithCQ = CanonicalQuery::canonicalize(opCtx, std::move(qr), extensionsCallback); if (!statusWithCQ.isOK()) { return appendCommandStatus(result, statusWithCQ.getStatus()); } @@ -291,7 +291,7 @@ public: // Acquire locks. If the query is on a view, we release our locks and convert the query // request into an aggregation command. - AutoGetCollectionOrViewForRead ctx(txn, nss); + AutoGetCollectionOrViewForRead ctx(opCtx, nss); Collection* collection = ctx.getCollection(); if (ctx.getView()) { // Relinquish locks. The aggregation command will re-acquire them. @@ -306,7 +306,7 @@ public: Command* agg = Command::findCommand("aggregate"); try { - agg->run(txn, dbname, viewAggregationCommand.getValue(), options, errmsg, result); + agg->run(opCtx, dbname, viewAggregationCommand.getValue(), options, errmsg, result); } catch (DBException& error) { if (error.getCode() == ErrorCodes::InvalidPipelineOperator) { return appendCommandStatus( @@ -321,7 +321,7 @@ public: // Get the execution plan for the query. auto statusWithPlanExecutor = - getExecutorFind(txn, collection, nss, std::move(cq), PlanExecutor::YIELD_AUTO); + getExecutorFind(opCtx, collection, nss, std::move(cq), PlanExecutor::YIELD_AUTO); if (!statusWithPlanExecutor.isOK()) { return appendCommandStatus(result, statusWithPlanExecutor.getStatus()); } @@ -329,8 +329,8 @@ public: std::unique_ptr<PlanExecutor> exec = std::move(statusWithPlanExecutor.getValue()); { - stdx::lock_guard<Client> lk(*txn->getClient()); - CurOp::get(txn)->setPlanSummary_inlock(Explain::getPlanSummary(exec.get())); + stdx::lock_guard<Client> lk(*opCtx->getClient()); + CurOp::get(opCtx)->setPlanSummary_inlock(Explain::getPlanSummary(exec.get())); } if (!collection) { @@ -338,7 +338,7 @@ public: // there is no ClientCursor id, and then return. const long long numResults = 0; const CursorId cursorId = 0; - endQueryOp(txn, collection, *exec, numResults, cursorId); + endQueryOp(opCtx, collection, *exec, numResults, cursorId); appendCursorResponseObject(cursorId, nss.ns(), BSONArray(), &result); return true; } @@ -378,12 +378,12 @@ public: // Before saving the cursor, ensure that whatever plan we established happened with the // expected collection version - auto css = CollectionShardingState::get(txn, nss); - css->checkShardVersionOrThrow(txn); + auto css = CollectionShardingState::get(opCtx, nss); + css->checkShardVersionOrThrow(opCtx); // Set up the cursor for getMore. CursorId cursorId = 0; - if (shouldSaveCursor(txn, collection, state, exec.get())) { + if (shouldSaveCursor(opCtx, collection, state, exec.get())) { // Register the execution plan inside a ClientCursor. Ownership of the PlanExecutor is // transferred to the ClientCursor. // @@ -395,7 +395,7 @@ public: ClientCursorPin pinnedCursor = collection->getCursorManager()->registerCursor( {exec.release(), nss.ns(), - txn->recoveryUnit()->isReadingFromMajorityCommittedSnapshot(), + opCtx->recoveryUnit()->isReadingFromMajorityCommittedSnapshot(), originalQR.getOptions(), cmdObj.getOwned()}); cursorId = pinnedCursor.getCursor()->cursorid(); @@ -407,13 +407,13 @@ public: cursorExec->saveState(); cursorExec->detachFromOperationContext(); - pinnedCursor.getCursor()->setLeftoverMaxTimeMicros(txn->getRemainingMaxTimeMicros()); + pinnedCursor.getCursor()->setLeftoverMaxTimeMicros(opCtx->getRemainingMaxTimeMicros()); pinnedCursor.getCursor()->setPos(numResults); // Fill out curop based on the results. - endQueryOp(txn, collection, *cursorExec, numResults, cursorId); + endQueryOp(opCtx, collection, *cursorExec, numResults, cursorId); } else { - endQueryOp(txn, collection, *exec, numResults, cursorId); + endQueryOp(opCtx, collection, *exec, numResults, cursorId); } // Generate the response object to send to the client. |