diff options
author | Mathias Stearn <mathias@10gen.com> | 2014-01-30 17:16:36 -0500 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2014-02-12 11:38:38 -0500 |
commit | 20806b5757b5bf4dbf524df0f332170012086af7 (patch) | |
tree | c0f71847c38417ae835bd2dff99eef4d59f9d4ce /src/mongo/db/pipeline/pipeline_d.cpp | |
parent | 8c99c9ad5cd5ef14f808c1c135f807255330f025 (diff) | |
download | mongo-20806b5757b5bf4dbf524df0f332170012086af7.tar.gz |
SERVER-12530 clean up agg output cursor creation and locking
Diffstat (limited to 'src/mongo/db/pipeline/pipeline_d.cpp')
-rw-r--r-- | src/mongo/db/pipeline/pipeline_d.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/mongo/db/pipeline/pipeline_d.cpp b/src/mongo/db/pipeline/pipeline_d.cpp index 7bb6f0940d2..e85a5b3d3ee 100644 --- a/src/mongo/db/pipeline/pipeline_d.cpp +++ b/src/mongo/db/pipeline/pipeline_d.cpp @@ -63,9 +63,12 @@ namespace { }; } - void PipelineD::prepareCursorSource( - const intrusive_ptr<Pipeline> &pPipeline, - const intrusive_ptr<ExpressionContext> &pExpCtx) { + void PipelineD::prepareCursorSource(const intrusive_ptr<Pipeline>& pPipeline, + const intrusive_ptr<ExpressionContext>& pExpCtx, + Collection* collection) { + // get the full "namespace" name + const string& fullName = pExpCtx->ns.ns(); + Lock::assertAtLeastReadLocked(fullName); // We will be modifying the source vector as we go Pipeline::SourceContainer& sources = pPipeline->sources; @@ -125,9 +128,6 @@ namespace { } } - // get the full "namespace" name - const string& fullName = pExpCtx->ns.ns(); - // for debugging purposes, show what the query and sort are DEV { (log() << "\n---- query BSON\n" << @@ -138,11 +138,9 @@ namespace { fullName << "\n----\n"); } - // Create the necessary context to use a Runner, including taking a namespace read lock. - // Note: this may throw if the sharding version for this connection is out of date. - Client::ReadContext context(fullName); - Collection* collection = context.ctx().db()->getCollection(fullName); - if ( !collection ) { + if (!collection) { + // Collection doesn't exist. Create a source that will return no results to simulate an + // empty collection. intrusive_ptr<DocumentSource> source(DocumentSourceBsonArray::create(BSONObj(), pExpCtx)); while (!sources.empty() && source->coalesce(sources.front())) { |