diff options
Diffstat (limited to 'src/mongo/db/exec/timeseries_modify.h')
-rw-r--r-- | src/mongo/db/exec/timeseries_modify.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/mongo/db/exec/timeseries_modify.h b/src/mongo/db/exec/timeseries_modify.h index 6bd3ffd8436..268a7884f7a 100644 --- a/src/mongo/db/exec/timeseries_modify.h +++ b/src/mongo/db/exec/timeseries_modify.h @@ -44,6 +44,7 @@ struct TimeseriesModifyParams { isMulti(deleteParams->isMulti), fromMigrate(deleteParams->fromMigrate), isExplain(deleteParams->isExplain), + returnDeleted(deleteParams->returnDeleted), stmtId(deleteParams->stmtId), canonicalQuery(deleteParams->canonicalQuery) {} @@ -74,6 +75,9 @@ struct TimeseriesModifyParams { // Are we explaining a command rather than actually executing it? bool isExplain; + // Should we return the deleted document? + bool returnDeleted = false; + // The stmtId for this particular command. StmtId stmtId = kUninitializedStmtId; @@ -142,8 +146,12 @@ private: /** * Writes the modifications to a bucket. + * + * Returns the pair of (whether the write was successful, the stage state to propagate). */ - PlanStage::StageState _writeToTimeseriesBuckets( + template <typename F> + std::pair<bool, PlanStage::StageState> _writeToTimeseriesBuckets( + ScopeGuard<F>& bucketFreer, WorkingSetID bucketWsmId, const std::vector<BSONObj>& unchangedMeasurements, const std::vector<BSONObj>& modifiedMeasurements, @@ -164,6 +172,11 @@ private: */ PlanStage::StageState _getNextBucket(WorkingSetID& id); + /** + * Prepares returning a deleted measurement. + */ + void _prepareToReturnDeletedMeasurement(WorkingSetID& out, BSONObj measurement); + TimeseriesModifyParams _params; WorkingSet* _ws; @@ -194,5 +207,9 @@ private: // A pending retry to get to after a NEED_YIELD propagation and a new storage snapshot is // established. This can be set when a write fails or when a fetch fails. WorkingSetID _retryBucketId = WorkingSet::INVALID_ID; + + // Stores the deleted document when a deleteOne with returnDeleted: true is requested and we + // need to yield. + boost::optional<BSONObj> _deletedMeasurementToReturn = boost::none; }; } // namespace mongo |