diff options
author | Ruslan Abdulkhalikov <ruslan.abdulkhalikov@mongodb.com> | 2022-02-02 23:53:33 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-02-03 00:31:08 +0000 |
commit | f1664bad02c3ebf8593ae3418fc172e336d8f6cc (patch) | |
tree | a388a965c6ac65b7994acebe33f87f3b1c07d38f /src/mongo/db/pipeline | |
parent | 3f7f9f57be3b127a6334c584b8a1795480baf1ae (diff) | |
download | mongo-f1664bad02c3ebf8593ae3418fc172e336d8f6cc.tar.gz |
SERVER-60800 add optional UUID to ResolvedNamespace
Diffstat (limited to 'src/mongo/db/pipeline')
-rw-r--r-- | src/mongo/db/pipeline/document_source_graph_lookup.cpp | 9 | ||||
-rw-r--r-- | src/mongo/db/pipeline/document_source_lookup.cpp | 10 | ||||
-rw-r--r-- | src/mongo/db/pipeline/document_source_union_with.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/pipeline/expression_context.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/pipeline/expression_context.h | 10 |
5 files changed, 23 insertions, 13 deletions
diff --git a/src/mongo/db/pipeline/document_source_graph_lookup.cpp b/src/mongo/db/pipeline/document_source_graph_lookup.cpp index 331e8fdd444..e77137c922c 100644 --- a/src/mongo/db/pipeline/document_source_graph_lookup.cpp +++ b/src/mongo/db/pipeline/document_source_graph_lookup.cpp @@ -617,7 +617,7 @@ DocumentSourceGraphLookUp::DocumentSourceGraphLookUp( _variables(expCtx->variables), _variablesParseState(expCtx->variablesParseState.copyWith(_variables.useIdGenerator())) { const auto& resolvedNamespace = pExpCtx->getResolvedNamespace(_from); - _fromExpCtx = pExpCtx->copyForSubPipeline(resolvedNamespace.ns); + _fromExpCtx = pExpCtx->copyForSubPipeline(resolvedNamespace.ns, resolvedNamespace.uuid); // We append an additional BSONObj to '_fromPipeline' as a placeholder for the $match stage // we'll eventually construct from the input document. @@ -627,7 +627,8 @@ DocumentSourceGraphLookUp::DocumentSourceGraphLookUp( } DocumentSourceGraphLookUp::DocumentSourceGraphLookUp(const DocumentSourceGraphLookUp& original) - : DocumentSource(kStageName, original.pExpCtx->copyWith(original.pExpCtx->ns)), + : DocumentSource(kStageName, + original.pExpCtx->copyWith(original.pExpCtx->ns, original.pExpCtx->uuid)), _from(original._from), _as(original._as), _connectFromField(original._connectFromField), @@ -636,7 +637,9 @@ DocumentSourceGraphLookUp::DocumentSourceGraphLookUp(const DocumentSourceGraphLo _additionalFilter(original._additionalFilter), _depthField(original._depthField), _maxDepth(original._maxDepth), - _fromExpCtx(original._fromExpCtx->copyWith(original.pExpCtx->getResolvedNamespace(_from).ns)), + _fromExpCtx( + original._fromExpCtx->copyWith(original.pExpCtx->getResolvedNamespace(_from).ns, + original.pExpCtx->getResolvedNamespace(_from).uuid)), _fromPipeline(original._fromPipeline), _frontier(pExpCtx->getValueComparator().makeUnorderedValueSet()), _visited(ValueComparator::kInstance.makeUnorderedValueMap<Document>()), diff --git a/src/mongo/db/pipeline/document_source_lookup.cpp b/src/mongo/db/pipeline/document_source_lookup.cpp index 61b5173c21a..d44f3fde71a 100644 --- a/src/mongo/db/pipeline/document_source_lookup.cpp +++ b/src/mongo/db/pipeline/document_source_lookup.cpp @@ -163,7 +163,8 @@ DocumentSourceLookUp::DocumentSourceLookUp( const auto& resolvedNamespace = expCtx->getResolvedNamespace(_fromNs); _resolvedNs = resolvedNamespace.ns; _resolvedPipeline = resolvedNamespace.pipeline; - _fromExpCtx = expCtx->copyForSubPipeline(resolvedNamespace.ns); + + _fromExpCtx = expCtx->copyForSubPipeline(resolvedNamespace.ns, resolvedNamespace.uuid); if (fromCollator) { _fromExpCtx->setCollator(std::move(fromCollator.get())); _hasExplicitCollation = true; @@ -254,7 +255,8 @@ DocumentSourceLookUp::DocumentSourceLookUp( } DocumentSourceLookUp::DocumentSourceLookUp(const DocumentSourceLookUp& original) - : DocumentSource(kStageName, original.pExpCtx->copyWith(original.pExpCtx->ns)), + : DocumentSource(kStageName, + original.pExpCtx->copyWith(original.pExpCtx->ns, original.pExpCtx->uuid)), _fromNs(original._fromNs), _resolvedNs(original._resolvedNs), _as(original._as), @@ -264,7 +266,7 @@ DocumentSourceLookUp::DocumentSourceLookUp(const DocumentSourceLookUp& original) _fieldMatchPipelineIdx(original._fieldMatchPipelineIdx), _variables(original._variables), _variablesParseState(original._variablesParseState.copyWith(_variables.useIdGenerator())), - _fromExpCtx(original._fromExpCtx->copyWith(_resolvedNs)), + _fromExpCtx(original._fromExpCtx->copyWith(_resolvedNs, original._fromExpCtx->uuid)), _hasExplicitCollation(original._hasExplicitCollation), _resolvedPipeline(original._resolvedPipeline), _userPipeline(original._userPipeline), @@ -513,7 +515,7 @@ std::unique_ptr<Pipeline, PipelineDeleter> DocumentSourceLookUp::buildPipelineFr // Update the expression context with any new namespaces the resolved pipeline has introduced. LiteParsedPipeline liteParsedPipeline(resolvedNamespace.ns, resolvedNamespace.pipeline); - _fromExpCtx = _fromExpCtx->copyWith(resolvedNamespace.ns); + _fromExpCtx = _fromExpCtx->copyWith(resolvedNamespace.ns, resolvedNamespace.uuid); _fromExpCtx->addResolvedNamespaces(liteParsedPipeline.getInvolvedNamespaces()); return pipeline; diff --git a/src/mongo/db/pipeline/document_source_union_with.cpp b/src/mongo/db/pipeline/document_source_union_with.cpp index 48eb2ed332a..02126f35878 100644 --- a/src/mongo/db/pipeline/document_source_union_with.cpp +++ b/src/mongo/db/pipeline/document_source_union_with.cpp @@ -73,7 +73,7 @@ std::unique_ptr<Pipeline, PipelineDeleter> buildPipelineFromViewDefinition( opts.validator = validatorCallback; return Pipeline::makePipelineFromViewDefinition( - expCtx->copyForSubPipeline(expCtx->ns), resolvedNs, currentPipeline, opts); + expCtx->copyForSubPipeline(expCtx->ns, resolvedNs.uuid), resolvedNs, currentPipeline, opts); } } // namespace diff --git a/src/mongo/db/pipeline/expression_context.cpp b/src/mongo/db/pipeline/expression_context.cpp index cb92a6e9ef9..8e3a06d8a13 100644 --- a/src/mongo/db/pipeline/expression_context.cpp +++ b/src/mongo/db/pipeline/expression_context.cpp @@ -44,8 +44,9 @@ namespace mongo { using boost::intrusive_ptr; ExpressionContext::ResolvedNamespace::ResolvedNamespace(NamespaceString ns, - std::vector<BSONObj> pipeline) - : ns(std::move(ns)), pipeline(std::move(pipeline)) {} + std::vector<BSONObj> pipeline, + boost::optional<UUID> collUUID) + : ns(std::move(ns)), pipeline(std::move(pipeline)), uuid(collUUID) {} ExpressionContext::ExpressionContext(OperationContext* opCtx, const AggregateCommandRequest& request, diff --git a/src/mongo/db/pipeline/expression_context.h b/src/mongo/db/pipeline/expression_context.h index be915aa98f1..f6ba5812e86 100644 --- a/src/mongo/db/pipeline/expression_context.h +++ b/src/mongo/db/pipeline/expression_context.h @@ -72,10 +72,13 @@ class ExpressionContext : public RefCountable { public: struct ResolvedNamespace { ResolvedNamespace() = default; - ResolvedNamespace(NamespaceString ns, std::vector<BSONObj> pipeline); + ResolvedNamespace(NamespaceString ns, + std::vector<BSONObj> pipeline, + boost::optional<UUID> uuid = boost::none); NamespaceString ns; std::vector<BSONObj> pipeline; + boost::optional<UUID> uuid = boost::none; }; /** @@ -260,12 +263,13 @@ public: * Returns an ExpressionContext that is identical to 'this' except for the 'subPipelineDepth' * and 'needsMerge' fields. */ - boost::intrusive_ptr<ExpressionContext> copyForSubPipeline(NamespaceString nss) const { + boost::intrusive_ptr<ExpressionContext> copyForSubPipeline( + NamespaceString nss, boost::optional<UUID> uuid = boost::none) const { uassert(ErrorCodes::MaxSubPipelineDepthExceeded, str::stream() << "Maximum number of nested sub-pipelines exceeded. Limit is " << internalMaxSubPipelineViewDepth.load(), subPipelineDepth < internalMaxSubPipelineViewDepth.load()); - auto newCopy = copyWith(std::move(nss)); + auto newCopy = copyWith(std::move(nss), uuid); newCopy->subPipelineDepth += 1; // The original expCtx might have been attached to an aggregation pipeline running on the // shards. We must reset 'needsMerge' in order to get fully merged results for the |