diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
| commit | 4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch) | |
| tree | 1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/s/write_ops/batched_command_request.cpp | |
| parent | aa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff) | |
| parent | 8f0827553e09872941945a093b647a4211a9db7f (diff) | |
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0'
with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/mongo/s/write_ops/batched_command_request.cpp')
| -rw-r--r-- | src/mongo/s/write_ops/batched_command_request.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/mongo/s/write_ops/batched_command_request.cpp b/src/mongo/s/write_ops/batched_command_request.cpp index 185857d6acc..107f1a49204 100644 --- a/src/mongo/s/write_ops/batched_command_request.cpp +++ b/src/mongo/s/write_ops/batched_command_request.cpp @@ -38,6 +38,8 @@ namespace mongo { namespace { +const auto kWriteConcern = "writeConcern"_sd; + template <class T> BatchedCommandRequest constructBatchedCommandRequest(const OpMsgRequest& request) { auto batchRequest = BatchedCommandRequest{T::parse(request)}; @@ -51,6 +53,11 @@ BatchedCommandRequest constructBatchedCommandRequest(const OpMsgRequest& request batchRequest.setShardVersion(shardVersion); } + auto writeConcernField = request.body[kWriteConcern]; + if (!writeConcernField.eoo()) { + batchRequest.setWriteConcern(writeConcernField.Obj()); + } + // The 'isTimeseriesNamespace' is an internal parameter used for communication between mongos // and mongod. auto isTimeseriesNamespace = @@ -166,9 +173,19 @@ const boost::optional<BSONObj>& BatchedCommandRequest::getLet() const { return _visit(Visitor{}); }; -const OptionalBool& BatchedCommandRequest::getBypassEmptyTsReplacement() const { - return _visit([](auto&& op) -> decltype(auto) { return op.getBypassEmptyTsReplacement(); }); -}; +bool BatchedCommandRequest::isVerboseWC() const { + if (!hasWriteConcern()) { + return true; + } + + BSONObj writeConcern = getWriteConcern(); + BSONElement wElem = writeConcern["w"]; + if (!wElem.isNumber() || wElem.Number() != 0) { + return true; + } + + return false; +} const write_ops::WriteCommandRequestBase& BatchedCommandRequest::getWriteCommandRequestBase() const { @@ -189,6 +206,10 @@ void BatchedCommandRequest::serialize(BSONObjBuilder* builder) const { if (_dbVersion) { builder->append("databaseVersion", _dbVersion->toBSON()); } + + if (_writeConcern) { + builder->append(kWriteConcern, *_writeConcern); + } } BSONObj BatchedCommandRequest::toBSON() const { |
