diff options
author | Bernard Gorman <bernard.gorman@mongodb.com> | 2019-11-14 21:59:35 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-11-14 21:59:35 +0000 |
commit | 23e55cb3d041236f399f7095df31cd3e3da491cc (patch) | |
tree | 25bc309af51bc66dbd46922b0cf7560b3351478a /src/mongo/db/query/internal_plans.cpp | |
parent | cdc44d95e169da75093f25c324aa9670e72743e8 (diff) | |
download | mongo-23e55cb3d041236f399f7095df31cd3e3da491cc.tar.gz |
SERVER-43860 Always upsert exact source document for pipeline-insert $merge
Diffstat (limited to 'src/mongo/db/query/internal_plans.cpp')
-rw-r--r-- | src/mongo/db/query/internal_plans.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mongo/db/query/internal_plans.cpp b/src/mongo/db/query/internal_plans.cpp index 53328901c88..a9bc1b5021a 100644 --- a/src/mongo/db/query/internal_plans.cpp +++ b/src/mongo/db/query/internal_plans.cpp @@ -42,6 +42,7 @@ #include "mongo/db/exec/idhack.h" #include "mongo/db/exec/index_scan.h" #include "mongo/db/exec/update_stage.h" +#include "mongo/db/exec/upsert_stage.h" #include "mongo/db/query/get_executor.h" namespace mongo { @@ -166,8 +167,12 @@ std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> InternalPlanner::updateWith auto ws = std::make_unique<WorkingSet>(); auto idHackStage = std::make_unique<IDHackStage>(opCtx, key, ws.get(), descriptor); - auto root = - std::make_unique<UpdateStage>(opCtx, params, ws.get(), collection, idHackStage.release()); + + const bool isUpsert = params.request->isUpsert(); + auto root = (isUpsert ? std::make_unique<UpsertStage>( + opCtx, params, ws.get(), collection, idHackStage.release()) + : std::make_unique<UpdateStage>( + opCtx, params, ws.get(), collection, idHackStage.release())); auto executor = PlanExecutor::make(opCtx, std::move(ws), std::move(root), collection, yieldPolicy); |