summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_lookup.cpp
diff options
context:
space:
mode:
authorBernard Gorman <bernard.gorman@mongodb.com>2019-10-01 21:17:44 +0000
committerevergreen <evergreen@mongodb.com>2019-10-01 21:17:44 +0000
commitd6133a3a5464fac202f512b0310dfeb200c126f9 (patch)
treed405b43dcdf1d991224e000b856f7d930082b4ad /src/mongo/db/pipeline/document_source_lookup.cpp
parente77b9df00d5a269c8eb4955efef2c21c42819306 (diff)
downloadmongo-d6133a3a5464fac202f512b0310dfeb200c126f9.tar.gz
SERVER-43350 $lookup with no local default or user-specified collation should explicitly set the simple collation on the foreign expression context
Diffstat (limited to 'src/mongo/db/pipeline/document_source_lookup.cpp')
-rw-r--r--src/mongo/db/pipeline/document_source_lookup.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/mongo/db/pipeline/document_source_lookup.cpp b/src/mongo/db/pipeline/document_source_lookup.cpp
index a4b1bf4221a..575d3335ba4 100644
--- a/src/mongo/db/pipeline/document_source_lookup.cpp
+++ b/src/mongo/db/pipeline/document_source_lookup.cpp
@@ -61,7 +61,14 @@ DocumentSourceLookUp::DocumentSourceLookUp(NamespaceString fromNs,
const auto& resolvedNamespace = expCtx->getResolvedNamespace(_fromNs);
_resolvedNs = resolvedNamespace.ns;
_resolvedPipeline = resolvedNamespace.pipeline;
- _fromExpCtx = expCtx->copyWith(_resolvedNs);
+
+ // We always set an explicit collator on the copied expression context, even if the collator is
+ // null (i.e. the simple collation). Otherwise, in the situation where the user did not specify
+ // a collation and the simple collation was inherited from the local collection, the execution
+ // machinery will incorrectly interpret the null collator and empty user collation as an
+ // indication that it should inherit the foreign collection's collation.
+ _fromExpCtx = expCtx->copyWith(
+ _resolvedNs, boost::none, expCtx->getCollator() ? expCtx->getCollator()->clone() : nullptr);
_fromExpCtx->subPipelineDepth += 1;
uassert(ErrorCodes::MaxSubPipelineDepthExceeded,