summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/expression_context.cpp
diff options
context:
space:
mode:
authorBernard Gorman <bernard.gorman@mongodb.com>2019-12-03 02:30:08 +0000
committerevergreen <evergreen@mongodb.com>2019-12-03 02:30:08 +0000
commitf4404e7ac489bec9b208bc56b1ebb9078a518216 (patch)
tree14dbe7e109b94b3bf86c28350a694ac02f495ab3 /src/mongo/db/pipeline/expression_context.cpp
parented399a2efa01185d38d57b0bda11e70ff7ca6dc8 (diff)
downloadmongo-r4.2.2-rc0.tar.gz
SERVER-43860 Always upsert exact source document for pipeline-insert $merger4.2.2-rc0
(cherry picked from commit 23e55cb3d041236f399f7095df31cd3e3da491cc) (cherry picked from commit 70ef84cd14388602b3d763b12c6f8448ba62a9d8)
Diffstat (limited to 'src/mongo/db/pipeline/expression_context.cpp')
-rw-r--r--src/mongo/db/pipeline/expression_context.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/expression_context.cpp b/src/mongo/db/pipeline/expression_context.cpp
index 9f65c12669f..781c0cc96c1 100644
--- a/src/mongo/db/pipeline/expression_context.cpp
+++ b/src/mongo/db/pipeline/expression_context.cpp
@@ -67,6 +67,10 @@ ExpressionContext::ExpressionContext(OperationContext* opCtx,
} else {
variables.setDefaultRuntimeConstants(opCtx);
}
+
+ // Any request which did not originate from a mongoS, or which did originate from a mongoS but
+ // has the 'useNewUpsert' flag set, can use the new upsertSupplied mechanism for $merge.
+ useNewUpsert = request.getUseNewUpsert() || !request.isFromMongos();
}
ExpressionContext::ExpressionContext(OperationContext* opCtx,
@@ -164,6 +168,7 @@ intrusive_ptr<ExpressionContext> ExpressionContext::copyWith(
expCtx->subPipelineDepth = subPipelineDepth;
expCtx->tempDir = tempDir;
+ expCtx->useNewUpsert = useNewUpsert;
expCtx->opCtx = opCtx;