summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Boros <ian.boros@10gen.com>2019-01-22 12:18:42 -0500
committerIan Boros <ian.boros@10gen.com>2019-01-31 16:14:44 -0500
commit69ba97af386b1ef713579c24dd1f8dbcac2fe7dc (patch)
tree3efb9e13ed0761e072c75b27429455ce209e93c8 /src
parenta31407309c0440c220c81c63d3053910d90ce4e1 (diff)
downloadmongo-69ba97af386b1ef713579c24dd1f8dbcac2fe7dc.tar.gz
SERVER-39109 fix case where agg uses illegal field path
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/pipeline/pipeline_d.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/mongo/db/pipeline/pipeline_d.cpp b/src/mongo/db/pipeline/pipeline_d.cpp
index 9be12b669e6..e2a3526984a 100644
--- a/src/mongo/db/pipeline/pipeline_d.cpp
+++ b/src/mongo/db/pipeline/pipeline_d.cpp
@@ -888,10 +888,12 @@ void PipelineD::addCursorSource(Collection* collection,
intrusive_ptr<DocumentSourceCursor> pSource = DocumentSourceCursor::create(
collection, std::move(exec), expCtx, failsForExecutionLevelExplain);
- // Note the query, sort, and projection for explain.
+ // Add the cursor to the pipeline first so that it's correctly disposed of as part of the
+ // pipeline if an exception is thrown during this method.
+ pipeline->addInitialSource(pSource);
+
pSource->setQuery(queryObj);
pSource->setSort(sortObj);
-
if (deps.hasNoRequirements()) {
pSource->shouldProduceEmptyDocs();
}
@@ -908,7 +910,6 @@ void PipelineD::addCursorSource(Collection* collection,
pSource->setProjection(deps.toProjection(), deps.toParsedDeps());
}
- pipeline->addInitialSource(pSource);
}
Timestamp PipelineD::getLatestOplogTimestamp(const Pipeline* pipeline) {