diff options
author | Bernard Gorman <bernard.gorman@mongodb.com> | 2019-12-02 21:55:49 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-12-02 21:55:49 +0000 |
commit | 70ef84cd14388602b3d763b12c6f8448ba62a9d8 (patch) | |
tree | 104b86a7dfe90c4fc21ab246b74e61fb17bbacd2 /src/mongo/db/pipeline/expression_context.cpp | |
parent | cb125fa6284810a767a6e2ec50f940eb1eca7fad (diff) | |
download | mongo-70ef84cd14388602b3d763b12c6f8448ba62a9d8.tar.gz |
SERVER-43860 Upgrade/downgrade mechanism for new $merge upsert behaviour
Diffstat (limited to 'src/mongo/db/pipeline/expression_context.cpp')
-rw-r--r-- | src/mongo/db/pipeline/expression_context.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/mongo/db/pipeline/expression_context.cpp b/src/mongo/db/pipeline/expression_context.cpp index 1ecd751eb69..1a9eb04e4ef 100644 --- a/src/mongo/db/pipeline/expression_context.cpp +++ b/src/mongo/db/pipeline/expression_context.cpp @@ -62,7 +62,12 @@ ExpressionContext::ExpressionContext(OperationContext* opCtx, std::move(collator), std::move(processInterface), std::move(resolvedNamespaces), - std::move(collUUID)) {} + std::move(collUUID)) { + // 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. + // TODO SERVER-44884: Remove this flag after we branch for 4.5. + useNewUpsert = request.getUseNewUpsert() || !request.isFromMongos(); +} ExpressionContext::ExpressionContext( OperationContext* opCtx, @@ -100,6 +105,12 @@ ExpressionContext::ExpressionContext( variables.setRuntimeConstants(*runtimeConstants); else variables.setDefaultRuntimeConstants(opCtx); + + // Any request which did not originate from a mongoS can use the new upsertSupplied mechanism. + // This is used to set 'useNewUpsert' when constructing a MR context on mongoS or mongoD. The MR + // on mongoS will be issued as an aggregation to the shards and will use the other constructor. + // TODO SERVER-44884: Remove this flag after we branch for 4.5. + useNewUpsert = !fromMongos; } ExpressionContext::ExpressionContext(OperationContext* opCtx, @@ -191,6 +202,7 @@ intrusive_ptr<ExpressionContext> ExpressionContext::copyWith( expCtx->maxFeatureCompatibilityVersion = maxFeatureCompatibilityVersion; expCtx->subPipelineDepth = subPipelineDepth; expCtx->tempDir = tempDir; + expCtx->useNewUpsert = useNewUpsert; // ExpressionContext is used both universally in Agg and in Find within a $expr. In the case // that this context is for use in $expr, the collator will be unowned and we will pass nullptr |