From 06797deec0c5806e56a70a7d156556e0b028da7f Mon Sep 17 00:00:00 2001 From: Jason Zhang Date: Wed, 17 May 2023 02:23:47 +0000 Subject: SERVER-69922 Implement explain for updateOne, deleteOne, and findAndModify --- src/mongo/s/write_ops/write_without_shard_key_util.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/mongo/s/write_ops/write_without_shard_key_util.h') diff --git a/src/mongo/s/write_ops/write_without_shard_key_util.h b/src/mongo/s/write_ops/write_without_shard_key_util.h index bb7e4d0509b..5fb9bb35d68 100644 --- a/src/mongo/s/write_ops/write_without_shard_key_util.h +++ b/src/mongo/s/write_ops/write_without_shard_key_util.h @@ -38,6 +38,11 @@ namespace mongo { namespace write_without_shard_key { +// Used as a "dummy" target document for constructing explain responses for single writes without +// shard key. +const BSONObj targetDocForExplain = BSON("_id" + << "WriteWithoutShardKey"); + /** * Uses updateDriver to produce the document to insert. Only use when {upsert: true}. */ @@ -75,6 +80,13 @@ bool useTwoPhaseProtocol(OperationContext* opCtx, StatusWith runTwoPhaseWriteProtocol(OperationContext* opCtx, NamespaceString nss, BSONObj cmdObj); +/** + * Return a formatted 'explain' response that describes the work done in the two phase write + * protocol. + **/ +BSONObj generateExplainResponseForTwoPhaseWriteProtocol( + const BSONObj& clusterQueryWithoutShardKeyExplainObj, + const BSONObj& clusterWriteWithoutShardKeyExplainObj); } // namespace write_without_shard_key } // namespace mongo -- cgit v1.2.1