diff options
Diffstat (limited to 'src/mongo/db/exec/stagedebug_cmd.cpp')
-rw-r--r-- | src/mongo/db/exec/stagedebug_cmd.cpp | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/src/mongo/db/exec/stagedebug_cmd.cpp b/src/mongo/db/exec/stagedebug_cmd.cpp index 926cca4c485..72949a80598 100644 --- a/src/mongo/db/exec/stagedebug_cmd.cpp +++ b/src/mongo/db/exec/stagedebug_cmd.cpp @@ -137,7 +137,7 @@ public: // check needed. } - bool run(OperationContext* txn, + bool run(OperationContext* opCtx, const string& dbname, BSONObj& cmdObj, int, @@ -164,8 +164,8 @@ public: // TODO A write lock is currently taken here to accommodate stages that perform writes // (e.g. DeleteStage). This should be changed to use a read lock for read-only // execution trees. - ScopedTransaction transaction(txn, MODE_IX); - AutoGetCollection autoColl(txn, nss, MODE_IX); + ScopedTransaction transaction(opCtx, MODE_IX); + AutoGetCollection autoColl(opCtx, nss, MODE_IX); // Make sure the collection is valid. Collection* collection = autoColl.getCollection(); @@ -184,16 +184,16 @@ public: OwnedPointerVector<MatchExpression> exprs; unique_ptr<WorkingSet> ws(new WorkingSet()); - PlanStage* userRoot = parseQuery(txn, collection, planObj, ws.get(), &exprs); + PlanStage* userRoot = parseQuery(opCtx, collection, planObj, ws.get(), &exprs); uassert(16911, "Couldn't parse plan from " + cmdObj.toString(), NULL != userRoot); // Add a fetch at the top for the user so we can get obj back for sure. // TODO: Do we want to do this for the user? I think so. unique_ptr<PlanStage> rootFetch = - make_unique<FetchStage>(txn, ws.get(), userRoot, nullptr, collection); + make_unique<FetchStage>(opCtx, ws.get(), userRoot, nullptr, collection); auto statusWithPlanExecutor = PlanExecutor::make( - txn, std::move(ws), std::move(rootFetch), collection, PlanExecutor::YIELD_AUTO); + opCtx, std::move(ws), std::move(rootFetch), collection, PlanExecutor::YIELD_AUTO); fassert(28536, statusWithPlanExecutor.getStatus()); std::unique_ptr<PlanExecutor> exec = std::move(statusWithPlanExecutor.getValue()); @@ -223,7 +223,7 @@ public: return true; } - PlanStage* parseQuery(OperationContext* txn, + PlanStage* parseQuery(OperationContext* opCtx, Collection* collection, BSONObj obj, WorkingSet* workingSet, @@ -251,7 +251,7 @@ public: if (filterTag == e.fieldName()) { const CollatorInterface* collator = nullptr; StatusWithMatchExpression statusWithMatcher = MatchExpressionParser::parse( - argObj, ExtensionsCallbackReal(txn, &collection->ns()), collator); + argObj, ExtensionsCallbackReal(opCtx, &collection->ns()), collator); if (!statusWithMatcher.isOK()) { return NULL; } @@ -279,7 +279,7 @@ public: BSONObj keyPatternObj = keyPatternElement.Obj(); std::vector<IndexDescriptor*> indexes; collection->getIndexCatalog()->findIndexesByKeyPattern( - txn, keyPatternObj, false, &indexes); + opCtx, keyPatternObj, false, &indexes); uassert(16890, str::stream() << "Can't find index: " << keyPatternObj, !indexes.empty()); @@ -297,7 +297,7 @@ public: str::stream() << "Index 'name' must be a string in: " << nodeArgs, nodeArgs["name"].type() == BSONType::String); StringData name = nodeArgs["name"].valueStringData(); - desc = collection->getIndexCatalog()->findIndexByName(txn, name); + desc = collection->getIndexCatalog()->findIndexByName(opCtx, name); uassert(40223, str::stream() << "Can't find index: " << name.toString(), desc); } @@ -310,12 +310,12 @@ public: nodeArgs["startKeyInclusive"].Bool(), nodeArgs["endKeyInclusive"].Bool()); params.direction = nodeArgs["direction"].numberInt(); - return new IndexScan(txn, params, workingSet, matcher); + return new IndexScan(opCtx, params, workingSet, matcher); } else if ("andHash" == nodeName) { uassert( 16921, "Nodes argument must be provided to AND", nodeArgs["nodes"].isABSONObj()); - auto andStage = make_unique<AndHashStage>(txn, workingSet, collection); + auto andStage = make_unique<AndHashStage>(opCtx, workingSet, collection); int nodesAdded = 0; BSONObjIterator it(nodeArgs["nodes"].Obj()); @@ -323,7 +323,7 @@ public: BSONElement e = it.next(); uassert(16922, "node of AND isn't an obj?: " + e.toString(), e.isABSONObj()); - PlanStage* subNode = parseQuery(txn, collection, e.Obj(), workingSet, exprs); + PlanStage* subNode = parseQuery(opCtx, collection, e.Obj(), workingSet, exprs); uassert( 16923, "Can't parse sub-node of AND: " + e.Obj().toString(), NULL != subNode); // takes ownership @@ -338,7 +338,7 @@ public: uassert( 16924, "Nodes argument must be provided to AND", nodeArgs["nodes"].isABSONObj()); - auto andStage = make_unique<AndSortedStage>(txn, workingSet, collection); + auto andStage = make_unique<AndSortedStage>(opCtx, workingSet, collection); int nodesAdded = 0; BSONObjIterator it(nodeArgs["nodes"].Obj()); @@ -346,7 +346,7 @@ public: BSONElement e = it.next(); uassert(16925, "node of AND isn't an obj?: " + e.toString(), e.isABSONObj()); - PlanStage* subNode = parseQuery(txn, collection, e.Obj(), workingSet, exprs); + PlanStage* subNode = parseQuery(opCtx, collection, e.Obj(), workingSet, exprs); uassert( 16926, "Can't parse sub-node of AND: " + e.Obj().toString(), NULL != subNode); // takes ownership @@ -362,13 +362,14 @@ public: 16934, "Nodes argument must be provided to AND", nodeArgs["nodes"].isABSONObj()); uassert(16935, "Dedup argument must be provided to OR", !nodeArgs["dedup"].eoo()); BSONObjIterator it(nodeArgs["nodes"].Obj()); - auto orStage = make_unique<OrStage>(txn, workingSet, nodeArgs["dedup"].Bool(), matcher); + auto orStage = + make_unique<OrStage>(opCtx, workingSet, nodeArgs["dedup"].Bool(), matcher); while (it.more()) { BSONElement e = it.next(); if (!e.isABSONObj()) { return NULL; } - PlanStage* subNode = parseQuery(txn, collection, e.Obj(), workingSet, exprs); + PlanStage* subNode = parseQuery(opCtx, collection, e.Obj(), workingSet, exprs); uassert( 16936, "Can't parse sub-node of OR: " + e.Obj().toString(), NULL != subNode); // takes ownership @@ -380,11 +381,11 @@ public: uassert( 16929, "Node argument must be provided to fetch", nodeArgs["node"].isABSONObj()); PlanStage* subNode = - parseQuery(txn, collection, nodeArgs["node"].Obj(), workingSet, exprs); + parseQuery(opCtx, collection, nodeArgs["node"].Obj(), workingSet, exprs); uassert(28731, "Can't parse sub-node of FETCH: " + nodeArgs["node"].Obj().toString(), NULL != subNode); - return new FetchStage(txn, workingSet, subNode, matcher, collection); + return new FetchStage(opCtx, workingSet, subNode, matcher, collection); } else if ("limit" == nodeName) { uassert( 16937, "Limit stage doesn't have a filter (put it on the child)", NULL == matcher); @@ -392,22 +393,22 @@ public: 16930, "Node argument must be provided to limit", nodeArgs["node"].isABSONObj()); uassert(16931, "Num argument must be provided to limit", nodeArgs["num"].isNumber()); PlanStage* subNode = - parseQuery(txn, collection, nodeArgs["node"].Obj(), workingSet, exprs); + parseQuery(opCtx, collection, nodeArgs["node"].Obj(), workingSet, exprs); uassert(28732, "Can't parse sub-node of LIMIT: " + nodeArgs["node"].Obj().toString(), NULL != subNode); - return new LimitStage(txn, nodeArgs["num"].numberInt(), workingSet, subNode); + return new LimitStage(opCtx, nodeArgs["num"].numberInt(), workingSet, subNode); } else if ("skip" == nodeName) { uassert( 16938, "Skip stage doesn't have a filter (put it on the child)", NULL == matcher); uassert(16932, "Node argument must be provided to skip", nodeArgs["node"].isABSONObj()); uassert(16933, "Num argument must be provided to skip", nodeArgs["num"].isNumber()); PlanStage* subNode = - parseQuery(txn, collection, nodeArgs["node"].Obj(), workingSet, exprs); + parseQuery(opCtx, collection, nodeArgs["node"].Obj(), workingSet, exprs); uassert(28733, "Can't parse sub-node of SKIP: " + nodeArgs["node"].Obj().toString(), NULL != subNode); - return new SkipStage(txn, nodeArgs["num"].numberInt(), workingSet, subNode); + return new SkipStage(opCtx, nodeArgs["num"].numberInt(), workingSet, subNode); } else if ("cscan" == nodeName) { CollectionScanParams params; params.collection = collection; @@ -422,7 +423,7 @@ public: params.direction = CollectionScanParams::BACKWARD; } - return new CollectionScan(txn, params, workingSet, matcher); + return new CollectionScan(opCtx, params, workingSet, matcher); } // sort is disabled for now. #if 0 @@ -431,7 +432,7 @@ public: nodeArgs["node"].isABSONObj()); uassert(16970, "Pattern argument must be provided to sort", nodeArgs["pattern"].isABSONObj()); - PlanStage* subNode = parseQuery(txn, db, nodeArgs["node"].Obj(), workingSet, exprs); + PlanStage* subNode = parseQuery(opCtx, db, nodeArgs["node"].Obj(), workingSet, exprs); SortStageParams params; params.pattern = nodeArgs["pattern"].Obj(); return new SortStage(params, workingSet, subNode); @@ -448,14 +449,14 @@ public: params.pattern = nodeArgs["pattern"].Obj(); // Dedup is true by default. - auto mergeStage = make_unique<MergeSortStage>(txn, params, workingSet, collection); + auto mergeStage = make_unique<MergeSortStage>(opCtx, params, workingSet, collection); BSONObjIterator it(nodeArgs["nodes"].Obj()); while (it.more()) { BSONElement e = it.next(); uassert(16973, "node of mergeSort isn't an obj?: " + e.toString(), e.isABSONObj()); - PlanStage* subNode = parseQuery(txn, collection, e.Obj(), workingSet, exprs); + PlanStage* subNode = parseQuery(opCtx, collection, e.Obj(), workingSet, exprs); uassert(16974, "Can't parse sub-node of mergeSort: " + e.Obj().toString(), NULL != subNode); @@ -467,7 +468,7 @@ public: string search = nodeArgs["search"].String(); vector<IndexDescriptor*> idxMatches; - collection->getIndexCatalog()->findIndexByType(txn, "text", idxMatches); + collection->getIndexCatalog()->findIndexByType(opCtx, "text", idxMatches); uassert(17194, "Expected exactly one text index", idxMatches.size() == 1); IndexDescriptor* index = idxMatches[0]; @@ -494,7 +495,7 @@ public: return NULL; } - return new TextStage(txn, params, workingSet, matcher); + return new TextStage(opCtx, params, workingSet, matcher); } else if ("delete" == nodeName) { uassert( 18636, "Delete stage doesn't have a filter (put it on the child)", NULL == matcher); @@ -504,13 +505,13 @@ public: "isMulti argument must be provided to delete", nodeArgs["isMulti"].type() == Bool); PlanStage* subNode = - parseQuery(txn, collection, nodeArgs["node"].Obj(), workingSet, exprs); + parseQuery(opCtx, collection, nodeArgs["node"].Obj(), workingSet, exprs); uassert(28734, "Can't parse sub-node of DELETE: " + nodeArgs["node"].Obj().toString(), NULL != subNode); DeleteStageParams params; params.isMulti = nodeArgs["isMulti"].Bool(); - return new DeleteStage(txn, params, workingSet, collection, subNode); + return new DeleteStage(opCtx, params, workingSet, collection, subNode); } else { return NULL; } |