summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/client/dbclient_base.cpp4
-rw-r--r--src/mongo/client/dbclient_cursor.cpp12
-rw-r--r--src/mongo/client/dbclient_cursor.h7
-rw-r--r--src/mongo/db/auth/authorization_checks.cpp2
-rw-r--r--src/mongo/db/auth/authorization_checks.h2
-rw-r--r--src/mongo/db/catalog/document_validation.h2
-rw-r--r--src/mongo/db/commands/count_cmd.cpp6
-rw-r--r--src/mongo/db/commands/current_op.cpp4
-rw-r--r--src/mongo/db/commands/current_op_common.cpp6
-rw-r--r--src/mongo/db/commands/current_op_common.h8
-rw-r--r--src/mongo/db/commands/dbcommands_d.cpp2
-rw-r--r--src/mongo/db/commands/explain_cmd.cpp4
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp44
-rw-r--r--src/mongo/db/commands/find_cmd.cpp36
-rw-r--r--src/mongo/db/commands/getmore_cmd.cpp13
-rw-r--r--src/mongo/db/commands/index_filter_commands.cpp2
-rw-r--r--src/mongo/db/commands/index_filter_commands_test.cpp6
-rw-r--r--src/mongo/db/commands/killcursors_common.h4
-rw-r--r--src/mongo/db/commands/map_reduce.idl5
-rw-r--r--src/mongo/db/commands/map_reduce_agg.cpp4
-rw-r--r--src/mongo/db/commands/map_reduce_agg_test.cpp52
-rw-r--r--src/mongo/db/commands/map_reduce_parse_test.cpp340
-rw-r--r--src/mongo/db/commands/mr_common.cpp4
-rw-r--r--src/mongo/db/commands/mr_common.h2
-rw-r--r--src/mongo/db/commands/pipeline_command.cpp6
-rw-r--r--src/mongo/db/commands/plan_cache_clear_command.cpp12
-rw-r--r--src/mongo/db/commands/plan_cache_commands.cpp2
-rw-r--r--src/mongo/db/commands/run_aggregate.cpp26
-rw-r--r--src/mongo/db/commands/run_aggregate.h4
-rw-r--r--src/mongo/db/commands/rwc_defaults_commands.cpp2
-rw-r--r--src/mongo/db/commands/set_feature_compatibility_version_command.cpp2
-rw-r--r--src/mongo/db/commands/update_metrics.cpp2
-rw-r--r--src/mongo/db/commands/update_metrics.h2
-rw-r--r--src/mongo/db/commands/user_management_commands.cpp16
-rw-r--r--src/mongo/db/commands/validate_db_metadata.idl5
-rw-r--r--src/mongo/db/commands/validate_db_metadata_cmd.cpp6
-rw-r--r--src/mongo/db/commands/validate_db_metadata_common.h3
-rw-r--r--src/mongo/db/commands/write_commands.cpp49
-rw-r--r--src/mongo/db/commands/write_commands_common.cpp12
-rw-r--r--src/mongo/db/commands/write_commands_common.h6
-rw-r--r--src/mongo/db/db_raii_test.cpp2
-rw-r--r--src/mongo/db/dbdirectclient.cpp4
-rw-r--r--src/mongo/db/dbdirectclient.h4
-rw-r--r--src/mongo/db/dbhelpers.cpp4
-rw-r--r--src/mongo/db/dbhelpers.h4
-rw-r--r--src/mongo/db/exec/idhack.cpp2
-rw-r--r--src/mongo/db/exec/sbe_cmd.cpp3
-rw-r--r--src/mongo/db/exec/subplan.cpp2
-rw-r--r--src/mongo/db/exec/trial_period_utils.cpp9
-rw-r--r--src/mongo/db/explain.idl2
-rw-r--r--src/mongo/db/explain_test.cpp62
-rw-r--r--src/mongo/db/keys_collection_cache_test.cpp4
-rw-r--r--src/mongo/db/keys_collection_client_direct.cpp2
-rw-r--r--src/mongo/db/matcher/expression_optimize_test.cpp56
-rw-r--r--src/mongo/db/ops/parsed_delete.cpp4
-rw-r--r--src/mongo/db/ops/parsed_update.cpp4
-rw-r--r--src/mongo/db/ops/write_ops.cpp67
-rw-r--r--src/mongo/db/ops/write_ops.h26
-rw-r--r--src/mongo/db/ops/write_ops.idl37
-rw-r--r--src/mongo/db/ops/write_ops_exec.cpp27
-rw-r--r--src/mongo/db/ops/write_ops_exec.h6
-rw-r--r--src/mongo/db/ops/write_ops_parsers_test.cpp56
-rw-r--r--src/mongo/db/ops/write_ops_retryability.cpp12
-rw-r--r--src/mongo/db/ops/write_ops_retryability.h4
-rw-r--r--src/mongo/db/ops/write_ops_retryability_test.cpp32
-rw-r--r--src/mongo/db/persistent_task_store.h6
-rw-r--r--src/mongo/db/pipeline/aggregate_command.idl2
-rw-r--r--src/mongo/db/pipeline/aggregation_request_helper.cpp82
-rw-r--r--src/mongo/db/pipeline/aggregation_request_helper.h45
-rw-r--r--src/mongo/db/pipeline/aggregation_request_test.cpp76
-rw-r--r--src/mongo/db/pipeline/dispatch_shard_pipeline_test.cpp20
-rw-r--r--src/mongo/db/pipeline/document_source.h2
-rw-r--r--src/mongo/db/pipeline/document_source_change_stream.cpp4
-rw-r--r--src/mongo/db/pipeline/document_source_group_test.cpp6
-rw-r--r--src/mongo/db/pipeline/document_source_unwind_test.cpp2
-rw-r--r--src/mongo/db/pipeline/expression_context.cpp2
-rw-r--r--src/mongo/db/pipeline/expression_context.h6
-rw-r--r--src/mongo/db/pipeline/expression_context_for_test.h2
-rw-r--r--src/mongo/db/pipeline/expression_walker_test.cpp2
-rw-r--r--src/mongo/db/pipeline/lite_parsed_pipeline.h2
-rw-r--r--src/mongo/db/pipeline/pipeline_d.cpp23
-rw-r--r--src/mongo/db/pipeline/pipeline_d.h17
-rw-r--r--src/mongo/db/pipeline/pipeline_metadata_tree_test.cpp2
-rw-r--r--src/mongo/db/pipeline/pipeline_test.cpp12
-rw-r--r--src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp19
-rw-r--r--src/mongo/db/pipeline/process_interface/common_mongod_process_interface.h17
-rw-r--r--src/mongo/db/pipeline/sharded_agg_helpers.cpp38
-rw-r--r--src/mongo/db/pipeline/sharded_agg_helpers.h13
-rw-r--r--src/mongo/db/query/README.md12
-rw-r--r--src/mongo/db/query/canonical_query.cpp22
-rw-r--r--src/mongo/db/query/canonical_query.h10
-rw-r--r--src/mongo/db/query/canonical_query_encoder.cpp7
-rw-r--r--src/mongo/db/query/canonical_query_encoder_test.cpp2
-rw-r--r--src/mongo/db/query/canonical_query_test.cpp27
-rw-r--r--src/mongo/db/query/classic_stage_builder.cpp35
-rw-r--r--src/mongo/db/query/classic_stage_builder_test.cpp2
-rw-r--r--src/mongo/db/query/count_command.idl2
-rw-r--r--src/mongo/db/query/count_command_as_aggregation_command.cpp2
-rw-r--r--src/mongo/db/query/count_command_as_aggregation_command.h4
-rw-r--r--src/mongo/db/query/count_command_test.cpp88
-rw-r--r--src/mongo/db/query/count_request.h6
-rw-r--r--src/mongo/db/query/distinct_command.idl2
-rw-r--r--src/mongo/db/query/find.cpp4
-rw-r--r--src/mongo/db/query/find_command.idl2
-rw-r--r--src/mongo/db/query/find_common.cpp2
-rw-r--r--src/mongo/db/query/find_common.h4
-rw-r--r--src/mongo/db/query/get_executor.cpp52
-rw-r--r--src/mongo/db/query/get_executor.h8
-rw-r--r--src/mongo/db/query/get_executor_test.cpp2
-rw-r--r--src/mongo/db/query/getmore_command.idl2
-rw-r--r--src/mongo/db/query/kill_cursors.idl6
-rw-r--r--src/mongo/db/query/killcursors_request_test.cpp22
-rw-r--r--src/mongo/db/query/parsed_distinct.cpp10
-rw-r--r--src/mongo/db/query/plan_cache.cpp6
-rw-r--r--src/mongo/db/query/plan_cache_test.cpp14
-rw-r--r--src/mongo/db/query/plan_executor_impl.cpp3
-rw-r--r--src/mongo/db/query/plan_insert_listener.cpp5
-rw-r--r--src/mongo/db/query/planner_access.cpp12
-rw-r--r--src/mongo/db/query/planner_analysis.cpp12
-rw-r--r--src/mongo/db/query/query_planner.cpp24
-rw-r--r--src/mongo/db/query/query_planner_options_test.cpp6
-rw-r--r--src/mongo/db/query/query_planner_test_fixture.cpp8
-rw-r--r--src/mongo/db/query/query_request_helper.cpp131
-rw-r--r--src/mongo/db/query/query_request_helper.h59
-rw-r--r--src/mongo/db/query/query_request_test.cpp301
-rw-r--r--src/mongo/db/query/query_settings.cpp2
-rw-r--r--src/mongo/db/query/sbe_stage_builder.cpp2
-rw-r--r--src/mongo/db/query/sbe_stage_builder_test_fixture.cpp2
-rw-r--r--src/mongo/db/repl/oplog_buffer_collection.cpp6
-rw-r--r--src/mongo/db/repl/tenant_collection_cloner.cpp6
-rw-r--r--src/mongo/db/repl/tenant_migration_donor_service.cpp2
-rw-r--r--src/mongo/db/repl/tenant_migration_recipient_service.cpp12
-rw-r--r--src/mongo/db/repl/tenant_migration_recipient_service.h2
-rw-r--r--src/mongo/db/rs_local_client.cpp2
-rw-r--r--src/mongo/db/rs_local_client.h2
-rw-r--r--src/mongo/db/s/add_shard_util.cpp2
-rw-r--r--src/mongo/db/s/config/config_server_test_fixture.cpp54
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager.cpp10
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp4
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp2
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp2
-rw-r--r--src/mongo/db/s/create_collection_coordinator.cpp10
-rw-r--r--src/mongo/db/s/dist_lock_catalog_replset.cpp8
-rw-r--r--src/mongo/db/s/migration_destination_manager.cpp4
-rw-r--r--src/mongo/db/s/migration_util.cpp6
-rw-r--r--src/mongo/db/s/resharding/resharding_collection_cloner.cpp2
-rw-r--r--src/mongo/db/s/resharding/resharding_data_copy_util.cpp2
-rw-r--r--src/mongo/db/s/resharding/resharding_oplog_fetcher.cpp7
-rw-r--r--src/mongo/db/s/resharding/resharding_oplog_fetcher.h2
-rw-r--r--src/mongo/db/s/resharding/resharding_txn_cloner.cpp4
-rw-r--r--src/mongo/db/s/resharding_collection_test.cpp2
-rw-r--r--src/mongo/db/s/session_catalog_migration_destination_test.cpp6
-rw-r--r--src/mongo/db/s/shard_local.cpp2
-rw-r--r--src/mongo/db/s/shard_local.h2
-rw-r--r--src/mongo/db/s/shard_local_test.cpp2
-rw-r--r--src/mongo/db/s/shard_metadata_util.cpp35
-rw-r--r--src/mongo/db/s/sharding_ddl_util.cpp9
-rw-r--r--src/mongo/db/s/transaction_coordinator_util.cpp9
-rw-r--r--src/mongo/db/session_catalog_mongod.cpp6
-rw-r--r--src/mongo/db/transaction_history_iterator.cpp2
-rw-r--r--src/mongo/db/ttl.cpp2
-rw-r--r--src/mongo/db/update/update_driver.cpp2
-rw-r--r--src/mongo/db/views/resolved_view.cpp5
-rw-r--r--src/mongo/db/views/resolved_view.h3
-rw-r--r--src/mongo/db/views/resolved_view_test.cpp22
-rw-r--r--src/mongo/db/views/view_catalog.cpp2
-rw-r--r--src/mongo/dbtests/documentsourcetests.cpp12
-rw-r--r--src/mongo/dbtests/plan_executor_invalidation_test.cpp2
-rw-r--r--src/mongo/dbtests/plan_ranking.cpp28
-rw-r--r--src/mongo/dbtests/query_plan_executor.cpp4
-rw-r--r--src/mongo/dbtests/query_stage_cached_plan.cpp10
-rw-r--r--src/mongo/dbtests/query_stage_count.cpp18
-rw-r--r--src/mongo/dbtests/query_stage_delete.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_multiplan.cpp14
-rw-r--r--src/mongo/dbtests/query_stage_subplan.cpp18
-rw-r--r--src/mongo/dbtests/query_stage_update.cpp2
-rw-r--r--src/mongo/executor/task_executor_cursor.cpp3
-rw-r--r--src/mongo/s/catalog/sharding_catalog_client_impl.cpp16
-rw-r--r--src/mongo/s/chunk_manager.cpp2
-rw-r--r--src/mongo/s/chunk_manager_index_bounds_test.cpp2
-rw-r--r--src/mongo/s/chunk_manager_targeter.cpp6
-rw-r--r--src/mongo/s/chunk_manager_targeter_test.cpp4
-rw-r--r--src/mongo/s/client/shard.h2
-rw-r--r--src/mongo/s/client/shard_remote.cpp4
-rw-r--r--src/mongo/s/client/shard_remote.h2
-rw-r--r--src/mongo/s/commands/cluster_count_cmd.cpp8
-rw-r--r--src/mongo/s/commands/cluster_current_op.cpp4
-rw-r--r--src/mongo/s/commands/cluster_explain_cmd.cpp4
-rw-r--r--src/mongo/s/commands/cluster_find_cmd.cpp19
-rw-r--r--src/mongo/s/commands/cluster_getmore_cmd.cpp5
-rw-r--r--src/mongo/s/commands/cluster_map_reduce_agg.cpp26
-rw-r--r--src/mongo/s/commands/cluster_pipeline_cmd.cpp6
-rw-r--r--src/mongo/s/commands/cluster_validate_db_metadata_cmd.cpp10
-rw-r--r--src/mongo/s/commands/cluster_write_cmd.cpp8
-rw-r--r--src/mongo/s/commands/document_shard_key_update_util.cpp12
-rw-r--r--src/mongo/s/commands/strategy.cpp6
-rw-r--r--src/mongo/s/commands/strategy.h4
-rw-r--r--src/mongo/s/query/async_results_merger.cpp2
-rw-r--r--src/mongo/s/query/async_results_merger_test.cpp8
-rw-r--r--src/mongo/s/query/cluster_aggregate.cpp19
-rw-r--r--src/mongo/s/query/cluster_aggregate.h6
-rw-r--r--src/mongo/s/query/cluster_aggregation_planner.cpp4
-rw-r--r--src/mongo/s/query/cluster_find.cpp30
-rw-r--r--src/mongo/s/query/cluster_find.h2
-rw-r--r--src/mongo/s/query/establish_cursors.cpp4
-rw-r--r--src/mongo/s/shard_key_pattern.cpp4
-rw-r--r--src/mongo/s/write_ops/batch_write_exec_test.cpp186
-rw-r--r--src/mongo/s/write_ops/batch_write_op.cpp31
-rw-r--r--src/mongo/s/write_ops/batch_write_op_test.cpp112
-rw-r--r--src/mongo/s/write_ops/batched_command_request.cpp58
-rw-r--r--src/mongo/s/write_ops/batched_command_request.h22
-rw-r--r--src/mongo/s/write_ops/batched_command_request_test.cpp10
-rw-r--r--src/mongo/s/write_ops/write_op_test.cpp20
-rw-r--r--src/mongo/shell/bench.cpp14
214 files changed, 1821 insertions, 1719 deletions
diff --git a/src/mongo/client/dbclient_base.cpp b/src/mongo/client/dbclient_base.cpp
index 96f057e118b..c085d260d53 100644
--- a/src/mongo/client/dbclient_base.cpp
+++ b/src/mongo/client/dbclient_base.cpp
@@ -963,8 +963,8 @@ void DBClientBase::update(const string& ns,
}
void DBClientBase::killCursor(const NamespaceString& ns, long long cursorId) {
- runFireAndForgetCommand(
- OpMsgRequest::fromDBAndBody(ns.db(), KillCursorsRequest(ns, {cursorId}).toBSON(BSONObj{})));
+ runFireAndForgetCommand(OpMsgRequest::fromDBAndBody(
+ ns.db(), KillCursorsCommandRequest(ns, {cursorId}).toBSON(BSONObj{})));
}
namespace {
diff --git a/src/mongo/client/dbclient_cursor.cpp b/src/mongo/client/dbclient_cursor.cpp
index b6b10ff5781..88bbb6ce478 100644
--- a/src/mongo/client/dbclient_cursor.cpp
+++ b/src/mongo/client/dbclient_cursor.cpp
@@ -136,16 +136,16 @@ Message DBClientCursor::_assembleInit() {
// Legacy queries don't handle readOnce.
findCommand.getValue()->setReadOnce(true);
}
- if (query.getBoolField(FindCommand::kRequestResumeTokenFieldName)) {
+ if (query.getBoolField(FindCommandRequest::kRequestResumeTokenFieldName)) {
// Legacy queries don't handle requestResumeToken.
findCommand.getValue()->setRequestResumeToken(true);
}
- if (query.hasField(FindCommand::kResumeAfterFieldName)) {
+ if (query.hasField(FindCommandRequest::kResumeAfterFieldName)) {
// Legacy queries don't handle resumeAfter.
findCommand.getValue()->setResumeAfter(
- query.getObjectField(FindCommand::kResumeAfterFieldName));
+ query.getObjectField(FindCommandRequest::kResumeAfterFieldName));
}
- if (auto replTerm = query[FindCommand::kTermFieldName]) {
+ if (auto replTerm = query[FindCommandRequest::kTermFieldName]) {
// Legacy queries don't handle term.
findCommand.getValue()->setTerm(replTerm.numberLong());
}
@@ -159,7 +159,7 @@ Message DBClientCursor::_assembleInit() {
BSONObj cmd = findCommand.getValue()->toBSON(BSONObj());
if (auto readPref = query["$readPreference"]) {
- // FindCommand doesn't handle $readPreference.
+ // FindCommandRequest doesn't handle $readPreference.
cmd = BSONObjBuilder(std::move(cmd)).append(readPref).obj();
}
return assembleCommandRequest(_client, ns.db(), opts, std::move(cmd));
@@ -599,7 +599,7 @@ DBClientCursor::DBClientCursor(DBClientBase* client,
/* static */
StatusWith<std::unique_ptr<DBClientCursor>> DBClientCursor::fromAggregationRequest(
- DBClientBase* client, AggregateCommand aggRequest, bool secondaryOk, bool useExhaust) {
+ DBClientBase* client, AggregateCommandRequest aggRequest, bool secondaryOk, bool useExhaust) {
BSONObj ret;
try {
if (!client->runCommand(aggRequest.getNamespace().db().toString(),
diff --git a/src/mongo/client/dbclient_cursor.h b/src/mongo/client/dbclient_cursor.h
index b40474bbd6f..ff79874fb6e 100644
--- a/src/mongo/client/dbclient_cursor.h
+++ b/src/mongo/client/dbclient_cursor.h
@@ -41,7 +41,7 @@ namespace mongo {
class AScopedConnection;
class DBClientBase;
-class AggregateCommand;
+class AggregateCommandRequest;
/** Queries return a cursor object */
class DBClientCursor {
@@ -164,7 +164,10 @@ public:
std::vector<BSONObj> initialBatch = {});
static StatusWith<std::unique_ptr<DBClientCursor>> fromAggregationRequest(
- DBClientBase* client, AggregateCommand aggRequest, bool secondaryOk, bool useExhaust);
+ DBClientBase* client,
+ AggregateCommandRequest aggRequest,
+ bool secondaryOk,
+ bool useExhaust);
virtual ~DBClientCursor();
diff --git a/src/mongo/db/auth/authorization_checks.cpp b/src/mongo/db/auth/authorization_checks.cpp
index 0b8c9b43857..6beb7def53a 100644
--- a/src/mongo/db/auth/authorization_checks.cpp
+++ b/src/mongo/db/auth/authorization_checks.cpp
@@ -272,7 +272,7 @@ Status checkAuthForCollMod(AuthorizationSession* authSession,
StatusWith<PrivilegeVector> getPrivilegesForAggregate(AuthorizationSession* authSession,
const NamespaceString& nss,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
bool isMongos) {
if (!nss.isValid()) {
return Status(ErrorCodes::InvalidNamespace,
diff --git a/src/mongo/db/auth/authorization_checks.h b/src/mongo/db/auth/authorization_checks.h
index 8815d0630c2..326722c6a5b 100644
--- a/src/mongo/db/auth/authorization_checks.h
+++ b/src/mongo/db/auth/authorization_checks.h
@@ -85,7 +85,7 @@ Status checkAuthForKillCursors(AuthorizationSession* authSession,
// 'request' on the namespace 'ns' either directly on mongoD or via mongoS.
StatusWith<PrivilegeVector> getPrivilegesForAggregate(AuthorizationSession* authSession,
const NamespaceString& ns,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
bool isMongos);
// Checks if this connection has the privileges necessary to create 'ns' with the options
diff --git a/src/mongo/db/catalog/document_validation.h b/src/mongo/db/catalog/document_validation.h
index f236deccd56..875f255c565 100644
--- a/src/mongo/db/catalog/document_validation.h
+++ b/src/mongo/db/catalog/document_validation.h
@@ -57,7 +57,7 @@ public:
kEnableValidation = 0x00,
/*
* Disables the schema validation during document inserts and updates.
- * This flag should be enabled if WriteCommandBase::_bypassDocumentValidation
+ * This flag should be enabled if WriteCommandRequestBase::_bypassDocumentValidation
* is set to true.
*/
kDisableSchemaValidation = 0x01,
diff --git a/src/mongo/db/commands/count_cmd.cpp b/src/mongo/db/commands/count_cmd.cpp
index 1347c0af83c..c53ffb44608 100644
--- a/src/mongo/db/commands/count_cmd.cpp
+++ b/src/mongo/db/commands/count_cmd.cpp
@@ -146,9 +146,9 @@ public:
AutoGetCollectionViewMode::kViewsPermitted);
const auto nss = ctx->getNss();
- CountCommand request(NamespaceStringOrUUID(NamespaceString{}));
+ CountCommandRequest request(NamespaceStringOrUUID(NamespaceString{}));
try {
- request = CountCommand::parse(IDLParserErrorContext("count"), opMsgRequest);
+ request = CountCommandRequest::parse(IDLParserErrorContext("count"), opMsgRequest);
} catch (...) {
return exceptionToStatus();
}
@@ -225,7 +225,7 @@ public:
CurOpFailpointHelpers::waitWhileFailPointEnabled(
&hangBeforeCollectionCount, opCtx, "hangBeforeCollectionCount", []() {}, nss);
- auto request = CountCommand::parse(IDLParserErrorContext("count"), cmdObj);
+ auto request = CountCommandRequest::parse(IDLParserErrorContext("count"), cmdObj);
// Check whether we are allowed to read from this node after acquiring our locks.
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
diff --git a/src/mongo/db/commands/current_op.cpp b/src/mongo/db/commands/current_op.cpp
index 6c6e542bdfc..1fd9200f9da 100644
--- a/src/mongo/db/commands/current_op.cpp
+++ b/src/mongo/db/commands/current_op.cpp
@@ -66,8 +66,8 @@ public:
return Status(ErrorCodes::Unauthorized, "Unauthorized");
}
- virtual StatusWith<CursorResponse> runAggregation(OperationContext* opCtx,
- const AggregateCommand& request) const final {
+ virtual StatusWith<CursorResponse> runAggregation(
+ OperationContext* opCtx, const AggregateCommandRequest& request) const final {
auto aggCmdObj = aggregation_request_helper::serializeToCommandObj(request);
rpc::OpMsgReplyBuilder replyBuilder;
diff --git a/src/mongo/db/commands/current_op_common.cpp b/src/mongo/db/commands/current_op_common.cpp
index ccec9928924..d44d5c066d2 100644
--- a/src/mongo/db/commands/current_op_common.cpp
+++ b/src/mongo/db/commands/current_op_common.cpp
@@ -109,9 +109,9 @@ bool CurrentOpCommandBase::run(OperationContext* opCtx,
pipeline.push_back(groupBuilder.obj());
- // Pipeline is complete; create an AggregateCommand for $currentOp.
- const AggregateCommand request(NamespaceString::makeCollectionlessAggregateNSS("admin"),
- std::move(pipeline));
+ // Pipeline is complete; create an AggregateCommandRequest for $currentOp.
+ const AggregateCommandRequest request(NamespaceString::makeCollectionlessAggregateNSS("admin"),
+ std::move(pipeline));
// Run the pipeline and obtain a CursorResponse.
auto aggResults = uassertStatusOK(runAggregation(opCtx, request));
diff --git a/src/mongo/db/commands/current_op_common.h b/src/mongo/db/commands/current_op_common.h
index 8331f44d990..31ff95ac764 100644
--- a/src/mongo/db/commands/current_op_common.h
+++ b/src/mongo/db/commands/current_op_common.h
@@ -70,11 +70,11 @@ private:
virtual void modifyPipeline(std::vector<BSONObj>* pipeline) const {};
/**
- * Runs the aggregation specified by the supplied AggregateCommand, returning a CursorResponse
- * if successful or a Status containing the error otherwise.
+ * Runs the aggregation specified by the supplied AggregateCommandRequest, returning a
+ * CursorResponse if successful or a Status containing the error otherwise.
*/
- virtual StatusWith<CursorResponse> runAggregation(OperationContext* opCtx,
- const AggregateCommand& request) const = 0;
+ virtual StatusWith<CursorResponse> runAggregation(
+ OperationContext* opCtx, const AggregateCommandRequest& request) const = 0;
/**
* Allows overriders to optionally write additional data to the response object before the final
diff --git a/src/mongo/db/commands/dbcommands_d.cpp b/src/mongo/db/commands/dbcommands_d.cpp
index 6b71f0cc36f..4184a0af2ce 100644
--- a/src/mongo/db/commands/dbcommands_d.cpp
+++ b/src/mongo/db/commands/dbcommands_d.cpp
@@ -282,7 +282,7 @@ public:
BSONObj sort = BSON("files_id" << 1 << "n" << 1);
return writeConflictRetry(opCtx, "filemd5", dbname, [&] {
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(query.getOwned());
findCommand->setSort(sort.getOwned());
diff --git a/src/mongo/db/commands/explain_cmd.cpp b/src/mongo/db/commands/explain_cmd.cpp
index 8f754f6e1d4..318029aef75 100644
--- a/src/mongo/db/commands/explain_cmd.cpp
+++ b/src/mongo/db/commands/explain_cmd.cpp
@@ -154,8 +154,8 @@ std::unique_ptr<CommandInvocation> CmdExplain::parse(OperationContext* opCtx,
CommandHelpers::uassertNoDocumentSequences(getName(), request);
// To enforce API versioning
- auto cmdObj = ExplainCmd::parse(
- IDLParserErrorContext(ExplainCmd::kCommandName,
+ auto cmdObj = ExplainCommandRequest::parse(
+ IDLParserErrorContext(ExplainCommandRequest::kCommandName,
APIParameters::get(opCtx).getAPIStrict().value_or(false)),
request.body);
std::string dbname = cmdObj.getDbName().toString();
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index 1c5da6a7c98..95968d013b4 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -87,7 +87,7 @@ MONGO_FAIL_POINT_DEFINE(hangBeforeFindAndModifyPerformsUpdate);
* boost::none if no matching document to update/remove was found. If the operation failed, throws.
*/
boost::optional<BSONObj> advanceExecutor(OperationContext* opCtx,
- const write_ops::FindAndModifyCommand& request,
+ const write_ops::FindAndModifyCommandRequest& request,
PlanExecutor* exec,
bool isRemove) {
BSONObj value;
@@ -117,7 +117,7 @@ boost::optional<BSONObj> advanceExecutor(OperationContext* opCtx,
return boost::none;
}
-void validate(const write_ops::FindAndModifyCommand& request) {
+void validate(const write_ops::FindAndModifyCommandRequest& request) {
uassert(ErrorCodes::FailedToParse,
"Either an update or remove=true must be specified",
request.getRemove().value_or(false) || request.getUpdate());
@@ -148,7 +148,7 @@ void validate(const write_ops::FindAndModifyCommand& request) {
}
void makeUpdateRequest(OperationContext* opCtx,
- const write_ops::FindAndModifyCommand& request,
+ const write_ops::FindAndModifyCommandRequest& request,
boost::optional<ExplainOptions::Verbosity> explain,
UpdateRequest* requestOut) {
requestOut->setQuery(request.getQuery());
@@ -174,7 +174,7 @@ void makeUpdateRequest(OperationContext* opCtx,
}
void makeDeleteRequest(OperationContext* opCtx,
- const write_ops::FindAndModifyCommand& request,
+ const write_ops::FindAndModifyCommandRequest& request,
bool explain,
DeleteRequest* requestOut) {
requestOut->setQuery(request.getQuery());
@@ -194,9 +194,9 @@ void makeDeleteRequest(OperationContext* opCtx,
: PlanYieldPolicy::YieldPolicy::YIELD_AUTO);
}
-write_ops::FindAndModifyReply buildResponse(const PlanExecutor* exec,
- bool isRemove,
- const boost::optional<BSONObj>& value) {
+write_ops::FindAndModifyCommandReply buildResponse(const PlanExecutor* exec,
+ bool isRemove,
+ const boost::optional<BSONObj>& value) {
write_ops::FindAndModifyLastError lastError;
if (isRemove) {
lastError.setNumDocs(value ? 1 : 0);
@@ -212,7 +212,7 @@ write_ops::FindAndModifyReply buildResponse(const PlanExecutor* exec,
}
}
- write_ops::FindAndModifyReply result;
+ write_ops::FindAndModifyCommandReply result;
result.setLastErrorObject(std::move(lastError));
result.setValue(value);
return result;
@@ -304,19 +304,19 @@ public:
void appendMirrorableRequest(BSONObjBuilder* bob) const final;
private:
- static write_ops::FindAndModifyReply writeConflictRetryRemove(
+ static write_ops::FindAndModifyCommandReply writeConflictRetryRemove(
OperationContext* opCtx,
const NamespaceString& nsString,
- const write_ops::FindAndModifyCommand& request,
+ const write_ops::FindAndModifyCommandRequest& request,
int stmtId,
CurOp* curOp,
OpDebug* opDebug,
bool inTransaction);
- static write_ops::FindAndModifyReply writeConflictRetryUpsert(
+ static write_ops::FindAndModifyCommandReply writeConflictRetryUpsert(
OperationContext* opCtx,
const NamespaceString& nsString,
- const write_ops::FindAndModifyCommand& request,
+ const write_ops::FindAndModifyCommandRequest& request,
CurOp* curOp,
OpDebug* opDebug,
bool inTransaction,
@@ -330,10 +330,10 @@ private:
UpdateMetrics CmdFindAndModify::_updateMetrics{"findAndModify"};
-write_ops::FindAndModifyReply CmdFindAndModify::Invocation::writeConflictRetryRemove(
+write_ops::FindAndModifyCommandReply CmdFindAndModify::Invocation::writeConflictRetryRemove(
OperationContext* opCtx,
const NamespaceString& nsString,
- const write_ops::FindAndModifyCommand& request,
+ const write_ops::FindAndModifyCommandRequest& request,
int stmtId,
CurOp* curOp,
OpDebug* const opDebug,
@@ -406,10 +406,10 @@ write_ops::FindAndModifyReply CmdFindAndModify::Invocation::writeConflictRetryRe
return buildResponse(exec.get(), request.getRemove().value_or(false), docFound);
}
-write_ops::FindAndModifyReply CmdFindAndModify::Invocation::writeConflictRetryUpsert(
+write_ops::FindAndModifyCommandReply CmdFindAndModify::Invocation::writeConflictRetryUpsert(
OperationContext* opCtx,
const NamespaceString& nsString,
- const write_ops::FindAndModifyCommand& request,
+ const write_ops::FindAndModifyCommandRequest& request,
CurOp* curOp,
OpDebug* opDebug,
bool inTransaction,
@@ -597,7 +597,8 @@ void CmdFindAndModify::Invocation::explain(OperationContext* opCtx,
}
}
-write_ops::FindAndModifyReply CmdFindAndModify::Invocation::typedRun(OperationContext* opCtx) {
+write_ops::FindAndModifyCommandReply CmdFindAndModify::Invocation::typedRun(
+ OperationContext* opCtx) {
const auto& req = request();
validate(req);
@@ -708,16 +709,17 @@ write_ops::FindAndModifyReply CmdFindAndModify::Invocation::typedRun(OperationCo
void CmdFindAndModify::Invocation::appendMirrorableRequest(BSONObjBuilder* bob) const {
const auto& req = request();
- bob->append(FindCommand::kCommandName, req.getNamespace().coll());
+ bob->append(FindCommandRequest::kCommandName, req.getNamespace().coll());
if (!req.getQuery().isEmpty()) {
- bob->append(FindCommand::kFilterFieldName, req.getQuery());
+ bob->append(FindCommandRequest::kFilterFieldName, req.getQuery());
}
if (req.getSort()) {
- bob->append(write_ops::FindAndModifyCommand::kSortFieldName, *req.getSort());
+ bob->append(write_ops::FindAndModifyCommandRequest::kSortFieldName, *req.getSort());
}
if (req.getCollation()) {
- bob->append(write_ops::FindAndModifyCommand::kCollationFieldName, *req.getCollation());
+ bob->append(write_ops::FindAndModifyCommandRequest::kCollationFieldName,
+ *req.getCollation());
}
// Prevent the find from returning multiple documents since we can
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp
index f9b858d0b49..669f133fab5 100644
--- a/src/mongo/db/commands/find_cmd.cpp
+++ b/src/mongo/db/commands/find_cmd.cpp
@@ -65,11 +65,11 @@ namespace {
const auto kTermField = "term"_sd;
-// Parses the command object to a FindCommand. If the client request did not specify any runtime
-// constants, make them available to the query here.
-std::unique_ptr<FindCommand> parseCmdObjectToFindCommand(OperationContext* opCtx,
- NamespaceString nss,
- BSONObj cmdObj) {
+// Parses the command object to a FindCommandRequest. If the client request did not specify any
+// runtime constants, make them available to the query here.
+std::unique_ptr<FindCommandRequest> parseCmdObjectToFindCommandRequest(OperationContext* opCtx,
+ NamespaceString nss,
+ BSONObj cmdObj) {
auto findCommand = query_request_helper::makeFromFindCommand(
std::move(cmdObj),
std::move(nss),
@@ -82,7 +82,7 @@ std::unique_ptr<FindCommand> parseCmdObjectToFindCommand(OperationContext* opCtx
boost::intrusive_ptr<ExpressionContext> makeExpressionContext(
OperationContext* opCtx,
- const FindCommand& findCommand,
+ const FindCommandRequest& findCommand,
boost::optional<ExplainOptions::Verbosity> verbosity) {
std::unique_ptr<CollatorInterface> collator;
if (!findCommand.getCollation().isEmpty()) {
@@ -248,10 +248,10 @@ public:
AutoGetCollectionViewMode::kViewsPermitted);
const auto nss = ctx->getNss();
- // Parse the command BSON to a FindCommand.
- auto findCommand = parseCmdObjectToFindCommand(opCtx, nss, _request.body);
+ // Parse the command BSON to a FindCommandRequest.
+ auto findCommand = parseCmdObjectToFindCommandRequest(opCtx, nss, _request.body);
- // Finish the parsing step by using the FindCommand to create a CanonicalQuery.
+ // Finish the parsing step by using the FindCommandRequest to create a CanonicalQuery.
const ExtensionsCallbackReal extensionsCallback(opCtx, &nss);
auto expCtx = makeExpressionContext(opCtx, *findCommand, verbosity);
const bool isExplain = true;
@@ -269,7 +269,7 @@ public:
// Convert the find command into an aggregation using $match (and other stages, as
// necessary), if possible.
- const auto& findCommand = cq->getFindCommand();
+ const auto& findCommand = cq->getFindCommandRequest();
auto viewAggregationCommand =
uassertStatusOK(query_request_helper::asAggregationCommand(findCommand));
@@ -329,12 +329,13 @@ public:
const BSONObj& cmdObj = _request.body;
- // Parse the command BSON to a FindCommand. Pass in the parsedNss in case cmdObj does
- // not have a UUID.
+ // Parse the command BSON to a FindCommandRequest. Pass in the parsedNss in case cmdObj
+ // does not have a UUID.
auto parsedNss = NamespaceString{CommandHelpers::parseNsFromCommand(_dbName, cmdObj)};
const bool isExplain = false;
const bool isOplogNss = (parsedNss == NamespaceString::kRsOplogNamespace);
- auto findCommand = parseCmdObjectToFindCommand(opCtx, std::move(parsedNss), cmdObj);
+ auto findCommand =
+ parseCmdObjectToFindCommandRequest(opCtx, std::move(parsedNss), cmdObj);
// Only allow speculative majority for internal commands that specify the correct flag.
uassert(ErrorCodes::ReadConcernMajorityNotEnabled,
@@ -402,7 +403,7 @@ public:
const int ntoskip = -1;
beginQueryOp(opCtx, nss, _request.body, ntoreturn, ntoskip);
- // Finish the parsing step by using the FindCommand to create a CanonicalQuery.
+ // Finish the parsing step by using the FindCommandRequest to create a CanonicalQuery.
const ExtensionsCallbackReal extensionsCallback(opCtx, &nss);
auto expCtx = makeExpressionContext(opCtx, *findCommand, boost::none /* verbosity */);
auto cq = uassertStatusOK(
@@ -419,7 +420,7 @@ public:
// Convert the find command into an aggregation using $match (and other stages, as
// necessary), if possible.
- const auto& findCommand = cq->getFindCommand();
+ const auto& findCommand = cq->getFindCommandRequest();
auto viewAggregationCommand =
uassertStatusOK(query_request_helper::asAggregationCommand(findCommand));
@@ -437,7 +438,7 @@ public:
const auto& collection = ctx->getCollection();
- if (cq->getFindCommand().getReadOnce()) {
+ if (cq->getFindCommandRequest().getReadOnce()) {
// The readOnce option causes any storage-layer cursors created during plan
// execution to assume read data will not be needed again and need not be cached.
opCtx->recoveryUnit()->setReadOnce(true);
@@ -466,7 +467,8 @@ public:
FindCommon::waitInFindBeforeMakingBatch(opCtx, *exec->getCanonicalQuery());
- const FindCommand& originalFC = exec->getCanonicalQuery()->getFindCommand();
+ const FindCommandRequest& originalFC =
+ exec->getCanonicalQuery()->getFindCommandRequest();
// Stream query results, adding them to a BSONArray as we go.
CursorResponseBuilder::Options options;
diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp
index e5a68078df4..15f42dfe249 100644
--- a/src/mongo/db/commands/getmore_cmd.cpp
+++ b/src/mongo/db/commands/getmore_cmd.cpp
@@ -188,7 +188,7 @@ void applyCursorReadConcern(OperationContext* opCtx, repl::ReadConcernArgs rcArg
*/
void setUpOperationDeadline(OperationContext* opCtx,
const ClientCursor& cursor,
- const GetMoreCommand& cmd,
+ const GetMoreCommandRequest& cmd,
bool disableAwaitDataFailpointActive) {
// We assume that cursors created through a DBDirectClient are always used from their
@@ -214,7 +214,7 @@ void setUpOperationDeadline(OperationContext* opCtx,
*/
void setUpOperationContextStateForGetMore(OperationContext* opCtx,
const ClientCursor& cursor,
- const GetMoreCommand& cmd,
+ const GetMoreCommandRequest& cmd,
bool disableAwaitDataFailpointActive) {
applyCursorReadConcern(opCtx, cursor.getReadConcernArgs());
opCtx->setWriteConcern(cursor.getWriteConcernOptions());
@@ -254,7 +254,8 @@ public:
class Invocation final : public CommandInvocation {
public:
Invocation(Command* cmd, const OpMsgRequest& request)
- : CommandInvocation(cmd), _cmd(GetMoreCommand::parse({"getMore"}, request.body)) {
+ : CommandInvocation(cmd),
+ _cmd(GetMoreCommandRequest::parse({"getMore"}, request.body)) {
NamespaceString nss(_cmd.getDbName(), _cmd.getCollection());
uassert(ErrorCodes::InvalidNamespace,
str::stream() << "Invalid namespace for getMore: " << nss.ns(),
@@ -303,7 +304,7 @@ public:
*/
bool generateBatch(OperationContext* opCtx,
ClientCursor* cursor,
- const GetMoreCommand& cmd,
+ const GetMoreCommandRequest& cmd,
const bool isTailable,
CursorResponseBuilder* nextBatch,
std::uint64_t* numResults,
@@ -520,7 +521,7 @@ public:
PlanExecutor* exec = cursorPin->getExecutor();
const auto* cq = exec->getCanonicalQuery();
- if (cq && cq->getFindCommand().getReadOnce()) {
+ if (cq && cq->getFindCommandRequest().getReadOnce()) {
// The readOnce option causes any storage-layer cursors created during plan
// execution to assume read data will not be needed again and need not be cached.
opCtx->recoveryUnit()->setReadOnce(true);
@@ -754,7 +755,7 @@ public:
CursorGetMoreReply::parse({"CursorGetMoreReply"}, ret.removeField("ok"));
}
- const GetMoreCommand _cmd;
+ const GetMoreCommandRequest _cmd;
};
bool maintenanceOk() const override {
diff --git a/src/mongo/db/commands/index_filter_commands.cpp b/src/mongo/db/commands/index_filter_commands.cpp
index 286b3595056..bc2498acd60 100644
--- a/src/mongo/db/commands/index_filter_commands.cpp
+++ b/src/mongo/db/commands/index_filter_commands.cpp
@@ -303,7 +303,7 @@ Status ClearFilters::clear(OperationContext* opCtx,
AllowedIndexEntry entry = *i;
// Create canonical query.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(entry.query);
findCommand->setSort(entry.sort);
findCommand->setProjection(entry.projection);
diff --git a/src/mongo/db/commands/index_filter_commands_test.cpp b/src/mongo/db/commands/index_filter_commands_test.cpp
index 760ccfbf9d2..1293a0d0db3 100644
--- a/src/mongo/db/commands/index_filter_commands_test.cpp
+++ b/src/mongo/db/commands/index_filter_commands_test.cpp
@@ -130,7 +130,7 @@ void addQueryShapeToPlanCache(OperationContext* opCtx,
const char* projectionStr,
const char* collationStr) {
// Create canonical query.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(fromjson(queryStr));
findCommand->setSort(fromjson(sortStr));
findCommand->setProjection(fromjson(projectionStr));
@@ -161,7 +161,7 @@ bool planCacheContains(OperationContext* opCtx,
const char* collationStr) {
// Create canonical query.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(fromjson(queryStr));
findCommand->setSort(fromjson(sortStr));
findCommand->setProjection(fromjson(projectionStr));
@@ -181,7 +181,7 @@ bool planCacheContains(OperationContext* opCtx,
// Canonicalize the query shape stored in the cache entry in order to get the plan cache
// key.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(createdFromQuery.filter);
findCommand->setSort(createdFromQuery.sort);
findCommand->setProjection(createdFromQuery.projection);
diff --git a/src/mongo/db/commands/killcursors_common.h b/src/mongo/db/commands/killcursors_common.h
index 900038fad59..4d906b66777 100644
--- a/src/mongo/db/commands/killcursors_common.h
+++ b/src/mongo/db/commands/killcursors_common.h
@@ -104,7 +104,7 @@ public:
}
}
- KillCursorsReply typedRun(OperationContext* opCtx) final {
+ KillCursorsCommandReply typedRun(OperationContext* opCtx) final {
auto killCursorsRequest = this->request();
std::vector<CursorId> cursorsKilled;
@@ -122,7 +122,7 @@ public:
}
}
- KillCursorsReply reply;
+ KillCursorsCommandReply reply;
reply.setCursorsKilled(std::move(cursorsKilled));
reply.setCursorsNotFound(std::move(cursorsNotFound));
reply.setCursorsAlive(std::move(cursorsAlive));
diff --git a/src/mongo/db/commands/map_reduce.idl b/src/mongo/db/commands/map_reduce.idl
index b2e8cbf22f6..cf74f858a39 100644
--- a/src/mongo/db/commands/map_reduce.idl
+++ b/src/mongo/db/commands/map_reduce.idl
@@ -68,9 +68,10 @@ types:
commands:
- MapReduce:
+ mapReduce:
description: "The MapReduce command."
- command_name: "MapReduce"
+ command_name: "mapReduce"
+ cpp_name: MapReduceCommandRequest
namespace: concatenate_with_db
api_version: ""
strict: true
diff --git a/src/mongo/db/commands/map_reduce_agg.cpp b/src/mongo/db/commands/map_reduce_agg.cpp
index 557c199b788..d86b4679814 100644
--- a/src/mongo/db/commands/map_reduce_agg.cpp
+++ b/src/mongo/db/commands/map_reduce_agg.cpp
@@ -59,7 +59,7 @@ namespace mongo::map_reduce_agg {
namespace {
auto makeExpressionContext(OperationContext* opCtx,
- const MapReduce& parsedMr,
+ const MapReduceCommandRequest& parsedMr,
boost::optional<ExplainOptions::Verbosity> verbosity) {
// AutoGetCollectionForReadCommand will throw if the sharding version for this connection is
// out of date.
@@ -123,7 +123,7 @@ bool runAggregationMapReduce(OperationContext* opCtx,
Timer cmdTimer;
- auto parsedMr = MapReduce::parse(IDLParserErrorContext("MapReduce"), cmd);
+ auto parsedMr = MapReduceCommandRequest::parse(IDLParserErrorContext("mapReduce"), cmd);
auto expCtx = makeExpressionContext(opCtx, parsedMr, verbosity);
auto runnablePipeline = [&]() {
auto pipeline = map_reduce_common::translateFromMR(parsedMr, expCtx);
diff --git a/src/mongo/db/commands/map_reduce_agg_test.cpp b/src/mongo/db/commands/map_reduce_agg_test.cpp
index a5859d040ca..52ee67c416b 100644
--- a/src/mongo/db/commands/map_reduce_agg_test.cpp
+++ b/src/mongo/db/commands/map_reduce_agg_test.cpp
@@ -70,10 +70,11 @@ constexpr auto finalizeJavascript = "finalize!"_sd;
TEST(MapReduceAggTest, testBasicTranslate) {
auto nss = NamespaceString{"db", "coll"};
- auto mr = MapReduce{nss,
- MapReduceJavascriptCode{mapJavascript.toString()},
- MapReduceJavascriptCode{reduceJavascript.toString()},
- MapReduceOutOptions{boost::none, "", OutputType::InMemory, false}};
+ auto mr =
+ MapReduceCommandRequest{nss,
+ MapReduceJavascriptCode{mapJavascript.toString()},
+ MapReduceJavascriptCode{reduceJavascript.toString()},
+ MapReduceOutOptions{boost::none, "", OutputType::InMemory, false}};
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest(nss));
auto pipeline = map_reduce_common::translateFromMR(mr, expCtx);
auto& sources = pipeline->getSources();
@@ -86,10 +87,11 @@ TEST(MapReduceAggTest, testBasicTranslate) {
TEST(MapReduceAggTest, testSortWithoutLimit) {
auto nss = NamespaceString{"db", "coll"};
- auto mr = MapReduce{nss,
- MapReduceJavascriptCode{mapJavascript.toString()},
- MapReduceJavascriptCode{reduceJavascript.toString()},
- MapReduceOutOptions{boost::none, "", OutputType::InMemory, false}};
+ auto mr =
+ MapReduceCommandRequest{nss,
+ MapReduceJavascriptCode{mapJavascript.toString()},
+ MapReduceJavascriptCode{reduceJavascript.toString()},
+ MapReduceOutOptions{boost::none, "", OutputType::InMemory, false}};
mr.setSort(BSON("foo" << 1));
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest(nss));
auto pipeline = map_reduce_common::translateFromMR(mr, expCtx);
@@ -106,10 +108,11 @@ TEST(MapReduceAggTest, testSortWithoutLimit) {
TEST(MapReduceAggTest, testSortWithLimit) {
auto nss = NamespaceString{"db", "coll"};
- auto mr = MapReduce{nss,
- MapReduceJavascriptCode{mapJavascript.toString()},
- MapReduceJavascriptCode{reduceJavascript.toString()},
- MapReduceOutOptions{boost::none, "", OutputType::InMemory, false}};
+ auto mr =
+ MapReduceCommandRequest{nss,
+ MapReduceJavascriptCode{mapJavascript.toString()},
+ MapReduceJavascriptCode{reduceJavascript.toString()},
+ MapReduceOutOptions{boost::none, "", OutputType::InMemory, false}};
mr.setSort(BSON("foo" << 1));
mr.setLimit(23);
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest(nss));
@@ -130,10 +133,11 @@ TEST(MapReduceAggTest, testSortWithLimit) {
TEST(MapReduceAggTest, testLimitNoSort) {
auto nss = NamespaceString{"db", "coll"};
- auto mr = MapReduce{nss,
- MapReduceJavascriptCode{mapJavascript.toString()},
- MapReduceJavascriptCode{reduceJavascript.toString()},
- MapReduceOutOptions{boost::none, "", OutputType::InMemory, false}};
+ auto mr =
+ MapReduceCommandRequest{nss,
+ MapReduceJavascriptCode{mapJavascript.toString()},
+ MapReduceJavascriptCode{reduceJavascript.toString()},
+ MapReduceOutOptions{boost::none, "", OutputType::InMemory, false}};
mr.setLimit(23);
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest(nss));
auto pipeline = map_reduce_common::translateFromMR(mr, expCtx);
@@ -150,7 +154,7 @@ TEST(MapReduceAggTest, testLimitNoSort) {
TEST(MapReduceAggTest, testFeatureLadenTranslate) {
auto nss = NamespaceString{"db", "coll"};
- auto mr = MapReduce{
+ auto mr = MapReduceCommandRequest{
nss,
MapReduceJavascriptCode{mapJavascript.toString()},
MapReduceJavascriptCode{reduceJavascript.toString()},
@@ -176,7 +180,7 @@ TEST(MapReduceAggTest, testFeatureLadenTranslate) {
TEST(MapReduceAggTest, testOutMergeTranslate) {
auto nss = NamespaceString{"db", "coll"};
- auto mr = MapReduce{
+ auto mr = MapReduceCommandRequest{
nss,
MapReduceJavascriptCode{mapJavascript.toString()},
MapReduceJavascriptCode{reduceJavascript.toString()},
@@ -196,7 +200,7 @@ TEST(MapReduceAggTest, testOutMergeTranslate) {
TEST(MapReduceAggTest, testOutReduceTranslate) {
auto nss = NamespaceString{"db", "coll"};
- auto mr = MapReduce{
+ auto mr = MapReduceCommandRequest{
nss,
MapReduceJavascriptCode{mapJavascript.toString()},
MapReduceJavascriptCode{reduceJavascript.toString()},
@@ -218,7 +222,7 @@ TEST(MapReduceAggTest, testOutReduceTranslate) {
TEST(MapReduceAggTest, testOutSameCollection) {
auto nss = NamespaceString{"db", "coll"};
- auto mr = MapReduce{
+ auto mr = MapReduceCommandRequest{
nss,
MapReduceJavascriptCode{mapJavascript.toString()},
MapReduceJavascriptCode{reduceJavascript.toString()},
@@ -236,7 +240,7 @@ TEST(MapReduceAggTest, testOutSameCollection) {
TEST(MapReduceAggTest, testSourceDestinationCollectionsEqualMergeDoesNotFail) {
auto nss = NamespaceString{"db", "coll"};
- auto mr = MapReduce{
+ auto mr = MapReduceCommandRequest{
nss,
MapReduceJavascriptCode{mapJavascript.toString()},
MapReduceJavascriptCode{reduceJavascript.toString()},
@@ -247,7 +251,7 @@ TEST(MapReduceAggTest, testSourceDestinationCollectionsEqualMergeDoesNotFail) {
TEST(MapReduceAggTest, testSourceDestinationCollectionsNotEqualMergeDoesNotFail) {
auto nss = NamespaceString{"db", "coll"};
- auto mr = MapReduce{
+ auto mr = MapReduceCommandRequest{
nss,
MapReduceJavascriptCode{mapJavascript.toString()},
MapReduceJavascriptCode{reduceJavascript.toString()},
@@ -258,7 +262,7 @@ TEST(MapReduceAggTest, testSourceDestinationCollectionsNotEqualMergeDoesNotFail)
TEST(MapReduceAggTest, testShardedTrueWithReplaceActionIsNotAllowed) {
auto nss = NamespaceString{"db", "coll"};
- auto mr = MapReduce{
+ auto mr = MapReduceCommandRequest{
nss,
MapReduceJavascriptCode{mapJavascript.toString()},
MapReduceJavascriptCode{reduceJavascript.toString()},
@@ -272,7 +276,7 @@ TEST(MapReduceAggTest, testErrorMessagesTranslated) {
// Verifies that agg specific error messages are translated to be mapReduce specific.
auto nss = NamespaceString{"db", "coll1"};
- auto mr = MapReduce{
+ auto mr = MapReduceCommandRequest{
nss,
MapReduceJavascriptCode{mapJavascript.toString()},
MapReduceJavascriptCode{reduceJavascript.toString()},
diff --git a/src/mongo/db/commands/map_reduce_parse_test.cpp b/src/mongo/db/commands/map_reduce_parse_test.cpp
index fc7f7e1ae9d..f89040dbf2e 100644
--- a/src/mongo/db/commands/map_reduce_parse_test.cpp
+++ b/src/mongo/db/commands/map_reduce_parse_test.cpp
@@ -50,201 +50,211 @@ constexpr auto finalizeJavascript = "finalize!"_sd;
TEST(MapReduceParseTest, failedParse) {
auto ctx = IDLParserErrorContext("mapReduce");
// Missing fields.
- ASSERT_THROWS(MapReduce::parse(ctx,
- BSON(""
- << ""
- << "$db"
- << "db")),
- DBException);
- ASSERT_THROWS(MapReduce::parse(ctx,
- BSON("mapReduce"
- << "foo"
- << "$db"
- << "db")),
+ ASSERT_THROWS(MapReduceCommandRequest::parse(ctx,
+ BSON(""
+ << ""
+ << "$db"
+ << "db")),
DBException);
- ASSERT_THROWS(MapReduce::parse(ctx,
- BSON("map" << mapJavascript << "reduce" << reduceJavascript
- << "out" << BSON("inline" << 1) << "$db"
- << "db")),
+ ASSERT_THROWS(MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "foo"
+ << "$db"
+ << "db")),
DBException);
+ ASSERT_THROWS(
+ MapReduceCommandRequest::parse(ctx,
+ BSON("map" << mapJavascript << "reduce" << reduceJavascript
+ << "out" << BSON("inline" << 1) << "$db"
+ << "db")),
+ DBException);
// Extra fields.
- ASSERT_THROWS(MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript
- << "out" << BSON("inline" << 1) << "alloy"
- << "chromium steel"
- << "$db"
- << "db")),
+ ASSERT_THROWS(MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce"
+ << reduceJavascript << "out"
+ << BSON("inline" << 1) << "alloy"
+ << "chromium steel"
+ << "$db"
+ << "db")),
DBException);
- ASSERT_THROWS(MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript
- << "out" << BSON("inline" << 1 << "notinline" << 0) << "$db"
- << "db")),
+ ASSERT_THROWS(MapReduceCommandRequest::parse(
+ ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
+ << BSON("inline" << 1 << "notinline" << 0) << "$db"
+ << "db")),
DBException);
}
TEST(MapReduceParseTest, failsToParseCodeWithScope) {
auto ctx = IDLParserErrorContext("mapReduce");
- ASSERT_THROWS(MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce"
- << BSONCodeWScope("var x = 3", BSONObj()) << "out"
- << BSON("inline" << 1) << "$db"
- << "db")),
+ ASSERT_THROWS(MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce"
+ << BSONCodeWScope("var x = 3", BSONObj())
+ << "out" << BSON("inline" << 1) << "$db"
+ << "db")),
+ DBException);
+ ASSERT_THROWS(MapReduceCommandRequest::parse(
+ ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << BSONCodeWScope("var x = 3", BSONObj()) << "reduce"
+ << reduceJavascript << "out" << BSON("inline" << 1) << "$db"
+ << "db")),
DBException);
- ASSERT_THROWS(
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << BSONCodeWScope("var x = 3", BSONObj()) << "reduce"
- << reduceJavascript << "out" << BSON("inline" << 1) << "$db"
- << "db")),
- DBException);
}
TEST(MapReduceParseTest, parseOutputTypes) {
auto ctx = IDLParserErrorContext("mapReduce");
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("inline" << 1) << "$db"
- << "db"));
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << "theSink"
- << "$db"
- << "db"));
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("replace"
- << "theSink"
- << "db"
- << "myDb")
- << "$db"
- << "db"));
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("merge"
- << "theSink")
- << "$db"
- << "db"));
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("reduce"
- << "theSink"
- << "db"
- << "myDb"
- << "sharded" << true)
- << "$db"
- << "db"));
+ MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript
+ << "out" << BSON("inline" << 1) << "$db"
+ << "db"));
+ MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript
+ << "out"
+ << "theSink"
+ << "$db"
+ << "db"));
+ MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript
+ << "out"
+ << BSON("replace"
+ << "theSink"
+ << "db"
+ << "myDb")
+ << "$db"
+ << "db"));
+ MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript
+ << "out"
+ << BSON("merge"
+ << "theSink")
+ << "$db"
+ << "db"));
+ MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript
+ << "out"
+ << BSON("reduce"
+ << "theSink"
+ << "db"
+ << "myDb"
+ << "sharded" << true)
+ << "$db"
+ << "db"));
ASSERT(true);
}
TEST(MapReduceParseTest, parseAllOptionalFields) {
auto ctx = IDLParserErrorContext("mapReduce");
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("inline" << 1) << "query"
- << BSON("author"
- << "dave")
- << "sort" << BSON("bottlecaps" << 1) << "collation"
- << BSON("locale"
- << "zh@collation=pinyin")
- << "limit" << 86 << "finalize" << finalizeJavascript << "scope"
- << BSON("global" << initJavascript) << "verbose" << false
- << "bypassDocumentValidation" << true << "writeConcern"
- << BSON("w" << 1 << "j" << false << "wtimeout" << 1498) << "$db"
- << "db"));
+ MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript
+ << "out" << BSON("inline" << 1) << "query"
+ << BSON("author"
+ << "dave")
+ << "sort" << BSON("bottlecaps" << 1) << "collation"
+ << BSON("locale"
+ << "zh@collation=pinyin")
+ << "limit" << 86 << "finalize" << finalizeJavascript
+ << "scope" << BSON("global" << initJavascript) << "verbose"
+ << false << "bypassDocumentValidation" << true
+ << "writeConcern"
+ << BSON("w" << 1 << "j" << false << "wtimeout" << 1498)
+ << "$db"
+ << "db"));
}
TEST(MapReduceParseTest, deprecatedOptions) {
auto ctx = IDLParserErrorContext("mapReduce");
// jsMode can be true or false
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("inline" << 1) << "$db"
- << "db"
- << "jsMode" << true));
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("inline" << 1) << "$db"
- << "db"
- << "jsMode" << false));
+ MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript
+ << "out" << BSON("inline" << 1) << "$db"
+ << "db"
+ << "jsMode" << true));
+ MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript
+ << "out" << BSON("inline" << 1) << "$db"
+ << "db"
+ << "jsMode" << false));
// nonAtomic can be true but not false
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("reduce"
- << "theSink"
- << "db"
- << "myDb"
- << "nonAtomic" << true)
- << "$db"
- << "db"));
- ASSERT_THROWS(
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("reduce"
- << "theSink"
- << "db"
- << "myDb"
- << "nonAtomic" << false)
- << "$db"
- << "db")),
- DBException);
- ASSERT_THROWS(
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("reduce"
- << "theSink"
- << "db"
- << "myDb"
- << "nonAtomic" << false)
- << "$db"
- << "db")),
- DBException);
+ MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce" << reduceJavascript
+ << "out"
+ << BSON("reduce"
+ << "theSink"
+ << "db"
+ << "myDb"
+ << "nonAtomic" << true)
+ << "$db"
+ << "db"));
+ ASSERT_THROWS(MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce"
+ << reduceJavascript << "out"
+ << BSON("reduce"
+ << "theSink"
+ << "db"
+ << "myDb"
+ << "nonAtomic" << false)
+ << "$db"
+ << "db")),
+ DBException);
+ ASSERT_THROWS(MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce"
+ << reduceJavascript << "out"
+ << BSON("reduce"
+ << "theSink"
+ << "db"
+ << "myDb"
+ << "nonAtomic" << false)
+ << "$db"
+ << "db")),
+ DBException);
// out.sharded cannot be false
- ASSERT_THROWS(
- MapReduce::parse(ctx,
- BSON("mapReduce"
- << "theSource"
- << "map" << mapJavascript << "reduce" << reduceJavascript << "out"
- << BSON("reduce"
- << "theSink"
- << "db"
- << "myDb"
- << "sharded" << false)
- << "$db"
- << "db")),
- DBException);
+ ASSERT_THROWS(MapReduceCommandRequest::parse(ctx,
+ BSON("mapReduce"
+ << "theSource"
+ << "map" << mapJavascript << "reduce"
+ << reduceJavascript << "out"
+ << BSON("reduce"
+ << "theSink"
+ << "db"
+ << "myDb"
+ << "sharded" << false)
+ << "$db"
+ << "db")),
+ DBException);
}
} // namespace
diff --git a/src/mongo/db/commands/mr_common.cpp b/src/mongo/db/commands/mr_common.cpp
index db1708a8715..46a0a0e6284 100644
--- a/src/mongo/db/commands/mr_common.cpp
+++ b/src/mongo/db/commands/mr_common.cpp
@@ -62,7 +62,7 @@ namespace {
using namespace std::string_literals;
-Status interpretTranslationError(DBException* ex, const MapReduce& parsedMr) {
+Status interpretTranslationError(DBException* ex, const MapReduceCommandRequest& parsedMr) {
auto status = ex->toStatus();
auto outOptions = parsedMr.getOutOptions();
auto outNss = NamespaceString{outOptions.getDatabaseName() ? *outOptions.getDatabaseName()
@@ -377,7 +377,7 @@ bool mrSupportsWriteConcern(const BSONObj& cmd) {
}
std::unique_ptr<Pipeline, PipelineDeleter> translateFromMR(
- MapReduce parsedMr, boost::intrusive_ptr<ExpressionContext> expCtx) {
+ MapReduceCommandRequest parsedMr, boost::intrusive_ptr<ExpressionContext> expCtx) {
auto outNss = NamespaceString{parsedMr.getOutOptions().getDatabaseName()
? *parsedMr.getOutOptions().getDatabaseName()
: parsedMr.getNamespace().db(),
diff --git a/src/mongo/db/commands/mr_common.h b/src/mongo/db/commands/mr_common.h
index 5e5c6dc55e7..344d819841f 100644
--- a/src/mongo/db/commands/mr_common.h
+++ b/src/mongo/db/commands/mr_common.h
@@ -66,6 +66,6 @@ bool mrSupportsWriteConcern(const BSONObj& cmd);
* returned pipeline does *not* contain a $cursor stage and thus is not runnable.
*/
std::unique_ptr<Pipeline, PipelineDeleter> translateFromMR(
- MapReduce parsedMr, boost::intrusive_ptr<ExpressionContext> expCtx);
+ MapReduceCommandRequest parsedMr, boost::intrusive_ptr<ExpressionContext> expCtx);
} // namespace mongo::map_reduce_common
diff --git a/src/mongo/db/commands/pipeline_command.cpp b/src/mongo/db/commands/pipeline_command.cpp
index 507ac3a9301..beed004686e 100644
--- a/src/mongo/db/commands/pipeline_command.cpp
+++ b/src/mongo/db/commands/pipeline_command.cpp
@@ -101,7 +101,7 @@ public:
public:
Invocation(Command* cmd,
const OpMsgRequest& request,
- const AggregateCommand aggregationRequest,
+ const AggregateCommandRequest aggregationRequest,
PrivilegeVector privileges)
: CommandInvocation(cmd),
_request(request),
@@ -180,7 +180,7 @@ public:
const OpMsgRequest& _request;
const std::string _dbName;
- const AggregateCommand _aggregationRequest;
+ const AggregateCommandRequest _aggregationRequest;
const LiteParsedPipeline _liteParsedPipeline;
const PrivilegeVector _privileges;
};
@@ -201,7 +201,7 @@ public:
}
const AuthorizationContract* getAuthorizationContract() const final {
- return &::mongo::AggregateCommand::kAuthorizationContract;
+ return &::mongo::AggregateCommandRequest::kAuthorizationContract;
}
} pipelineCmd;
diff --git a/src/mongo/db/commands/plan_cache_clear_command.cpp b/src/mongo/db/commands/plan_cache_clear_command.cpp
index 69c632bdc0a..b49a54fe416 100644
--- a/src/mongo/db/commands/plan_cache_clear_command.cpp
+++ b/src/mongo/db/commands/plan_cache_clear_command.cpp
@@ -86,9 +86,9 @@ Status clear(OperationContext* opCtx,
"Query shape doesn't exist in PlanCache",
"namespace"_attr = ns,
"query"_attr = redact(cq->getQueryObj()),
- "sort"_attr = cq->getFindCommand().getSort(),
- "projection"_attr = cq->getFindCommand().getProjection(),
- "collation"_attr = cq->getFindCommand().getCollation());
+ "sort"_attr = cq->getFindCommandRequest().getSort(),
+ "projection"_attr = cq->getFindCommandRequest().getProjection(),
+ "collation"_attr = cq->getFindCommandRequest().getCollation());
return Status::OK();
}
@@ -99,9 +99,9 @@ Status clear(OperationContext* opCtx,
"Removed plan cache entry",
"namespace"_attr = ns,
"query"_attr = redact(cq->getQueryObj()),
- "sort"_attr = cq->getFindCommand().getSort(),
- "projection"_attr = cq->getFindCommand().getProjection(),
- "collation"_attr = cq->getFindCommand().getCollation());
+ "sort"_attr = cq->getFindCommandRequest().getSort(),
+ "projection"_attr = cq->getFindCommandRequest().getProjection(),
+ "collation"_attr = cq->getFindCommandRequest().getCollation());
return Status::OK();
}
diff --git a/src/mongo/db/commands/plan_cache_commands.cpp b/src/mongo/db/commands/plan_cache_commands.cpp
index 7ac23d5911b..9aa4ca30bb7 100644
--- a/src/mongo/db/commands/plan_cache_commands.cpp
+++ b/src/mongo/db/commands/plan_cache_commands.cpp
@@ -85,7 +85,7 @@ StatusWith<std::unique_ptr<CanonicalQuery>> canonicalize(OperationContext* opCtx
}
// Create canonical query
- auto findCommand = std::make_unique<FindCommand>(NamespaceString{ns});
+ auto findCommand = std::make_unique<FindCommandRequest>(NamespaceString{ns});
findCommand->setFilter(queryObj.getOwned());
findCommand->setSort(sortObj.getOwned());
findCommand->setProjection(projObj.getOwned());
diff --git a/src/mongo/db/commands/run_aggregate.cpp b/src/mongo/db/commands/run_aggregate.cpp
index 96da0fda23a..7ba72ab079d 100644
--- a/src/mongo/db/commands/run_aggregate.cpp
+++ b/src/mongo/db/commands/run_aggregate.cpp
@@ -101,7 +101,7 @@ namespace {
*/
bool canOptimizeAwayPipeline(const Pipeline* pipeline,
const PlanExecutor* exec,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
bool hasGeoNearStage,
bool hasChangeStreamStage) {
return pipeline && exec && !hasGeoNearStage && !hasChangeStreamStage &&
@@ -121,7 +121,7 @@ bool handleCursorCommand(OperationContext* opCtx,
boost::intrusive_ptr<ExpressionContext> expCtx,
const NamespaceString& nsForCursor,
std::vector<ClientCursor*> cursors,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
const BSONObj& cmdObj,
rpc::ReplyBuilderInterface* result) {
invariant(!cursors.empty());
@@ -266,7 +266,7 @@ bool handleCursorCommand(OperationContext* opCtx,
}
StatusWith<StringMap<ExpressionContext::ResolvedNamespace>> resolveInvolvedNamespaces(
- OperationContext* opCtx, const AggregateCommand& request) {
+ OperationContext* opCtx, const AggregateCommandRequest& request) {
const LiteParsedPipeline liteParsedPipeline(request);
const auto& pipelineInvolvedNamespaces = liteParsedPipeline.getInvolvedNamespaces();
@@ -418,7 +418,7 @@ Status collatorCompatibleWithPipeline(OperationContext* opCtx,
// versioned. This can happen in the case where we are running in a cluster with a 4.4 mongoS, which
// does not set any shard version on a $mergeCursors pipeline.
void setIgnoredShardVersionForMergeCursors(OperationContext* opCtx,
- const AggregateCommand& request) {
+ const AggregateCommandRequest& request) {
auto isMergeCursors = request.getFromMongos() && request.getPipeline().size() > 0 &&
request.getPipeline().front().firstElementFieldNameStringData() == "$mergeCursors"_sd;
if (isMergeCursors && !OperationShardingState::isOperationVersioned(opCtx)) {
@@ -429,7 +429,7 @@ void setIgnoredShardVersionForMergeCursors(OperationContext* opCtx,
boost::intrusive_ptr<ExpressionContext> makeExpressionContext(
OperationContext* opCtx,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
std::unique_ptr<CollatorInterface> collator,
boost::optional<UUID> uuid) {
setIgnoredShardVersionForMergeCursors(opCtx, request);
@@ -489,7 +489,7 @@ void _adjustChangeStreamReadConcern(OperationContext* opCtx) {
std::vector<std::unique_ptr<Pipeline, PipelineDeleter>> createExchangePipelinesIfNeeded(
OperationContext* opCtx,
boost::intrusive_ptr<ExpressionContext> expCtx,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
std::unique_ptr<Pipeline, PipelineDeleter> pipeline,
boost::optional<UUID> uuid) {
std::vector<std::unique_ptr<Pipeline, PipelineDeleter>> pipelines;
@@ -526,11 +526,11 @@ std::vector<std::unique_ptr<Pipeline, PipelineDeleter>> createExchangePipelinesI
* Performs validations related to API versioning and time-series stages.
* Throws UserAssertion if any of the validations fails
* - validation of API versioning on each stage on the pipeline
- * - validation of API versioning on 'AggregateCommand' request
+ * - validation of API versioning on 'AggregateCommandRequest' request
* - validation of time-series related stages
*/
void performValidationChecks(const OperationContext* opCtx,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
const LiteParsedPipeline& liteParsedPipeline) {
liteParsedPipeline.validate(opCtx);
aggregation_request_helper::validateRequestForAPIVersion(opCtx, request);
@@ -540,7 +540,7 @@ void performValidationChecks(const OperationContext* opCtx,
Status runAggregate(OperationContext* opCtx,
const NamespaceString& nss,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
const BSONObj& cmdObj,
const PrivilegeVector& privileges,
rpc::ReplyBuilderInterface* result) {
@@ -549,7 +549,7 @@ Status runAggregate(OperationContext* opCtx,
Status runAggregate(OperationContext* opCtx,
const NamespaceString& origNss,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
const LiteParsedPipeline& liteParsedPipeline,
const BSONObj& cmdObj,
const PrivilegeVector& privileges,
@@ -592,7 +592,7 @@ Status runAggregate(OperationContext* opCtx,
// If this is a change stream, perform special checks and change the execution namespace.
if (liteParsedPipeline.hasChangeStream()) {
uassert(4928900,
- str::stream() << AggregateCommand::kCollectionUUIDFieldName
+ str::stream() << AggregateCommandRequest::kCollectionUUIDFieldName
<< " is not supported for a change stream",
!request.getCollectionUUID());
@@ -629,7 +629,7 @@ Status runAggregate(OperationContext* opCtx,
ctx.emplace(opCtx, nss, AutoGetCollectionViewMode::kViewsForbidden);
} else if (nss.isCollectionlessAggregateNS() && pipelineInvolvedNamespaces.empty()) {
uassert(4928901,
- str::stream() << AggregateCommand::kCollectionUUIDFieldName
+ str::stream() << AggregateCommandRequest::kCollectionUUIDFieldName
<< " is not supported for a collectionless aggregation",
!request.getCollectionUUID());
@@ -662,7 +662,7 @@ Status runAggregate(OperationContext* opCtx,
invariant(nss != NamespaceString::kRsOplogNamespace);
invariant(!nss.isCollectionlessAggregateNS());
uassert(ErrorCodes::OptionNotSupportedOnView,
- str::stream() << AggregateCommand::kCollectionUUIDFieldName
+ str::stream() << AggregateCommandRequest::kCollectionUUIDFieldName
<< " is not supported against a view",
!request.getCollectionUUID());
diff --git a/src/mongo/db/commands/run_aggregate.h b/src/mongo/db/commands/run_aggregate.h
index 30376367e83..ea7873dade6 100644
--- a/src/mongo/db/commands/run_aggregate.h
+++ b/src/mongo/db/commands/run_aggregate.h
@@ -53,7 +53,7 @@ namespace mongo {
*/
Status runAggregate(OperationContext* opCtx,
const NamespaceString& nss,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
const LiteParsedPipeline& liteParsedPipeline,
const BSONObj& cmdObj,
const PrivilegeVector& privileges,
@@ -64,7 +64,7 @@ Status runAggregate(OperationContext* opCtx,
*/
Status runAggregate(OperationContext* opCtx,
const NamespaceString& nss,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
const BSONObj& cmdObj,
const PrivilegeVector& privileges,
rpc::ReplyBuilderInterface* result);
diff --git a/src/mongo/db/commands/rwc_defaults_commands.cpp b/src/mongo/db/commands/rwc_defaults_commands.cpp
index 90f817f29c5..ef2ce1272d2 100644
--- a/src/mongo/db/commands/rwc_defaults_commands.cpp
+++ b/src/mongo/db/commands/rwc_defaults_commands.cpp
@@ -54,7 +54,7 @@ namespace {
void updatePersistedDefaultRWConcernDocument(OperationContext* opCtx, const RWConcernDefault& rw) {
DBDirectClient client(opCtx);
const auto commandResponse = client.runCommand([&] {
- write_ops::Update updateOp(NamespaceString::kConfigSettingsNamespace);
+ write_ops::UpdateCommandRequest updateOp(NamespaceString::kConfigSettingsNamespace);
updateOp.setUpdates({[&] {
write_ops::UpdateOpEntry entry;
entry.setQ(BSON("_id" << ReadWriteConcernDefaults::kPersistedDocumentId));
diff --git a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
index 38198ad1aff..1869090bc4e 100644
--- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
+++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
@@ -81,7 +81,7 @@ MONGO_FAIL_POINT_DEFINE(hangWhileDowngrading);
void deletePersistedDefaultRWConcernDocument(OperationContext* opCtx) {
DBDirectClient client(opCtx);
const auto commandResponse = client.runCommand([&] {
- write_ops::Delete deleteOp(NamespaceString::kConfigSettingsNamespace);
+ write_ops::DeleteCommandRequest deleteOp(NamespaceString::kConfigSettingsNamespace);
deleteOp.setDeletes({[&] {
write_ops::DeleteOpEntry entry;
entry.setQ(BSON("_id" << ReadWriteConcernDefaults::kPersistedDocumentId));
diff --git a/src/mongo/db/commands/update_metrics.cpp b/src/mongo/db/commands/update_metrics.cpp
index 938a29944aa..357920aeb7e 100644
--- a/src/mongo/db/commands/update_metrics.cpp
+++ b/src/mongo/db/commands/update_metrics.cpp
@@ -58,7 +58,7 @@ void UpdateMetrics::collectMetrics(const BSONObj& cmdObj) {
}
}
-void UpdateMetrics::collectMetrics(const write_ops::FindAndModifyCommand& cmd) {
+void UpdateMetrics::collectMetrics(const write_ops::FindAndModifyCommandRequest& cmd) {
if (auto update = cmd.getUpdate()) {
if (update->type() == write_ops::UpdateModification::Type::kPipeline) {
_commandsWithAggregationPipeline.increment();
diff --git a/src/mongo/db/commands/update_metrics.h b/src/mongo/db/commands/update_metrics.h
index b237c9632a2..c6732762778 100644
--- a/src/mongo/db/commands/update_metrics.h
+++ b/src/mongo/db/commands/update_metrics.h
@@ -68,7 +68,7 @@ public:
/**
* Increments update metrics corresponding to the supplied parameters.
*/
- void collectMetrics(const write_ops::FindAndModifyCommand& cmd);
+ void collectMetrics(const write_ops::FindAndModifyCommandRequest& cmd);
private:
// A counter for how many times this command has been executed with an aggregation
diff --git a/src/mongo/db/commands/user_management_commands.cpp b/src/mongo/db/commands/user_management_commands.cpp
index adae82a5251..855c63acb60 100644
--- a/src/mongo/db/commands/user_management_commands.cpp
+++ b/src/mongo/db/commands/user_management_commands.cpp
@@ -243,7 +243,7 @@ Status insertAuthzDocument(OperationContext* opCtx,
BSONObj res;
client.runCommand(collectionName.db().toString(),
[&] {
- write_ops::Insert insertOp(collectionName);
+ write_ops::InsertCommandRequest insertOp(collectionName);
insertOp.setDocuments({document});
return insertOp.toBSON({});
}(),
@@ -279,7 +279,7 @@ Status updateAuthzDocuments(OperationContext* opCtx,
BSONObj res;
client.runCommand(collectionName.db().toString(),
[&] {
- write_ops::Update updateOp(collectionName);
+ write_ops::UpdateCommandRequest updateOp(collectionName);
updateOp.setUpdates({[&] {
write_ops::UpdateOpEntry entry;
entry.setQ(query);
@@ -353,7 +353,7 @@ Status removeAuthzDocuments(OperationContext* opCtx,
BSONObj res;
client.runCommand(collectionName.db().toString(),
[&] {
- write_ops::Delete deleteOp(collectionName);
+ write_ops::DeleteCommandRequest deleteOp(collectionName);
deleteOp.setDeletes({[&] {
write_ops::DeleteOpEntry entry;
entry.setQ(query);
@@ -790,7 +790,7 @@ public:
StatusWith<std::uint32_t> insert(const NamespaceString& nss, const std::vector<BSONObj>& docs) {
dassert(nss.db() == kAdminDB);
- write_ops::Insert op(nss);
+ write_ops::InsertCommandRequest op(nss);
op.setDocuments(docs);
return doCrudOp(op.toBSON({}));
}
@@ -801,7 +801,7 @@ public:
entry.setQ(query);
entry.setU(write_ops::UpdateModification::parseFromClassicUpdate(update));
entry.setMulti(true);
- write_ops::Update op(nss);
+ write_ops::UpdateCommandRequest op(nss);
op.setUpdates({entry});
return doCrudOp(op.toBSON({}));
}
@@ -811,7 +811,7 @@ public:
write_ops::DeleteOpEntry entry;
entry.setQ(query);
entry.setMulti(true);
- write_ops::Delete op(nss);
+ write_ops::DeleteCommandRequest op(nss);
op.setDeletes({entry});
return doCrudOp(op.toBSON({}));
}
@@ -1420,8 +1420,8 @@ UsersInfoReply CmdUMCTyped<UsersInfoCommand, UsersInfoReply, UMCInfoParams>::Inv
DBDirectClient client(opCtx);
rpc::OpMsgReplyBuilder replyBuilder;
- AggregateCommand aggRequest(AuthorizationManager::usersCollectionNamespace,
- std::move(pipeline));
+ AggregateCommandRequest aggRequest(AuthorizationManager::usersCollectionNamespace,
+ std::move(pipeline));
// Impose no cursor privilege requirements, as cursor is drained internally
uassertStatusOK(runAggregate(opCtx,
AuthorizationManager::usersCollectionNamespace,
diff --git a/src/mongo/db/commands/validate_db_metadata.idl b/src/mongo/db/commands/validate_db_metadata.idl
index c44a9dd1807..b66e3ac557c 100644
--- a/src/mongo/db/commands/validate_db_metadata.idl
+++ b/src/mongo/db/commands/validate_db_metadata.idl
@@ -46,7 +46,7 @@ structs:
codeName: string
errmsg: string
- ValidateDBMetadataReply:
+ ValidateDBMetadataCommandReply:
description: "The validateDBMetadata command's reply."
fields:
apiVersionErrors:
@@ -68,9 +68,10 @@ commands:
validateDBMetadata:
description: "Input request for validateDBMetadata command."
command_name: validateDBMetadata
+ cpp_name: ValidateDBMetadataCommandRequest
namespace: ignored
api_version: ""
- reply_type: ValidateDBMetadataReply
+ reply_type: ValidateDBMetadataCommandReply
fields:
db:
type: string
diff --git a/src/mongo/db/commands/validate_db_metadata_cmd.cpp b/src/mongo/db/commands/validate_db_metadata_cmd.cpp
index 6ed59358880..8ef1d91fd7a 100644
--- a/src/mongo/db/commands/validate_db_metadata_cmd.cpp
+++ b/src/mongo/db/commands/validate_db_metadata_cmd.cpp
@@ -68,8 +68,8 @@ class ValidateDBMetadataCmd : public TypedCommand<ValidateDBMetadataCmd> {
typename TypedCommand<ValidateDBMetadataCmd>::InvocationBase;
public:
- using Request = ValidateDBMetadata;
- using Reply = ValidateDBMetadataReply;
+ using Request = ValidateDBMetadataCommandRequest;
+ using Reply = ValidateDBMetadataCommandReply;
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kAlways;
@@ -236,7 +236,7 @@ public:
ValidateDBMetadataSizeTracker _sizeTracker;
std::vector<ErrorReplyElement> apiVersionErrors;
- ValidateDBMetadataReply _reply;
+ ValidateDBMetadataCommandReply _reply;
};
} validateDBMetadataCmd;
} // namespace mongo
diff --git a/src/mongo/db/commands/validate_db_metadata_common.h b/src/mongo/db/commands/validate_db_metadata_common.h
index 52e336b0dbe..a3b76ab6ab5 100644
--- a/src/mongo/db/commands/validate_db_metadata_common.h
+++ b/src/mongo/db/commands/validate_db_metadata_common.h
@@ -49,7 +49,8 @@ private:
size_t currentSize = 0;
};
-void assertUserCanRunValidate(OperationContext* opCtx, const ValidateDBMetadata& request) {
+void assertUserCanRunValidate(OperationContext* opCtx,
+ const ValidateDBMetadataCommandRequest& request) {
const auto resource = request.getDb() ? ResourcePattern::forDatabaseName(*request.getDb())
: ResourcePattern::forAnyNormalResource();
uassert(ErrorCodes::Unauthorized,
diff --git a/src/mongo/db/commands/write_commands.cpp b/src/mongo/db/commands/write_commands.cpp
index 33a5598bf02..241fe8f44d9 100644
--- a/src/mongo/db/commands/write_commands.cpp
+++ b/src/mongo/db/commands/write_commands.cpp
@@ -401,7 +401,7 @@ void populateReply(OperationContext* opCtx,
hooks->singleWriteResultHandler(opResult, i);
}
- auto& replyBase = cmdReply->getWriteReplyBase();
+ auto& replyBase = cmdReply->getWriteCommandReplyBase();
replyBase.setN(nVal);
if (!errors.empty()) {
@@ -485,9 +485,9 @@ public:
return request().getNamespace();
}
- write_ops::InsertReply typedRun(OperationContext* opCtx) final try {
+ write_ops::InsertCommandReply typedRun(OperationContext* opCtx) final try {
transactionChecks(opCtx, ns());
- write_ops::InsertReply insertReply;
+ write_ops::InsertCommandReply insertReply;
if (isTimeseries(opCtx, ns())) {
// Re-throw parsing exceptions to be consistent with CmdInsert::Invocation's
@@ -504,7 +504,7 @@ public:
auto reply = write_ops_exec::performInserts(opCtx, request());
populateReply(opCtx,
- !request().getWriteCommandBase().getOrdered(),
+ !request().getWriteCommandRequestBase().getOrdered(),
request().getDocuments().size(),
std::move(reply),
&insertReply);
@@ -547,21 +547,22 @@ public:
auto bucketsNs = ns().makeTimeseriesBucketsNamespace();
BSONObjBuilder builder;
- builder.append(write_ops::Insert::kCommandName, bucketsNs.coll());
+ builder.append(write_ops::InsertCommandRequest::kCommandName, bucketsNs.coll());
// The schema validation configured in the bucket collection is intended for direct
// operations by end users and is not applicable here.
- builder.append(write_ops::Insert::kBypassDocumentValidationFieldName, true);
+ builder.append(write_ops::InsertCommandRequest::kBypassDocumentValidationFieldName,
+ true);
if (stmtIds) {
- builder.append(write_ops::Insert::kStmtIdsFieldName, *stmtIds);
+ builder.append(write_ops::InsertCommandRequest::kStmtIdsFieldName, *stmtIds);
}
- builder.append(write_ops::Insert::kDocumentsFieldName,
+ builder.append(write_ops::InsertCommandRequest::kDocumentsFieldName,
makeTimeseriesInsertDocument(batch, metadata));
auto request = OpMsgRequest::fromDBAndBody(bucketsNs.db(), builder.obj());
- auto timeseriesInsertBatch =
- write_ops::Insert::parse({"CmdInsert::_performTimeseriesInsert"}, request);
+ auto timeseriesInsertBatch = write_ops::InsertCommandRequest::parse(
+ {"CmdInsert::_performTimeseriesInsert"}, request);
return _getTimeseriesSingleWriteResult(write_ops_exec::performInserts(
opCtx, timeseriesInsertBatch, OperationSource::kTimeseries));
@@ -578,10 +579,10 @@ public:
}
auto update = makeTimeseriesUpdateOpEntry(batch, metadata);
- write_ops::Update timeseriesUpdateBatch(ns().makeTimeseriesBucketsNamespace(),
- {update});
+ write_ops::UpdateCommandRequest timeseriesUpdateBatch(
+ ns().makeTimeseriesBucketsNamespace(), {update});
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::WriteCommandRequestBase writeCommandBase;
// The schema validation configured in the bucket collection is intended for direct
// operations by end users and is not applicable here.
writeCommandBase.setBypassDocumentValidation(true);
@@ -590,7 +591,7 @@ public:
writeCommandBase.setStmtIds(*stmtIds);
}
- timeseriesUpdateBatch.setWriteCommandBase(std::move(writeCommandBase));
+ timeseriesUpdateBatch.setWriteCommandRequestBase(std::move(writeCommandBase));
return _getTimeseriesSingleWriteResult(write_ops_exec::performUpdates(
opCtx, timeseriesUpdateBatch, OperationSource::kTimeseries));
@@ -805,7 +806,7 @@ public:
}
void _performTimeseriesWrites(OperationContext* opCtx,
- write_ops::InsertReply* insertReply) const {
+ write_ops::InsertCommandReply* insertReply) const {
auto& curOp = *CurOp::get(opCtx);
ON_BLOCK_EXIT([&] {
// This is the only part of finishCurOp we need to do for inserts because they reuse
@@ -826,7 +827,7 @@ public:
boost::optional<OID> electionId;
bool containsRetry = false;
- auto& baseReply = insertReply->getWriteReplyBase();
+ auto& baseReply = insertReply->getWriteCommandReplyBase();
if (request().getOrdered()) {
baseReply.setN(request().getDocuments().size());
@@ -952,10 +953,10 @@ public:
bob->append("singleBatch", true);
}
- write_ops::UpdateReply typedRun(OperationContext* opCtx) final try {
+ write_ops::UpdateCommandReply typedRun(OperationContext* opCtx) final try {
transactionChecks(opCtx, ns());
- write_ops::UpdateReply updateReply;
+ write_ops::UpdateCommandReply updateReply;
long long nModified = 0;
// Tracks the upserted information. The memory of this variable gets moved in the
@@ -981,7 +982,7 @@ public:
};
populateReply(opCtx,
- !request().getWriteCommandBase().getOrdered(),
+ !request().getWriteCommandRequestBase().getOrdered(),
request().getUpdates().size(),
std::move(reply),
&updateReply,
@@ -993,8 +994,8 @@ public:
// which stages were being used.
auto& updateMod = update.getU();
if (updateMod.type() == write_ops::UpdateModification::Type::kPipeline) {
- AggregateCommand aggCmd(request().getNamespace(),
- updateMod.getUpdatePipeline());
+ AggregateCommandRequest aggCmd(request().getNamespace(),
+ updateMod.getUpdatePipeline());
LiteParsedPipeline pipeline(aggCmd);
pipeline.tickGlobalStageCounters();
CmdUpdate::updateMetrics.incrementExecutedWithAggregationPipeline();
@@ -1114,14 +1115,14 @@ public:
return request().getNamespace();
}
- write_ops::DeleteReply typedRun(OperationContext* opCtx) final try {
+ write_ops::DeleteCommandReply typedRun(OperationContext* opCtx) final try {
transactionChecks(opCtx, ns());
- write_ops::DeleteReply deleteReply;
+ write_ops::DeleteCommandReply deleteReply;
auto reply = write_ops_exec::performDeletes(opCtx, request());
populateReply(opCtx,
- !request().getWriteCommandBase().getOrdered(),
+ !request().getWriteCommandRequestBase().getOrdered(),
request().getDeletes().size(),
std::move(reply),
&deleteReply);
diff --git a/src/mongo/db/commands/write_commands_common.cpp b/src/mongo/db/commands/write_commands_common.cpp
index bb16789da55..ac39adca706 100644
--- a/src/mongo/db/commands/write_commands_common.cpp
+++ b/src/mongo/db/commands/write_commands_common.cpp
@@ -63,13 +63,13 @@ NamespaceString _getIndexedNss(const std::vector<BSONObj>& documents) {
return NamespaceString(std::move(ns));
}
-void fillPrivileges(const write_ops::Insert& op,
+void fillPrivileges(const write_ops::InsertCommandRequest& op,
std::vector<Privilege>* privileges,
ActionSet* actions) {
actions->addAction(ActionType::insert);
}
-void fillPrivileges(const write_ops::Update& op,
+void fillPrivileges(const write_ops::UpdateCommandRequest& op,
std::vector<Privilege>* privileges,
ActionSet* actions) {
actions->addAction(ActionType::update);
@@ -80,7 +80,7 @@ void fillPrivileges(const write_ops::Update& op,
}
}
-void fillPrivileges(const write_ops::Delete& op,
+void fillPrivileges(const write_ops::DeleteCommandRequest& op,
std::vector<Privilege>* privileges,
ActionSet* actions) {
actions->addAction(ActionType::remove);
@@ -109,19 +109,19 @@ void checkAuthorizationImpl(AuthorizationSession* authzSession,
void checkAuthForInsertCommand(AuthorizationSession* authzSession,
bool withDocumentValidationBypass,
- const write_ops::Insert& op) {
+ const write_ops::InsertCommandRequest& op) {
checkAuthorizationImpl(authzSession, withDocumentValidationBypass, op);
}
void checkAuthForUpdateCommand(AuthorizationSession* authzSession,
bool withDocumentValidationBypass,
- const write_ops::Update& op) {
+ const write_ops::UpdateCommandRequest& op) {
checkAuthorizationImpl(authzSession, withDocumentValidationBypass, op);
}
void checkAuthForDeleteCommand(AuthorizationSession* authzSession,
bool withDocumentValidationBypass,
- const write_ops::Delete& op) {
+ const write_ops::DeleteCommandRequest& op) {
checkAuthorizationImpl(authzSession, withDocumentValidationBypass, op);
}
diff --git a/src/mongo/db/commands/write_commands_common.h b/src/mongo/db/commands/write_commands_common.h
index 62561d7bb31..088c0c8f690 100644
--- a/src/mongo/db/commands/write_commands_common.h
+++ b/src/mongo/db/commands/write_commands_common.h
@@ -43,13 +43,13 @@ namespace auth {
void checkAuthForInsertCommand(AuthorizationSession* authzSession,
bool withDocumentValidationBypass,
- const write_ops::Insert& op);
+ const write_ops::InsertCommandRequest& op);
void checkAuthForUpdateCommand(AuthorizationSession* authzSession,
bool withDocumentValidationBypass,
- const write_ops::Update& op);
+ const write_ops::UpdateCommandRequest& op);
void checkAuthForDeleteCommand(AuthorizationSession* authzSession,
bool withDocumentValidationBypass,
- const write_ops::Delete& op);
+ const write_ops::DeleteCommandRequest& op);
} // namespace auth
} // namespace mongo
diff --git a/src/mongo/db/db_raii_test.cpp b/src/mongo/db/db_raii_test.cpp
index cf142ce0222..2a8b03c6319 100644
--- a/src/mongo/db/db_raii_test.cpp
+++ b/src/mongo/db/db_raii_test.cpp
@@ -70,7 +70,7 @@ public:
std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> makeTailableQueryPlan(
OperationContext* opCtx, const CollectionPtr& collection) {
- auto findCommand = std::make_unique<FindCommand>(collection->ns());
+ auto findCommand = std::make_unique<FindCommandRequest>(collection->ns());
query_request_helper::setTailableMode(TailableModeEnum::kTailableAndAwaitData,
findCommand.get());
diff --git a/src/mongo/db/dbdirectclient.cpp b/src/mongo/db/dbdirectclient.cpp
index 36b49be7756..31d330ea11b 100644
--- a/src/mongo/db/dbdirectclient.cpp
+++ b/src/mongo/db/dbdirectclient.cpp
@@ -174,8 +174,8 @@ unique_ptr<DBClientCursor> DBDirectClient::query(const NamespaceStringOrUUID& ns
nsOrUuid, query, nToReturn, nToSkip, fieldsToReturn, queryOptions, batchSize);
}
-write_ops::FindAndModifyReply DBDirectClient::findAndModify(
- const write_ops::FindAndModifyCommand& findAndModify) {
+write_ops::FindAndModifyCommandReply DBDirectClient::findAndModify(
+ const write_ops::FindAndModifyCommandRequest& findAndModify) {
auto response = runCommand(findAndModify.serialize({}));
return FindAndModifyOp::parseResponse(response->getCommandReply());
}
diff --git a/src/mongo/db/dbdirectclient.h b/src/mongo/db/dbdirectclient.h
index a14d05c19eb..7b27481d540 100644
--- a/src/mongo/db/dbdirectclient.h
+++ b/src/mongo/db/dbdirectclient.h
@@ -65,8 +65,8 @@ public:
int batchSize = 0,
boost::optional<BSONObj> readConcernObj = boost::none);
- write_ops::FindAndModifyReply findAndModify(
- const write_ops::FindAndModifyCommand& findAndModify);
+ write_ops::FindAndModifyCommandReply findAndModify(
+ const write_ops::FindAndModifyCommandRequest& findAndModify);
virtual bool isFailed() const;
diff --git a/src/mongo/db/dbhelpers.cpp b/src/mongo/db/dbhelpers.cpp
index 0d4f4bebeec..95fa749e364 100644
--- a/src/mongo/db/dbhelpers.cpp
+++ b/src/mongo/db/dbhelpers.cpp
@@ -81,14 +81,14 @@ RecordId Helpers::findOne(OperationContext* opCtx,
if (!collection)
return RecordId();
- auto findCommand = std::make_unique<FindCommand>(collection->ns());
+ auto findCommand = std::make_unique<FindCommandRequest>(collection->ns());
findCommand->setFilter(query);
return findOne(opCtx, collection, std::move(findCommand), requireIndex);
}
RecordId Helpers::findOne(OperationContext* opCtx,
const CollectionPtr& collection,
- std::unique_ptr<FindCommand> findCommand,
+ std::unique_ptr<FindCommandRequest> findCommand,
bool requireIndex) {
if (!collection)
return RecordId();
diff --git a/src/mongo/db/dbhelpers.h b/src/mongo/db/dbhelpers.h
index 284e1b4d051..0d624e5769a 100644
--- a/src/mongo/db/dbhelpers.h
+++ b/src/mongo/db/dbhelpers.h
@@ -39,7 +39,7 @@ class Collection;
class CollectionPtr;
class Database;
class OperationContext;
-class FindCommand;
+class FindCommandRequest;
/**
* db helpers are helper functions and classes that let us easily manipulate the local
@@ -75,7 +75,7 @@ struct Helpers {
bool requireIndex);
static RecordId findOne(OperationContext* opCtx,
const CollectionPtr& collection,
- std::unique_ptr<FindCommand> qr,
+ std::unique_ptr<FindCommandRequest> qr,
bool requireIndex);
/**
diff --git a/src/mongo/db/exec/idhack.cpp b/src/mongo/db/exec/idhack.cpp
index db3a668bf27..304a18beb18 100644
--- a/src/mongo/db/exec/idhack.cpp
+++ b/src/mongo/db/exec/idhack.cpp
@@ -58,7 +58,7 @@ IDHackStage::IDHackStage(ExpressionContext* expCtx,
_workingSet(ws),
_key(query->getQueryObj()["_id"].wrap()) {
_specificStats.indexName = descriptor->indexName();
- _addKeyMetadata = query->getFindCommand().getReturnKey();
+ _addKeyMetadata = query->getFindCommandRequest().getReturnKey();
}
IDHackStage::IDHackStage(ExpressionContext* expCtx,
diff --git a/src/mongo/db/exec/sbe_cmd.cpp b/src/mongo/db/exec/sbe_cmd.cpp
index f91529db887..682b86b7e85 100644
--- a/src/mongo/db/exec/sbe_cmd.cpp
+++ b/src/mongo/db/exec/sbe_cmd.cpp
@@ -79,7 +79,8 @@ public:
NamespaceString nss{dbname};
// Create a trivial cannonical query for the 'sbe' command execution.
- auto statusWithCQ = CanonicalQuery::canonicalize(opCtx, std::make_unique<FindCommand>(nss));
+ auto statusWithCQ =
+ CanonicalQuery::canonicalize(opCtx, std::make_unique<FindCommandRequest>(nss));
std::unique_ptr<CanonicalQuery> cq = std::move(statusWithCQ.getValue());
stage_builder::PlanStageData data{std::make_unique<sbe::RuntimeEnvironment>()};
diff --git a/src/mongo/db/exec/subplan.cpp b/src/mongo/db/exec/subplan.cpp
index 9aaea0bb41d..0b60d4ffd4f 100644
--- a/src/mongo/db/exec/subplan.cpp
+++ b/src/mongo/db/exec/subplan.cpp
@@ -72,7 +72,7 @@ SubplanStage::SubplanStage(ExpressionContext* expCtx,
}
bool SubplanStage::canUseSubplanning(const CanonicalQuery& query) {
- const FindCommand& findCommand = query.getFindCommand();
+ const FindCommandRequest& findCommand = query.getFindCommandRequest();
const MatchExpression* expr = query.root();
// Hint provided
diff --git a/src/mongo/db/exec/trial_period_utils.cpp b/src/mongo/db/exec/trial_period_utils.cpp
index 9a7bbe8bc41..80e55f890cd 100644
--- a/src/mongo/db/exec/trial_period_utils.cpp
+++ b/src/mongo/db/exec/trial_period_utils.cpp
@@ -54,11 +54,12 @@ size_t getTrialPeriodNumToReturn(const CanonicalQuery& query) {
// Determine the number of results which we will produce during the plan ranking phase before
// stopping.
size_t numResults = static_cast<size_t>(internalQueryPlanEvaluationMaxResults.load());
- if (query.getFindCommand().getNtoreturn()) {
+ if (query.getFindCommandRequest().getNtoreturn()) {
+ numResults = std::min(static_cast<size_t>(*query.getFindCommandRequest().getNtoreturn()),
+ numResults);
+ } else if (query.getFindCommandRequest().getLimit()) {
numResults =
- std::min(static_cast<size_t>(*query.getFindCommand().getNtoreturn()), numResults);
- } else if (query.getFindCommand().getLimit()) {
- numResults = std::min(static_cast<size_t>(*query.getFindCommand().getLimit()), numResults);
+ std::min(static_cast<size_t>(*query.getFindCommandRequest().getLimit()), numResults);
}
return numResults;
diff --git a/src/mongo/db/explain.idl b/src/mongo/db/explain.idl
index 3738976e015..9dbbe2ce99d 100644
--- a/src/mongo/db/explain.idl
+++ b/src/mongo/db/explain.idl
@@ -37,9 +37,9 @@ commands:
explain:
description: "Parser for the explain command"
command_name: explain
+ cpp_name: ExplainCommandRequest
namespace: type
type: object
- cpp_name: ExplainCmd
strict: true
api_version: "1"
access_check:
diff --git a/src/mongo/db/explain_test.cpp b/src/mongo/db/explain_test.cpp
index 9b7d3df9c06..866574f0fc5 100644
--- a/src/mongo/db/explain_test.cpp
+++ b/src/mongo/db/explain_test.cpp
@@ -60,58 +60,62 @@ TEST(ExplainTest, ExplainSerializeToBSONCorrectly) {
}
TEST(ExplainTest, CanParseExplainVerbosity) {
- auto verbosity =
- ExplainCmd::parse(IDLParserErrorContext("explain"),
- fromjson("{explain: {}, verbosity: 'queryPlanner', $db: 'dummy'}"))
- .getVerbosity();
+ auto verbosity = ExplainCommandRequest::parse(
+ IDLParserErrorContext("explain"),
+ fromjson("{explain: {}, verbosity: 'queryPlanner', $db: 'dummy'}"))
+ .getVerbosity();
ASSERT(verbosity == Verbosity::kQueryPlanner);
- verbosity =
- ExplainCmd::parse(IDLParserErrorContext("explain"),
- fromjson("{explain: {}, verbosity: 'executionStats', $db: 'dummy'}"))
- .getVerbosity();
+ verbosity = ExplainCommandRequest::parse(
+ IDLParserErrorContext("explain"),
+ fromjson("{explain: {}, verbosity: 'executionStats', $db: 'dummy'}"))
+ .getVerbosity();
ASSERT(verbosity == Verbosity::kExecStats);
- verbosity =
- ExplainCmd::parse(IDLParserErrorContext("explain"),
- fromjson("{explain: {}, verbosity: 'allPlansExecution', $db: 'dummy'}"))
- .getVerbosity();
+ verbosity = ExplainCommandRequest::parse(
+ IDLParserErrorContext("explain"),
+ fromjson("{explain: {}, verbosity: 'allPlansExecution', $db: 'dummy'}"))
+ .getVerbosity();
ASSERT(verbosity == Verbosity::kExecAllPlans);
}
TEST(ExplainTest, ParsingFailsIfVerbosityIsNotAString) {
- ASSERT_THROWS_CODE(ExplainCmd::parse(IDLParserErrorContext("explain"),
- fromjson("{explain: {}, verbosity: 1}")),
- DBException,
- ErrorCodes::TypeMismatch);
- ASSERT_THROWS_CODE(ExplainCmd::parse(IDLParserErrorContext("explain"),
- fromjson("{explain: {}, verbosity: {foo: 'bar'}}")),
+ ASSERT_THROWS_CODE(ExplainCommandRequest::parse(IDLParserErrorContext("explain"),
+ fromjson("{explain: {}, verbosity: 1}")),
DBException,
ErrorCodes::TypeMismatch);
+ ASSERT_THROWS_CODE(
+ ExplainCommandRequest::parse(IDLParserErrorContext("explain"),
+ fromjson("{explain: {}, verbosity: {foo: 'bar'}}")),
+ DBException,
+ ErrorCodes::TypeMismatch);
}
TEST(ExplainTest, ParsingFailsIfVerbosityStringIsNotRecognized) {
- ASSERT_THROWS_CODE(ExplainCmd::parse(IDLParserErrorContext("explain"),
- fromjson("{explain: {}, verbosity: 'badVerbosity'}")),
- DBException,
- ErrorCodes::BadValue);
+ ASSERT_THROWS_CODE(
+ ExplainCommandRequest::parse(IDLParserErrorContext("explain"),
+ fromjson("{explain: {}, verbosity: 'badVerbosity'}")),
+ DBException,
+ ErrorCodes::BadValue);
}
TEST(ExplainTest, ParsingFailsIfFirstElementIsNotAnObject) {
- ASSERT_THROWS_CODE(ExplainCmd::parse(IDLParserErrorContext("explain"),
- fromjson("{explain: 1, verbosity: 'queryPlanner'}")),
- DBException,
- 40414);
+ ASSERT_THROWS_CODE(
+ ExplainCommandRequest::parse(IDLParserErrorContext("explain"),
+ fromjson("{explain: 1, verbosity: 'queryPlanner'}")),
+ DBException,
+ 40414);
}
TEST(ExplainTest, ParsingFailsIfUnknownFieldInCommandObject) {
ASSERT_THROWS_CODE(
- ExplainCmd::parse(IDLParserErrorContext("explain"),
- fromjson("{explain: {}, verbosity: 'queryPlanner', unknownField: true}")),
+ ExplainCommandRequest::parse(
+ IDLParserErrorContext("explain"),
+ fromjson("{explain: {}, verbosity: 'queryPlanner', unknownField: true}")),
DBException,
40415);
}
TEST(ExplainTest, CanParseGenericCommandArguments) {
- ExplainCmd::parse(
+ ExplainCommandRequest::parse(
IDLParserErrorContext("explain"),
fromjson("{explain: {}, verbosity: 'queryPlanner', comment: true, $db: 'test'}"));
}
diff --git a/src/mongo/db/keys_collection_cache_test.cpp b/src/mongo/db/keys_collection_cache_test.cpp
index 02204642c5a..3f5eccdd44a 100644
--- a/src/mongo/db/keys_collection_cache_test.cpp
+++ b/src/mongo/db/keys_collection_cache_test.cpp
@@ -80,7 +80,7 @@ protected:
const NamespaceString& nss,
const BSONObj& filter) {
auto cmdObj = [&] {
- write_ops::Delete deleteOp(nss);
+ write_ops::DeleteCommandRequest deleteOp(nss);
deleteOp.setDeletes({[&] {
write_ops::DeleteOpEntry entry;
entry.setQ(filter);
@@ -101,7 +101,7 @@ protected:
const BSONObj& filter,
const BSONObj& update) {
auto cmdObj = [&] {
- write_ops::Update updateOp(nss);
+ write_ops::UpdateCommandRequest updateOp(nss);
updateOp.setUpdates({[&] {
write_ops::UpdateOpEntry entry;
entry.setQ(filter);
diff --git a/src/mongo/db/keys_collection_client_direct.cpp b/src/mongo/db/keys_collection_client_direct.cpp
index 69f6fc471c0..30048be948b 100644
--- a/src/mongo/db/keys_collection_client_direct.cpp
+++ b/src/mongo/db/keys_collection_client_direct.cpp
@@ -165,7 +165,7 @@ Status KeysCollectionClientDirect::_insert(OperationContext* opCtx,
const BSONObj& doc,
const WriteConcernOptions& writeConcern) {
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
+ write_ops::InsertCommandRequest insertOp(nss);
insertOp.setDocuments({doc});
return insertOp;
}());
diff --git a/src/mongo/db/matcher/expression_optimize_test.cpp b/src/mongo/db/matcher/expression_optimize_test.cpp
index 2141c210a35..eaaf42e3e76 100644
--- a/src/mongo/db/matcher/expression_optimize_test.cpp
+++ b/src/mongo/db/matcher/expression_optimize_test.cpp
@@ -69,7 +69,7 @@ MatchExpression* parseMatchExpression(const BSONObj& obj) {
* (expression tree, query request) tuple passes CanonicalQuery::isValid().
* Returns Status::OK() if the tuple is valid, else returns an error Status.
*/
-Status isValid(const std::string& queryStr, const FindCommand& findCommand) {
+Status isValid(const std::string& queryStr, const FindCommandRequest& findCommand) {
BSONObj queryObj = fromjson(queryStr);
std::unique_ptr<MatchExpression> me(parseMatchExpression(queryObj));
me = MatchExpression::optimize(std::move(me));
@@ -77,9 +77,9 @@ Status isValid(const std::string& queryStr, const FindCommand& findCommand) {
}
TEST(ExpressionOptimizeTest, IsValidText) {
- // Filter inside FindCommand is not used.
- auto findCommand = std::make_unique<FindCommand>(nss);
- ASSERT_OK(query_request_helper::validateFindCommand(*findCommand));
+ // Filter inside FindCommandRequest is not used.
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(*findCommand));
// Valid: regular TEXT.
ASSERT_OK(isValid("{$text: {$search: 's'}}", *findCommand));
@@ -133,19 +133,19 @@ TEST(ExpressionOptimizeTest, IsValidText) {
}
TEST(ExpressionOptimizeTest, IsValidTextTailable) {
- // Filter inside FindCommand is not used.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ // Filter inside FindCommandRequest is not used.
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
query_request_helper::setTailableMode(TailableModeEnum::kTailable, findCommand.get());
- ASSERT_OK(query_request_helper::validateFindCommand(*findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(*findCommand));
// Invalid: TEXT and tailable.
ASSERT_NOT_OK(isValid("{$text: {$search: 's'}}", *findCommand));
}
TEST(ExpressionOptimizeTest, IsValidGeo) {
- // Filter inside FindCommand is not used.
- auto findCommand = std::make_unique<FindCommand>(nss);
- ASSERT_OK(query_request_helper::validateFindCommand(*findCommand));
+ // Filter inside FindCommandRequest is not used.
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(*findCommand));
// Valid: regular GEO_NEAR.
ASSERT_OK(isValid("{a: {$near: [0, 0]}}", *findCommand));
@@ -209,9 +209,9 @@ TEST(ExpressionOptimizeTest, IsValidGeo) {
}
TEST(ExpressionOptimizeTest, IsValidTextAndGeo) {
- // Filter inside FindCommand is not used.
- auto findCommand = std::make_unique<FindCommand>(nss);
- ASSERT_OK(query_request_helper::validateFindCommand(*findCommand));
+ // Filter inside FindCommandRequest is not used.
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(*findCommand));
// Invalid: TEXT and GEO_NEAR.
ASSERT_NOT_OK(isValid("{$text: {$search: 's'}, a: {$near: [0, 0]}}", *findCommand));
@@ -230,30 +230,30 @@ TEST(ExpressionOptimizeTest, IsValidTextAndGeo) {
}
TEST(ExpressionOptimizeTest, IsValidTextAndNaturalAscending) {
- // Filter inside FindCommand is not used.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ // Filter inside FindCommandRequest is not used.
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setSort(fromjson("{$natural: 1}"));
- ASSERT_OK(query_request_helper::validateFindCommand(*findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(*findCommand));
// Invalid: TEXT and {$natural: 1} sort order.
ASSERT_NOT_OK(isValid("{$text: {$search: 's'}}", *findCommand));
}
TEST(ExpressionOptimizeTest, IsValidTextAndNaturalDescending) {
- // Filter inside FindCommand is not used.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ // Filter inside FindCommandRequest is not used.
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setSort(fromjson("{$natural: -1}"));
- ASSERT_OK(query_request_helper::validateFindCommand(*findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(*findCommand));
// Invalid: TEXT and {$natural: -1} sort order.
ASSERT_NOT_OK(isValid("{$text: {$search: 's'}}", *findCommand));
}
TEST(ExpressionOptimizeTest, IsValidTextAndHint) {
- // Filter inside FindCommand is not used.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ // Filter inside FindCommandRequest is not used.
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setHint(fromjson("{a: 1}"));
- ASSERT_OK(query_request_helper::validateFindCommand(*findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(*findCommand));
// Invalid: TEXT and {$natural: -1} sort order.
ASSERT_NOT_OK(isValid("{$text: {$search: 's'}}", *findCommand));
@@ -261,10 +261,10 @@ TEST(ExpressionOptimizeTest, IsValidTextAndHint) {
// SERVER-14366
TEST(ExpressionOptimizeTest, IsValidGeoNearNaturalSort) {
- // Filter inside FindCommand is not used.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ // Filter inside FindCommandRequest is not used.
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setSort(fromjson("{$natural: 1}"));
- ASSERT_OK(query_request_helper::validateFindCommand(*findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(*findCommand));
// Invalid: GEO_NEAR and {$natural: 1} sort order.
ASSERT_NOT_OK(
@@ -273,10 +273,10 @@ TEST(ExpressionOptimizeTest, IsValidGeoNearNaturalSort) {
// SERVER-14366
TEST(ExpressionOptimizeTest, IsValidGeoNearNaturalHint) {
- // Filter inside FindCommand is not used.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ // Filter inside FindCommandRequest is not used.
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setHint(fromjson("{$natural: 1}"));
- ASSERT_OK(query_request_helper::validateFindCommand(*findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(*findCommand));
// Invalid: GEO_NEAR and {$natural: 1} hint.
ASSERT_NOT_OK(
diff --git a/src/mongo/db/ops/parsed_delete.cpp b/src/mongo/db/ops/parsed_delete.cpp
index 0837f51addc..5028ccde159 100644
--- a/src/mongo/db/ops/parsed_delete.cpp
+++ b/src/mongo/db/ops/parsed_delete.cpp
@@ -90,7 +90,7 @@ Status ParsedDelete::parseQueryToCQ() {
// The projection needs to be applied after the delete operation, so we do not specify a
// projection during canonicalization.
- auto findCommand = std::make_unique<FindCommand>(_request->getNsString());
+ auto findCommand = std::make_unique<FindCommandRequest>(_request->getNsString());
findCommand->setFilter(_request->getQuery().getOwned());
findCommand->setSort(_request->getSort().getOwned());
findCommand->setCollation(_request->getCollation().getOwned());
@@ -107,7 +107,7 @@ Status ParsedDelete::parseQueryToCQ() {
}
// If the delete request has runtime constants or let parameters attached to it, pass them to
- // the FindCommand.
+ // the FindCommandRequest.
if (auto& runtimeConstants = _request->getLegacyRuntimeConstants())
findCommand->setLegacyRuntimeConstants(*runtimeConstants);
if (auto& letParams = _request->getLet())
diff --git a/src/mongo/db/ops/parsed_update.cpp b/src/mongo/db/ops/parsed_update.cpp
index fbdc4e0a43e..f36bee843fb 100644
--- a/src/mongo/db/ops/parsed_update.cpp
+++ b/src/mongo/db/ops/parsed_update.cpp
@@ -122,7 +122,7 @@ Status ParsedUpdate::parseQueryToCQ() {
// The projection needs to be applied after the update operation, so we do not specify a
// projection during canonicalization.
- auto findCommand = std::make_unique<FindCommand>(_request->getNamespaceString());
+ auto findCommand = std::make_unique<FindCommandRequest>(_request->getNamespaceString());
findCommand->setFilter(_request->getQuery());
findCommand->setSort(_request->getSort());
findCommand->setHint(_request->getHint());
@@ -150,7 +150,7 @@ Status ParsedUpdate::parseQueryToCQ() {
}
// If the update request has runtime constants or let parameters attached to it, pass them to
- // the FindCommand.
+ // the FindCommandRequest.
if (auto& runtimeConstants = _request->getLegacyRuntimeConstants()) {
findCommand->setLegacyRuntimeConstants(*runtimeConstants);
}
diff --git a/src/mongo/db/ops/write_ops.cpp b/src/mongo/db/ops/write_ops.cpp
index ae6ba44727b..8e00f19713a 100644
--- a/src/mongo/db/ops/write_ops.cpp
+++ b/src/mongo/db/ops/write_ops.cpp
@@ -43,10 +43,10 @@
namespace mongo {
-using write_ops::Delete;
+using write_ops::DeleteCommandRequest;
using write_ops::DeleteOpEntry;
-using write_ops::Insert;
-using write_ops::Update;
+using write_ops::InsertCommandRequest;
+using write_ops::UpdateCommandRequest;
using write_ops::UpdateOpEntry;
namespace {
@@ -58,7 +58,7 @@ void checkOpCountForCommand(const T& op, size_t numOps) {
<< write_ops::kMaxWriteBatchSize << ". Got " << numOps << " operations.",
numOps != 0 && numOps <= write_ops::kMaxWriteBatchSize);
- if (const auto& stmtIds = op.getWriteCommandBase().getStmtIds()) {
+ if (const auto& stmtIds = op.getWriteCommandRequestBase().getStmtIds()) {
uassert(
ErrorCodes::InvalidLength,
str::stream() << "Number of statement ids must match the number of batch entries. Got "
@@ -68,10 +68,10 @@ void checkOpCountForCommand(const T& op, size_t numOps) {
stmtIds->size() == numOps);
uassert(ErrorCodes::InvalidOptions,
str::stream() << "May not specify both stmtId and stmtIds in write command. Got "
- << BSON("stmtId" << *op.getWriteCommandBase().getStmtId() << "stmtIds"
- << *stmtIds)
+ << BSON("stmtId" << *op.getWriteCommandRequestBase().getStmtId()
+ << "stmtIds" << *stmtIds)
<< ". Write command: " << redact(op.toBSON({})),
- !op.getWriteCommandBase().getStmtId());
+ !op.getWriteCommandRequestBase().getStmtId());
}
}
@@ -114,7 +114,7 @@ repl::OpTime opTimeParser(BSONElement elem) {
<< BSONType::bsonTimestamp << ", but found " << elem.type());
}
-int32_t getStmtIdForWriteAt(const WriteCommandBase& writeCommandBase, size_t writePos) {
+int32_t getStmtIdForWriteAt(const WriteCommandRequestBase& writeCommandBase, size_t writePos) {
const auto& stmtIds = writeCommandBase.getStmtIds();
if (stmtIds) {
@@ -128,23 +128,23 @@ int32_t getStmtIdForWriteAt(const WriteCommandBase& writeCommandBase, size_t wri
} // namespace write_ops
-write_ops::Insert InsertOp::parse(const OpMsgRequest& request) {
- auto insertOp = Insert::parse(IDLParserErrorContext("insert"), request);
+write_ops::InsertCommandRequest InsertOp::parse(const OpMsgRequest& request) {
+ auto insertOp = InsertCommandRequest::parse(IDLParserErrorContext("insert"), request);
validate(insertOp);
return insertOp;
}
-write_ops::Insert InsertOp::parseLegacy(const Message& msgRaw) {
+write_ops::InsertCommandRequest InsertOp::parseLegacy(const Message& msgRaw) {
DbMessage msg(msgRaw);
- Insert op(NamespaceString(msg.getns()));
+ InsertCommandRequest op(NamespaceString(msg.getns()));
{
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setBypassDocumentValidation(false);
writeCommandBase.setOrdered(!(msg.reservedField() & InsertOption_ContinueOnError));
- op.setWriteCommandBase(std::move(writeCommandBase));
+ op.setWriteCommandRequestBase(std::move(writeCommandBase));
}
uassert(ErrorCodes::InvalidLength, "Need at least one object to insert", msg.moreJSObjs());
@@ -162,28 +162,28 @@ write_ops::Insert InsertOp::parseLegacy(const Message& msgRaw) {
return op;
}
-void InsertOp::validate(const write_ops::Insert& insertOp) {
+void InsertOp::validate(const write_ops::InsertCommandRequest& insertOp) {
const auto& docs = insertOp.getDocuments();
checkOpCountForCommand(insertOp, docs.size());
}
-write_ops::Update UpdateOp::parse(const OpMsgRequest& request) {
- auto updateOp = Update::parse(IDLParserErrorContext("update"), request);
+write_ops::UpdateCommandRequest UpdateOp::parse(const OpMsgRequest& request) {
+ auto updateOp = UpdateCommandRequest::parse(IDLParserErrorContext("update"), request);
checkOpCountForCommand(updateOp, updateOp.getUpdates().size());
return updateOp;
}
-write_ops::Update UpdateOp::parseLegacy(const Message& msgRaw) {
+write_ops::UpdateCommandRequest UpdateOp::parseLegacy(const Message& msgRaw) {
DbMessage msg(msgRaw);
- Update op(NamespaceString(msg.getns()));
+ UpdateCommandRequest op(NamespaceString(msg.getns()));
{
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setBypassDocumentValidation(false);
writeCommandBase.setOrdered(true);
- op.setWriteCommandBase(std::move(writeCommandBase));
+ op.setWriteCommandRequestBase(std::move(writeCommandBase));
}
op.setUpdates([&] {
@@ -205,39 +205,40 @@ write_ops::Update UpdateOp::parseLegacy(const Message& msgRaw) {
return op;
}
-write_ops::UpdateReply UpdateOp::parseResponse(const BSONObj& obj) {
+write_ops::UpdateCommandReply UpdateOp::parseResponse(const BSONObj& obj) {
uassertStatusOK(getStatusFromCommandResult(obj));
- return write_ops::UpdateReply::parse(IDLParserErrorContext("updateReply"), obj);
+ return write_ops::UpdateCommandReply::parse(IDLParserErrorContext("updateReply"), obj);
}
-void UpdateOp::validate(const Update& updateOp) {
+void UpdateOp::validate(const UpdateCommandRequest& updateOp) {
checkOpCountForCommand(updateOp, updateOp.getUpdates().size());
}
-write_ops::FindAndModifyReply FindAndModifyOp::parseResponse(const BSONObj& obj) {
+write_ops::FindAndModifyCommandReply FindAndModifyOp::parseResponse(const BSONObj& obj) {
uassertStatusOK(getStatusFromCommandResult(obj));
- return write_ops::FindAndModifyReply::parse(IDLParserErrorContext("findAndModifyReply"), obj);
+ return write_ops::FindAndModifyCommandReply::parse(IDLParserErrorContext("findAndModifyReply"),
+ obj);
}
-write_ops::Delete DeleteOp::parse(const OpMsgRequest& request) {
- auto deleteOp = Delete::parse(IDLParserErrorContext("delete"), request);
+write_ops::DeleteCommandRequest DeleteOp::parse(const OpMsgRequest& request) {
+ auto deleteOp = DeleteCommandRequest::parse(IDLParserErrorContext("delete"), request);
checkOpCountForCommand(deleteOp, deleteOp.getDeletes().size());
return deleteOp;
}
-write_ops::Delete DeleteOp::parseLegacy(const Message& msgRaw) {
+write_ops::DeleteCommandRequest DeleteOp::parseLegacy(const Message& msgRaw) {
DbMessage msg(msgRaw);
- Delete op(NamespaceString(msg.getns()));
+ DeleteCommandRequest op(NamespaceString(msg.getns()));
{
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setBypassDocumentValidation(false);
writeCommandBase.setOrdered(true);
- op.setWriteCommandBase(std::move(writeCommandBase));
+ op.setWriteCommandRequestBase(std::move(writeCommandBase));
}
op.setDeletes([&] {
@@ -256,7 +257,7 @@ write_ops::Delete DeleteOp::parseLegacy(const Message& msgRaw) {
return op;
}
-void DeleteOp::validate(const Delete& deleteOp) {
+void DeleteOp::validate(const DeleteCommandRequest& deleteOp) {
checkOpCountForCommand(deleteOp, deleteOp.getDeletes().size());
}
diff --git a/src/mongo/db/ops/write_ops.h b/src/mongo/db/ops/write_ops.h
index ca1c2e8f429..5fa6651bad5 100644
--- a/src/mongo/db/ops/write_ops.h
+++ b/src/mongo/db/ops/write_ops.h
@@ -37,29 +37,29 @@ namespace mongo {
class InsertOp {
public:
- static write_ops::Insert parse(const OpMsgRequest& request);
- static write_ops::Insert parseLegacy(const Message& msg);
- static void validate(const write_ops::Insert& insertOp);
+ static write_ops::InsertCommandRequest parse(const OpMsgRequest& request);
+ static write_ops::InsertCommandRequest parseLegacy(const Message& msg);
+ static void validate(const write_ops::InsertCommandRequest& insertOp);
};
class UpdateOp {
public:
- static write_ops::Update parse(const OpMsgRequest& request);
- static write_ops::Update parseLegacy(const Message& msg);
- static write_ops::UpdateReply parseResponse(const BSONObj& obj);
- static void validate(const write_ops::Update& updateOp);
+ static write_ops::UpdateCommandRequest parse(const OpMsgRequest& request);
+ static write_ops::UpdateCommandRequest parseLegacy(const Message& msg);
+ static write_ops::UpdateCommandReply parseResponse(const BSONObj& obj);
+ static void validate(const write_ops::UpdateCommandRequest& updateOp);
};
class DeleteOp {
public:
- static write_ops::Delete parse(const OpMsgRequest& request);
- static write_ops::Delete parseLegacy(const Message& msg);
- static void validate(const write_ops::Delete& deleteOp);
+ static write_ops::DeleteCommandRequest parse(const OpMsgRequest& request);
+ static write_ops::DeleteCommandRequest parseLegacy(const Message& msg);
+ static void validate(const write_ops::DeleteCommandRequest& deleteOp);
};
class FindAndModifyOp {
public:
- static write_ops::FindAndModifyReply parseResponse(const BSONObj& obj);
+ static write_ops::FindAndModifyCommandReply parseResponse(const BSONObj& obj);
};
namespace write_ops {
@@ -77,11 +77,11 @@ constexpr size_t insertVectorMaxBytes = 256 * 1024;
* Retrieves the statement id for the write at the specified position in the write batch entries
* array.
*/
-int32_t getStmtIdForWriteAt(const WriteCommandBase& writeCommandBase, size_t writePos);
+int32_t getStmtIdForWriteAt(const WriteCommandRequestBase& writeCommandBase, size_t writePos);
template <class T>
int32_t getStmtIdForWriteAt(const T& op, size_t writePos) {
- return getStmtIdForWriteAt(op.getWriteCommandBase(), writePos);
+ return getStmtIdForWriteAt(op.getWriteCommandRequestBase(), writePos);
}
// TODO: Delete this getter once IDL supports defaults for object and array fields
diff --git a/src/mongo/db/ops/write_ops.idl b/src/mongo/db/ops/write_ops.idl
index 5a61affe924..23f22c361d6 100644
--- a/src/mongo/db/ops/write_ops.idl
+++ b/src/mongo/db/ops/write_ops.idl
@@ -66,7 +66,7 @@ types:
structs:
- WriteReplyBase:
+ WriteCommandReplyBase:
description: "Contains fields that is common in all the write commands reply."
fields:
n:
@@ -88,11 +88,11 @@ structs:
type: array<object_owned>
optional: true
- InsertReply:
+ InsertCommandReply:
description: "Contains information related to insert command reply."
chained_structs:
- WriteReplyBase: writeReplyBase
+ WriteCommandReplyBase: writeCommandReplyBase
Upserted:
description: "Contains documents that have been upserted."
@@ -104,7 +104,7 @@ structs:
description: "ID of the document."
type: IDLAnyTypeOwned
- UpdateReply:
+ UpdateCommandReply:
description: "Contains information related to update command reply."
strict: false
fields:
@@ -118,15 +118,15 @@ structs:
default: 0
chained_structs:
- WriteReplyBase: writeReplyBase
+ WriteCommandReplyBase: writeCommandReplyBase
- DeleteReply:
+ DeleteCommandReply:
description: "Contains information related to delete command reply."
chained_structs:
- WriteReplyBase: writeReplyBase
+ WriteCommandReplyBase: writeCommandReplyBase
- WriteCommandBase:
+ WriteCommandRequestBase:
description: "Contains basic information included by all write commands"
strict: false
fields:
@@ -245,7 +245,7 @@ structs:
description: "The _id of the inserted document."
optional: true
- FindAndModifyReply:
+ FindAndModifyCommandReply:
description: "Parser for the response from a `findAndModify` command"
strict: false
fields:
@@ -263,6 +263,7 @@ commands:
insert:
description: "Parser for the 'insert' command."
command_name: insert
+ cpp_name: InsertCommandRequest
strict: true
namespace: concatenate_with_db
api_version: "1"
@@ -271,9 +272,9 @@ commands:
privilege:
resource_pattern: exact_namespace
action_type: [bypassDocumentValidation, insert]
- reply_type: InsertReply
+ reply_type: InsertCommandReply
chained_structs:
- WriteCommandBase: writeCommandBase
+ WriteCommandRequestBase: writeCommandRequestBase
fields:
documents:
description: "An array of one or more documents to insert."
@@ -283,6 +284,7 @@ commands:
update:
description: "Parser for the 'update' command."
command_name: update
+ cpp_name: UpdateCommandRequest
strict: true
namespace: concatenate_with_db
api_version: "1"
@@ -291,9 +293,9 @@ commands:
privilege:
resource_pattern: exact_namespace
action_type: [bypassDocumentValidation, insert, update]
- reply_type: UpdateReply
+ reply_type: UpdateCommandReply
chained_structs:
- WriteCommandBase: writeCommandBase
+ WriteCommandRequestBase: writeCommandRequestBase
fields:
updates:
description: "An array of one or more update statements to perform."
@@ -314,6 +316,7 @@ commands:
delete:
description: "Parser for the 'delete' command."
command_name: delete
+ cpp_name: DeleteCommandRequest
strict: true
namespace: concatenate_with_db
api_version: "1"
@@ -322,9 +325,9 @@ commands:
privilege:
resource_pattern: exact_namespace
action_type: [bypassDocumentValidation, remove]
- reply_type: DeleteReply
+ reply_type: DeleteCommandReply
chained_structs:
- WriteCommandBase: writeCommandBase
+ WriteCommandRequestBase: writeCommandRequestBase
fields:
deletes:
description: "An array of one or more delete statements to perform."
@@ -345,7 +348,7 @@ commands:
description: "Parser for the 'findAndModify' command."
command_name: findAndModify
command_alias: findandmodify
- cpp_name: FindAndModifyCommand
+ cpp_name: FindAndModifyCommandRequest
strict: true
namespace: concatenate_with_db
api_version: "1"
@@ -354,7 +357,7 @@ commands:
privilege:
resource_pattern: exact_namespace
action_type: [bypassDocumentValidation, find, insert, update, remove]
- reply_type: FindAndModifyReply
+ reply_type: FindAndModifyCommandReply
fields:
query:
description: "The query that matches documents to update. Uses the same query
diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp
index b9e3c1e6883..d36103f03e0 100644
--- a/src/mongo/db/ops/write_ops_exec.cpp
+++ b/src/mongo/db/ops/write_ops_exec.cpp
@@ -243,7 +243,7 @@ void makeCollection(OperationContext* opCtx, const NamespaceString& ns) {
bool handleError(OperationContext* opCtx,
const DBException& ex,
const NamespaceString& nss,
- const write_ops::WriteCommandBase& wholeOp,
+ const write_ops::WriteCommandRequestBase& wholeOp,
bool isMultiUpdate,
WriteResult* out) {
LastError::get(opCtx->getClient()).setLastError(ex.code(), ex.reason());
@@ -376,7 +376,7 @@ Status checkIfTransactionOnCappedColl(OperationContext* opCtx, const CollectionP
* Returns true if caller should try to insert more documents. Does nothing else if batch is empty.
*/
bool insertBatchAndHandleErrors(OperationContext* opCtx,
- const write_ops::Insert& wholeOp,
+ const write_ops::InsertCommandRequest& wholeOp,
std::vector<InsertStatement>& batch,
LastOpFixer* lastOpFixer,
WriteResult* out,
@@ -440,7 +440,7 @@ bool insertBatchAndHandleErrors(OperationContext* opCtx,
auto canContinue = handleError(opCtx,
ex,
wholeOp.getNamespace(),
- wholeOp.getWriteCommandBase(),
+ wholeOp.getWriteCommandRequestBase(),
false /* multiUpdate */,
out);
invariant(!canContinue);
@@ -512,7 +512,7 @@ bool insertBatchAndHandleErrors(OperationContext* opCtx,
bool canContinue = handleError(opCtx,
ex,
wholeOp.getNamespace(),
- wholeOp.getWriteCommandBase(),
+ wholeOp.getWriteCommandRequestBase(),
false /* multiUpdate */,
out);
@@ -542,7 +542,7 @@ SingleWriteResult makeWriteResultForInsertOrDeleteRetry() {
} // namespace
WriteResult performInserts(OperationContext* opCtx,
- const write_ops::Insert& wholeOp,
+ const write_ops::InsertCommandRequest& wholeOp,
const OperationSource& source) {
// Insert performs its own retries, so we should only be within a WriteUnitOfWork when run in a
// transaction.
@@ -579,7 +579,7 @@ WriteResult performInserts(OperationContext* opCtx,
}
DisableDocumentSchemaValidationIfTrue docSchemaValidationDisabler(
- opCtx, wholeOp.getWriteCommandBase().getBypassDocumentValidation());
+ opCtx, wholeOp.getWriteCommandRequestBase().getBypassDocumentValidation());
LastOpFixer lastOpFixer(opCtx, wholeOp.getNamespace());
WriteResult out;
@@ -649,7 +649,7 @@ WriteResult performInserts(OperationContext* opCtx,
canContinue = handleError(opCtx,
ex,
wholeOp.getNamespace(),
- wholeOp.getWriteCommandBase(),
+ wholeOp.getWriteCommandRequestBase(),
false /* multiUpdate */,
&out);
}
@@ -835,7 +835,7 @@ static SingleWriteResult performSingleUpdateOpWithDupKeyRetry(
}
WriteResult performUpdates(OperationContext* opCtx,
- const write_ops::Update& wholeOp,
+ const write_ops::UpdateCommandRequest& wholeOp,
const OperationSource& source) {
// Update performs its own retries, so we should not be in a WriteUnitOfWork unless run in a
// transaction.
@@ -845,7 +845,7 @@ WriteResult performUpdates(OperationContext* opCtx,
uassertStatusOK(userAllowedWriteNS(opCtx, wholeOp.getNamespace()));
DisableDocumentSchemaValidationIfTrue docSchemaValidationDisabler(
- opCtx, wholeOp.getWriteCommandBase().getBypassDocumentValidation());
+ opCtx, wholeOp.getWriteCommandRequestBase().getBypassDocumentValidation());
LastOpFixer lastOpFixer(opCtx, wholeOp.getNamespace());
bool containsRetry = false;
@@ -904,7 +904,7 @@ WriteResult performUpdates(OperationContext* opCtx,
const bool canContinue = handleError(opCtx,
ex,
wholeOp.getNamespace(),
- wholeOp.getWriteCommandBase(),
+ wholeOp.getWriteCommandRequestBase(),
singleOp.getMulti(),
&out);
if (!canContinue)
@@ -1006,7 +1006,8 @@ static SingleWriteResult performSingleDeleteOp(OperationContext* opCtx,
return result;
}
-WriteResult performDeletes(OperationContext* opCtx, const write_ops::Delete& wholeOp) {
+WriteResult performDeletes(OperationContext* opCtx,
+ const write_ops::DeleteCommandRequest& wholeOp) {
// Delete performs its own retries, so we should not be in a WriteUnitOfWork unless we are in a
// transaction.
auto txnParticipant = TransactionParticipant::get(opCtx);
@@ -1015,7 +1016,7 @@ WriteResult performDeletes(OperationContext* opCtx, const write_ops::Delete& who
uassertStatusOK(userAllowedWriteNS(opCtx, wholeOp.getNamespace()));
DisableDocumentSchemaValidationIfTrue docSchemaValidationDisabler(
- opCtx, wholeOp.getWriteCommandBase().getBypassDocumentValidation());
+ opCtx, wholeOp.getWriteCommandRequestBase().getBypassDocumentValidation());
LastOpFixer lastOpFixer(opCtx, wholeOp.getNamespace());
bool containsRetry = false;
@@ -1075,7 +1076,7 @@ WriteResult performDeletes(OperationContext* opCtx, const write_ops::Delete& who
const bool canContinue = handleError(opCtx,
ex,
wholeOp.getNamespace(),
- wholeOp.getWriteCommandBase(),
+ wholeOp.getWriteCommandRequestBase(),
false /* multiUpdate */,
&out);
if (!canContinue)
diff --git a/src/mongo/db/ops/write_ops_exec.h b/src/mongo/db/ops/write_ops_exec.h
index 87196b1345e..efe2e6663ac 100644
--- a/src/mongo/db/ops/write_ops_exec.h
+++ b/src/mongo/db/ops/write_ops_exec.h
@@ -75,12 +75,12 @@ struct WriteResult {
* and initial sync/tenant migration oplog buffer) inserts.
*/
WriteResult performInserts(OperationContext* opCtx,
- const write_ops::Insert& op,
+ const write_ops::InsertCommandRequest& op,
const OperationSource& source = OperationSource::kStandard);
WriteResult performUpdates(OperationContext* opCtx,
- const write_ops::Update& op,
+ const write_ops::UpdateCommandRequest& op,
const OperationSource& source = OperationSource::kStandard);
-WriteResult performDeletes(OperationContext* opCtx, const write_ops::Delete& op);
+WriteResult performDeletes(OperationContext* opCtx, const write_ops::DeleteCommandRequest& op);
/**
* Populate 'opDebug' with stats describing the execution of an update operation. Illegal to call
diff --git a/src/mongo/db/ops/write_ops_parsers_test.cpp b/src/mongo/db/ops/write_ops_parsers_test.cpp
index f7f8e631f47..5dbba6205d6 100644
--- a/src/mongo/db/ops/write_ops_parsers_test.cpp
+++ b/src/mongo/db/ops/write_ops_parsers_test.cpp
@@ -48,7 +48,7 @@ TEST(CommandWriteOpsParsers, CommonFields_BypassDocumentValidation) {
for (bool seq : {false, true}) {
auto request = toOpMsg("foo", cmd, seq);
auto op = InsertOp::parse(request);
- ASSERT_EQ(op.getWriteCommandBase().getBypassDocumentValidation(),
+ ASSERT_EQ(op.getWriteCommandRequestBase().getBypassDocumentValidation(),
shouldBypassDocumentValidationForCommand(cmd));
}
}
@@ -62,7 +62,7 @@ TEST(CommandWriteOpsParsers, CommonFields_Ordered) {
for (bool seq : {false, true}) {
auto request = toOpMsg("foo", cmd, seq);
auto op = InsertOp::parse(request);
- ASSERT_EQ(op.getWriteCommandBase().getOrdered(), ordered);
+ ASSERT_EQ(op.getWriteCommandRequestBase().getOrdered(), ordered);
}
}
}
@@ -213,8 +213,8 @@ TEST(CommandWriteOpsParsers, SingleInsert) {
auto request = toOpMsg(ns.db(), cmd, seq);
const auto op = InsertOp::parse(request);
ASSERT_EQ(op.getNamespace().ns(), ns.ns());
- ASSERT(!op.getWriteCommandBase().getBypassDocumentValidation());
- ASSERT(op.getWriteCommandBase().getOrdered());
+ ASSERT(!op.getWriteCommandRequestBase().getBypassDocumentValidation());
+ ASSERT(op.getWriteCommandRequestBase().getOrdered());
ASSERT_EQ(op.getDocuments().size(), 1u);
ASSERT_BSONOBJ_EQ(op.getDocuments()[0], obj);
}
@@ -238,8 +238,8 @@ TEST(CommandWriteOpsParsers, RealMultiInsert) {
auto request = toOpMsg(ns.db(), cmd, seq);
const auto op = InsertOp::parse(request);
ASSERT_EQ(op.getNamespace().ns(), ns.ns());
- ASSERT(!op.getWriteCommandBase().getBypassDocumentValidation());
- ASSERT(op.getWriteCommandBase().getOrdered());
+ ASSERT(!op.getWriteCommandRequestBase().getBypassDocumentValidation());
+ ASSERT(op.getWriteCommandRequestBase().getOrdered());
ASSERT_EQ(op.getDocuments().size(), 2u);
ASSERT_BSONOBJ_EQ(op.getDocuments()[0], obj0);
ASSERT_BSONOBJ_EQ(op.getDocuments()[1], obj1);
@@ -258,8 +258,8 @@ TEST(CommandWriteOpsParsers, MultiInsertWithStmtId) {
auto request = toOpMsg(ns.db(), cmd, seq);
const auto op = InsertOp::parse(request);
ASSERT_EQ(op.getNamespace().ns(), ns.ns());
- ASSERT(!op.getWriteCommandBase().getBypassDocumentValidation());
- ASSERT(op.getWriteCommandBase().getOrdered());
+ ASSERT(!op.getWriteCommandRequestBase().getBypassDocumentValidation());
+ ASSERT(op.getWriteCommandRequestBase().getOrdered());
ASSERT_EQ(op.getDocuments().size(), 2u);
ASSERT_BSONOBJ_EQ(op.getDocuments()[0], obj0);
ASSERT_BSONOBJ_EQ(op.getDocuments()[1], obj1);
@@ -278,8 +278,8 @@ TEST(CommandWriteOpsParsers, MultiInsertWithStmtIdsArray) {
auto request = toOpMsg(ns.db(), cmd, seq);
const auto op = InsertOp::parse(request);
ASSERT_EQ(op.getNamespace().ns(), ns.ns());
- ASSERT(!op.getWriteCommandBase().getBypassDocumentValidation());
- ASSERT(op.getWriteCommandBase().getOrdered());
+ ASSERT(!op.getWriteCommandRequestBase().getBypassDocumentValidation());
+ ASSERT(op.getWriteCommandRequestBase().getOrdered());
ASSERT_EQ(op.getDocuments().size(), 2u);
ASSERT_BSONOBJ_EQ(op.getDocuments()[0], obj0);
ASSERT_BSONOBJ_EQ(op.getDocuments()[1], obj1);
@@ -288,7 +288,7 @@ TEST(CommandWriteOpsParsers, MultiInsertWithStmtIdsArray) {
}
}
-TEST(CommandWriteOpsParsers, Update) {
+TEST(CommandWriteOpsParsers, UpdateCommandRequest) {
const auto ns = NamespaceString("test", "foo");
const BSONObj query = BSON("x" << 1);
const BSONObj update = BSON("$inc" << BSON("x" << 1));
@@ -305,8 +305,8 @@ TEST(CommandWriteOpsParsers, Update) {
auto request = toOpMsg(ns.db(), cmd, seq);
auto op = UpdateOp::parse(request);
ASSERT_EQ(op.getNamespace().ns(), ns.ns());
- ASSERT(!op.getWriteCommandBase().getBypassDocumentValidation());
- ASSERT_EQ(op.getWriteCommandBase().getOrdered(), true);
+ ASSERT(!op.getWriteCommandRequestBase().getBypassDocumentValidation());
+ ASSERT_EQ(op.getWriteCommandRequestBase().getOrdered(), true);
ASSERT_EQ(op.getUpdates().size(), 1u);
ASSERT_BSONOBJ_EQ(op.getUpdates()[0].getQ(), query);
@@ -342,8 +342,8 @@ TEST(CommandWriteOpsParsers, UpdateWithPipeline) {
auto request = toOpMsg(ns.db(), cmd, seq);
auto op = UpdateOp::parse(request);
ASSERT_EQ(op.getNamespace().ns(), ns.ns());
- ASSERT(!op.getWriteCommandBase().getBypassDocumentValidation());
- ASSERT_EQ(op.getWriteCommandBase().getOrdered(), true);
+ ASSERT(!op.getWriteCommandRequestBase().getBypassDocumentValidation());
+ ASSERT_EQ(op.getWriteCommandRequestBase().getOrdered(), true);
ASSERT_EQ(op.getUpdates().size(), 1u);
ASSERT_BSONOBJ_EQ(op.getUpdates()[0].getQ(), query["q"].Obj());
@@ -375,8 +375,8 @@ TEST(CommandWriteOpsParsers, Remove) {
auto request = toOpMsg(ns.db(), cmd, seq);
auto op = DeleteOp::parse(request);
ASSERT_EQ(op.getNamespace().ns(), ns.ns());
- ASSERT(!op.getWriteCommandBase().getBypassDocumentValidation());
- ASSERT_EQ(op.getWriteCommandBase().getOrdered(), true);
+ ASSERT(!op.getWriteCommandRequestBase().getBypassDocumentValidation());
+ ASSERT_EQ(op.getWriteCommandRequestBase().getOrdered(), true);
ASSERT_EQ(op.getDeletes().size(), 1u);
ASSERT_BSONOBJ_EQ(op.getDeletes()[0].getQ(), query);
ASSERT_BSONOBJ_EQ(write_ops::collationOf(op.getDeletes()[0]), collation);
@@ -408,8 +408,8 @@ TEST(LegacyWriteOpsParsers, SingleInsert) {
makeInsertMessage(ns, obj, continueOnError ? InsertOption_ContinueOnError : 0);
const auto op = InsertOp::parseLegacy(message);
ASSERT_EQ(op.getNamespace().ns(), ns);
- ASSERT(!op.getWriteCommandBase().getBypassDocumentValidation());
- ASSERT_EQ(!op.getWriteCommandBase().getOrdered(), continueOnError);
+ ASSERT(!op.getWriteCommandRequestBase().getBypassDocumentValidation());
+ ASSERT_EQ(!op.getWriteCommandRequestBase().getOrdered(), continueOnError);
ASSERT_EQ(op.getDocuments().size(), 1u);
ASSERT_BSONOBJ_EQ(op.getDocuments()[0], obj);
}
@@ -436,15 +436,15 @@ TEST(LegacyWriteOpsParsers, RealMultiInsert) {
ns, objs.data(), objs.size(), continueOnError ? InsertOption_ContinueOnError : 0);
const auto op = InsertOp::parseLegacy(message);
ASSERT_EQ(op.getNamespace().ns(), ns);
- ASSERT(!op.getWriteCommandBase().getBypassDocumentValidation());
- ASSERT_EQ(!op.getWriteCommandBase().getOrdered(), continueOnError);
+ ASSERT(!op.getWriteCommandRequestBase().getBypassDocumentValidation());
+ ASSERT_EQ(!op.getWriteCommandRequestBase().getOrdered(), continueOnError);
ASSERT_EQ(op.getDocuments().size(), 2u);
ASSERT_BSONOBJ_EQ(op.getDocuments()[0], obj0);
ASSERT_BSONOBJ_EQ(op.getDocuments()[1], obj1);
}
}
-TEST(LegacyWriteOpsParsers, Update) {
+TEST(LegacyWriteOpsParsers, UpdateCommandRequest) {
const std::string ns = "test.foo";
const BSONObj query = BSON("x" << 1);
const BSONObj update = BSON("$inc" << BSON("x" << 1));
@@ -457,8 +457,8 @@ TEST(LegacyWriteOpsParsers, Update) {
(multi ? UpdateOption_Multi : 0));
const auto op = UpdateOp::parseLegacy(message);
ASSERT_EQ(op.getNamespace().ns(), ns);
- ASSERT(!op.getWriteCommandBase().getBypassDocumentValidation());
- ASSERT_EQ(op.getWriteCommandBase().getOrdered(), true);
+ ASSERT(!op.getWriteCommandRequestBase().getBypassDocumentValidation());
+ ASSERT_EQ(op.getWriteCommandRequestBase().getOrdered(), true);
ASSERT_EQ(op.getUpdates().size(), 1u);
ASSERT_BSONOBJ_EQ(op.getUpdates()[0].getQ(), query);
ASSERT_BSONOBJ_EQ(op.getUpdates()[0].getU().getUpdateClassic(), update);
@@ -485,8 +485,8 @@ TEST(LegacyWriteOpsParsers, UpdateWithArrayUpdateFieldIsParsedAsReplacementStyle
(multi ? UpdateOption_Multi : 0));
const auto op = UpdateOp::parseLegacy(message);
ASSERT_EQ(op.getNamespace().ns(), ns);
- ASSERT(!op.getWriteCommandBase().getBypassDocumentValidation());
- ASSERT_EQ(op.getWriteCommandBase().getOrdered(), true);
+ ASSERT(!op.getWriteCommandRequestBase().getBypassDocumentValidation());
+ ASSERT_EQ(op.getWriteCommandRequestBase().getOrdered(), true);
ASSERT_EQ(op.getUpdates().size(), 1u);
ASSERT_BSONOBJ_EQ(op.getUpdates()[0].getQ(), query);
ASSERT(op.getUpdates()[0].getU().type() ==
@@ -505,8 +505,8 @@ TEST(LegacyWriteOpsParsers, Remove) {
auto message = makeRemoveMessage(ns, query, (multi ? 0 : RemoveOption_JustOne));
const auto op = DeleteOp::parseLegacy(message);
ASSERT_EQ(op.getNamespace().ns(), ns);
- ASSERT(!op.getWriteCommandBase().getBypassDocumentValidation());
- ASSERT_EQ(op.getWriteCommandBase().getOrdered(), true);
+ ASSERT(!op.getWriteCommandRequestBase().getBypassDocumentValidation());
+ ASSERT_EQ(op.getWriteCommandRequestBase().getOrdered(), true);
ASSERT_EQ(op.getDeletes().size(), 1u);
ASSERT_BSONOBJ_EQ(op.getDeletes()[0].getQ(), query);
ASSERT_EQ(op.getDeletes()[0].getMulti(), multi);
diff --git a/src/mongo/db/ops/write_ops_retryability.cpp b/src/mongo/db/ops/write_ops_retryability.cpp
index bf52941e959..1237cf41596 100644
--- a/src/mongo/db/ops/write_ops_retryability.cpp
+++ b/src/mongo/db/ops/write_ops_retryability.cpp
@@ -45,7 +45,7 @@ namespace {
* In the case of nested oplog entry where the correct links are in the top level
* oplog, oplogWithCorrectLinks can be used to specify the outer oplog.
*/
-void validateFindAndModifyRetryability(const write_ops::FindAndModifyCommand& request,
+void validateFindAndModifyRetryability(const write_ops::FindAndModifyCommandRequest& request,
const repl::OplogEntry& oplogEntry,
const repl::OplogEntry& oplogWithCorrectLinks) {
auto opType = oplogEntry.getOpType();
@@ -128,14 +128,14 @@ BSONObj extractPreOrPostImage(OperationContext* opCtx, const repl::OplogEntry& o
* previous execution of the command. In the case of nested oplog entry where the correct links
* are in the top level oplog, oplogWithCorrectLinks can be used to specify the outer oplog.
*/
-write_ops::FindAndModifyReply parseOplogEntryForFindAndModify(
+write_ops::FindAndModifyCommandReply parseOplogEntryForFindAndModify(
OperationContext* opCtx,
- const write_ops::FindAndModifyCommand& request,
+ const write_ops::FindAndModifyCommandRequest& request,
const repl::OplogEntry& oplogEntry,
const repl::OplogEntry& oplogWithCorrectLinks) {
validateFindAndModifyRetryability(request, oplogEntry, oplogWithCorrectLinks);
- write_ops::FindAndModifyReply result;
+ write_ops::FindAndModifyCommandReply result;
write_ops::FindAndModifyLastError lastError;
lastError.setNumDocs(1);
@@ -206,9 +206,9 @@ SingleWriteResult parseOplogEntryForUpdate(const repl::OplogEntry& entry) {
return res;
}
-write_ops::FindAndModifyReply parseOplogEntryForFindAndModify(
+write_ops::FindAndModifyCommandReply parseOplogEntryForFindAndModify(
OperationContext* opCtx,
- const write_ops::FindAndModifyCommand& request,
+ const write_ops::FindAndModifyCommandRequest& request,
const repl::OplogEntry& oplogEntry) {
// Migrated op case.
if (oplogEntry.getOpType() == repl::OpTypeEnum::kNoop) {
diff --git a/src/mongo/db/ops/write_ops_retryability.h b/src/mongo/db/ops/write_ops_retryability.h
index 5726864ddcb..dd59b412475 100644
--- a/src/mongo/db/ops/write_ops_retryability.h
+++ b/src/mongo/db/ops/write_ops_retryability.h
@@ -50,9 +50,9 @@ SingleWriteResult parseOplogEntryForUpdate(const repl::OplogEntry& entry);
* Populates the passed-in builder with the result of a findAndModify based on the oplog entries
* generated by the operation.
*/
-write_ops::FindAndModifyReply parseOplogEntryForFindAndModify(
+write_ops::FindAndModifyCommandReply parseOplogEntryForFindAndModify(
OperationContext* opCtx,
- const write_ops::FindAndModifyCommand& request,
+ const write_ops::FindAndModifyCommandRequest& request,
const repl::OplogEntry& oplogEntry);
} // namespace mongo
diff --git a/src/mongo/db/ops/write_ops_retryability_test.cpp b/src/mongo/db/ops/write_ops_retryability_test.cpp
index 4aa7f3a4748..2d209dbfebb 100644
--- a/src/mongo/db/ops/write_ops_retryability_test.cpp
+++ b/src/mongo/db/ops/write_ops_retryability_test.cpp
@@ -99,9 +99,9 @@ void setUpTxnParticipant(OperationContext* opCtx, std::vector<int> executedStmtI
txnPart.setCommittedStmtIdsForTest(std::move(executedStmtIds));
}
-write_ops::FindAndModifyCommand makeFindAndModifyRequest(
+write_ops::FindAndModifyCommandRequest makeFindAndModifyRequest(
NamespaceString fullNs, BSONObj query, boost::optional<write_ops::UpdateModification> update) {
- auto request = write_ops::FindAndModifyCommand(fullNs);
+ auto request = write_ops::FindAndModifyCommandRequest(fullNs);
request.setQuery(query);
if (update) {
request.setUpdate(std::move(update));
@@ -192,8 +192,8 @@ TEST_F(WriteOpsRetryability, PerformInsertsSuccess) {
repl::UnreplicatedWritesBlock unreplicated(opCtxRaii.get());
setUpReplication(getServiceContext());
- write_ops::Insert insertOp(NamespaceString("foo.bar"));
- insertOp.getWriteCommandBase().setOrdered(true);
+ write_ops::InsertCommandRequest insertOp(NamespaceString("foo.bar"));
+ insertOp.getWriteCommandRequestBase().setOrdered(true);
insertOp.setDocuments({BSON("_id" << 0), BSON("_id" << 1)});
write_ops_exec::WriteResult result = write_ops_exec::performInserts(opCtxRaii.get(), insertOp);
@@ -213,12 +213,12 @@ TEST_F(WriteOpsRetryability, PerformRetryableInsertsSuccess) {
// Set up a retryable write where statements 1 and 2 have already executed.
setUpTxnParticipant(opCtxRaii.get(), {1, 2});
- write_ops::Insert insertOp(NamespaceString("foo.bar"));
- insertOp.getWriteCommandBase().setOrdered(true);
+ write_ops::InsertCommandRequest insertOp(NamespaceString("foo.bar"));
+ insertOp.getWriteCommandRequestBase().setOrdered(true);
// Setup documents that cannot be successfully inserted to show that the retryable logic was
// exercised.
insertOp.setDocuments({BSON("_id" << 0), BSON("_id" << 0)});
- insertOp.getWriteCommandBase().setStmtIds({{1, 2}});
+ insertOp.getWriteCommandRequestBase().setStmtIds({{1, 2}});
write_ops_exec::WriteResult result = write_ops_exec::performInserts(opCtxRaii.get(), insertOp);
// Assert that both writes "succeeded". While there should have been a duplicate key error, the
@@ -240,11 +240,11 @@ TEST_F(WriteOpsRetryability, PerformRetryableInsertsWithBatchedFailure) {
// Set up a retryable write where statement 3 has already executed.
setUpTxnParticipant(opCtxRaii.get(), {3});
- write_ops::Insert insertOp(NamespaceString("foo.bar"));
- insertOp.getWriteCommandBase().setOrdered(false);
+ write_ops::InsertCommandRequest insertOp(NamespaceString("foo.bar"));
+ insertOp.getWriteCommandRequestBase().setOrdered(false);
// Setup documents such that the second will fail insertion.
insertOp.setDocuments({BSON("_id" << 0), BSON("_id" << 0), BSON("_id" << 1)});
- insertOp.getWriteCommandBase().setStmtIds({{1, 2, 3}});
+ insertOp.getWriteCommandRequestBase().setStmtIds({{1, 2, 3}});
write_ops_exec::WriteResult result = write_ops_exec::performInserts(opCtxRaii.get(), insertOp);
// Assert that the third (already executed) write succeeds, despite the second write failing
@@ -264,8 +264,8 @@ TEST_F(WriteOpsRetryability, PerformOrderedInsertsStopsAtError) {
repl::UnreplicatedWritesBlock unreplicated(opCtxRaii.get());
setUpReplication(getServiceContext());
- write_ops::Insert insertOp(NamespaceString("foo.bar"));
- insertOp.getWriteCommandBase().setOrdered(true);
+ write_ops::InsertCommandRequest insertOp(NamespaceString("foo.bar"));
+ insertOp.getWriteCommandRequestBase().setOrdered(true);
// Setup documents such that the second cannot be successfully inserted.
insertOp.setDocuments({BSON("_id" << 0), BSON("_id" << 0), BSON("_id" << 1)});
write_ops_exec::WriteResult result = write_ops_exec::performInserts(opCtxRaii.get(), insertOp);
@@ -285,8 +285,8 @@ TEST_F(WriteOpsRetryability, PerformOrderedInsertsStopsAtBadDoc) {
repl::UnreplicatedWritesBlock unreplicated(opCtxRaii.get());
setUpReplication(getServiceContext());
- write_ops::Insert insertOp(NamespaceString("foo.bar"));
- insertOp.getWriteCommandBase().setOrdered(true);
+ write_ops::InsertCommandRequest insertOp(NamespaceString("foo.bar"));
+ insertOp.getWriteCommandRequestBase().setOrdered(true);
// Setup documents such that the second cannot be successfully inserted.
auto largeBuffer = [](std::int32_t size) {
@@ -317,8 +317,8 @@ TEST_F(WriteOpsRetryability, PerformUnorderedInsertsContinuesAtBadDoc) {
repl::UnreplicatedWritesBlock unreplicated(opCtxRaii.get());
setUpReplication(getServiceContext());
- write_ops::Insert insertOp(NamespaceString("foo.bar"));
- insertOp.getWriteCommandBase().setOrdered(false);
+ write_ops::InsertCommandRequest insertOp(NamespaceString("foo.bar"));
+ insertOp.getWriteCommandRequestBase().setOrdered(false);
// Setup documents such that the second cannot be successfully inserted.
auto largeBuffer = [](std::int32_t size) {
diff --git a/src/mongo/db/persistent_task_store.h b/src/mongo/db/persistent_task_store.h
index 74e806e0a88..cef18c359c4 100644
--- a/src/mongo/db/persistent_task_store.h
+++ b/src/mongo/db/persistent_task_store.h
@@ -65,7 +65,7 @@ public:
DBDirectClient dbClient(opCtx);
const auto commandResponse = dbClient.runCommand([&] {
- write_ops::Insert insertOp(_storageNss);
+ write_ops::InsertCommandRequest insertOp(_storageNss);
insertOp.setDocuments({task.toBSON()});
return insertOp.serialize({});
}());
@@ -109,7 +109,7 @@ public:
DBDirectClient dbClient(opCtx);
auto commandResponse = dbClient.runCommand([&] {
- write_ops::Delete deleteOp(_storageNss);
+ write_ops::DeleteCommandRequest deleteOp(_storageNss);
deleteOp.setDeletes({[&] {
write_ops::DeleteOpEntry entry;
@@ -172,7 +172,7 @@ private:
DBDirectClient dbClient(opCtx);
auto commandResponse = dbClient.runCommand([&] {
- write_ops::Update updateOp(_storageNss);
+ write_ops::UpdateCommandRequest updateOp(_storageNss);
auto updateModification = write_ops::UpdateModification::parseFromClassicUpdate(update);
write_ops::UpdateOpEntry updateEntry(query.obj, updateModification);
updateEntry.setMulti(false);
diff --git a/src/mongo/db/pipeline/aggregate_command.idl b/src/mongo/db/pipeline/aggregate_command.idl
index ddbe35f7389..1146df571e3 100644
--- a/src/mongo/db/pipeline/aggregate_command.idl
+++ b/src/mongo/db/pipeline/aggregate_command.idl
@@ -65,7 +65,7 @@ types:
commands:
aggregate:
description: "Represents the user-supplied options to the aggregate command."
- cpp_name: AggregateCommand
+ cpp_name: AggregateCommandRequest
command_name: aggregate
strict: true
namespace: concatenate_with_db
diff --git a/src/mongo/db/pipeline/aggregation_request_helper.cpp b/src/mongo/db/pipeline/aggregation_request_helper.cpp
index d710e73597a..133e151dae6 100644
--- a/src/mongo/db/pipeline/aggregation_request_helper.cpp
+++ b/src/mongo/db/pipeline/aggregation_request_helper.cpp
@@ -53,14 +53,14 @@ void validate(const BSONObj& cmdObj,
const NamespaceString& nss,
boost::optional<ExplainOptions::Verbosity> explainVerbosity);
-AggregateCommand parseFromBSON(const std::string& dbName,
- const BSONObj& cmdObj,
- boost::optional<ExplainOptions::Verbosity> explainVerbosity,
- bool apiStrict) {
+AggregateCommandRequest parseFromBSON(const std::string& dbName,
+ const BSONObj& cmdObj,
+ boost::optional<ExplainOptions::Verbosity> explainVerbosity,
+ bool apiStrict) {
return parseFromBSON(parseNs(dbName, cmdObj), cmdObj, explainVerbosity, apiStrict);
}
-StatusWith<AggregateCommand> parseFromBSONForTests(
+StatusWith<AggregateCommandRequest> parseFromBSONForTests(
NamespaceString nss,
const BSONObj& cmdObj,
boost::optional<ExplainOptions::Verbosity> explainVerbosity,
@@ -72,7 +72,7 @@ StatusWith<AggregateCommand> parseFromBSONForTests(
}
}
-StatusWith<AggregateCommand> parseFromBSONForTests(
+StatusWith<AggregateCommandRequest> parseFromBSONForTests(
const std::string& dbName,
const BSONObj& cmdObj,
boost::optional<ExplainOptions::Verbosity> explainVerbosity,
@@ -84,30 +84,30 @@ StatusWith<AggregateCommand> parseFromBSONForTests(
}
}
-AggregateCommand parseFromBSON(NamespaceString nss,
- const BSONObj& cmdObj,
- boost::optional<ExplainOptions::Verbosity> explainVerbosity,
- bool apiStrict) {
+AggregateCommandRequest parseFromBSON(NamespaceString nss,
+ const BSONObj& cmdObj,
+ boost::optional<ExplainOptions::Verbosity> explainVerbosity,
+ bool apiStrict) {
// if the command object lacks field 'aggregate' or '$db', we will use the namespace in 'nss'.
bool cmdObjChanged = false;
- auto cmdObjBob = BSONObjBuilder{BSON(AggregateCommand::kCommandName << nss.coll())};
- if (!cmdObj.hasField(AggregateCommand::kCommandName) ||
- !cmdObj.hasField(AggregateCommand::kDbNameFieldName)) {
+ auto cmdObjBob = BSONObjBuilder{BSON(AggregateCommandRequest::kCommandName << nss.coll())};
+ if (!cmdObj.hasField(AggregateCommandRequest::kCommandName) ||
+ !cmdObj.hasField(AggregateCommandRequest::kDbNameFieldName)) {
cmdObjBob.append("$db", nss.db());
cmdObjBob.appendElementsUnique(cmdObj);
cmdObjChanged = true;
}
- AggregateCommand request(nss);
- request = AggregateCommand::parse(IDLParserErrorContext("aggregate", apiStrict),
- cmdObjChanged ? cmdObjBob.obj() : cmdObj);
+ AggregateCommandRequest request(nss);
+ request = AggregateCommandRequest::parse(IDLParserErrorContext("aggregate", apiStrict),
+ cmdObjChanged ? cmdObjBob.obj() : cmdObj);
if (explainVerbosity) {
uassert(ErrorCodes::FailedToParse,
- str::stream() << "The '" << AggregateCommand::kExplainFieldName
+ str::stream() << "The '" << AggregateCommandRequest::kExplainFieldName
<< "' option is illegal when a explain verbosity is also provided",
- !cmdObj.hasField(AggregateCommand::kExplainFieldName));
+ !cmdObj.hasField(AggregateCommandRequest::kExplainFieldName));
request.setExplain(explainVerbosity);
}
@@ -141,29 +141,29 @@ NamespaceString parseNs(const std::string& dbname, const BSONObj& cmdObj) {
}
}
-BSONObj serializeToCommandObj(const AggregateCommand& request) {
+BSONObj serializeToCommandObj(const AggregateCommandRequest& request) {
return request.toBSON(BSONObj());
}
-Document serializeToCommandDoc(const AggregateCommand& request) {
+Document serializeToCommandDoc(const AggregateCommandRequest& request) {
return Document(request.toBSON(BSONObj()).getOwned());
}
void validate(const BSONObj& cmdObj,
const NamespaceString& nss,
boost::optional<ExplainOptions::Verbosity> explainVerbosity) {
- bool hasAllowDiskUseElem = cmdObj.hasField(AggregateCommand::kAllowDiskUseFieldName);
- bool hasCursorElem = cmdObj.hasField(AggregateCommand::kCursorFieldName);
- bool hasExplainElem = cmdObj.hasField(AggregateCommand::kExplainFieldName);
- bool hasExplain =
- explainVerbosity || (hasExplainElem && cmdObj[AggregateCommand::kExplainFieldName].Bool());
- bool hasFromMongosElem = cmdObj.hasField(AggregateCommand::kFromMongosFieldName);
- bool hasNeedsMergeElem = cmdObj.hasField(AggregateCommand::kNeedsMergeFieldName);
+ bool hasAllowDiskUseElem = cmdObj.hasField(AggregateCommandRequest::kAllowDiskUseFieldName);
+ bool hasCursorElem = cmdObj.hasField(AggregateCommandRequest::kCursorFieldName);
+ bool hasExplainElem = cmdObj.hasField(AggregateCommandRequest::kExplainFieldName);
+ bool hasExplain = explainVerbosity ||
+ (hasExplainElem && cmdObj[AggregateCommandRequest::kExplainFieldName].Bool());
+ bool hasFromMongosElem = cmdObj.hasField(AggregateCommandRequest::kFromMongosFieldName);
+ bool hasNeedsMergeElem = cmdObj.hasField(AggregateCommandRequest::kNeedsMergeFieldName);
// 'hasExplainElem' implies an aggregate command-level explain option, which does not require
// a cursor argument.
uassert(ErrorCodes::FailedToParse,
- str::stream() << "The '" << AggregateCommand::kCursorFieldName
+ str::stream() << "The '" << AggregateCommandRequest::kCursorFieldName
<< "' option is required, except for aggregate with the explain argument",
hasCursorElem || hasExplainElem);
@@ -173,30 +173,31 @@ void validate(const BSONObj& cmdObj,
!hasExplain || !cmdObj[WriteConcernOptions::kWriteConcernField]);
uassert(ErrorCodes::FailedToParse,
- str::stream() << "Cannot specify '" << AggregateCommand::kNeedsMergeFieldName
- << "' without '" << AggregateCommand::kFromMongosFieldName << "'",
+ str::stream() << "Cannot specify '" << AggregateCommandRequest::kNeedsMergeFieldName
+ << "' without '" << AggregateCommandRequest::kFromMongosFieldName << "'",
(!hasNeedsMergeElem || hasFromMongosElem));
uassert(ErrorCodes::IllegalOperation,
- str::stream() << "The '" << AggregateCommand::kAllowDiskUseFieldName
+ str::stream() << "The '" << AggregateCommandRequest::kAllowDiskUseFieldName
<< "' option is not permitted in read-only mode.",
(!hasAllowDiskUseElem || !storageGlobalParams.readOnly));
auto requestReshardingResumeTokenElem =
- cmdObj[AggregateCommand::kRequestReshardingResumeTokenFieldName];
+ cmdObj[AggregateCommandRequest::kRequestReshardingResumeTokenFieldName];
uassert(ErrorCodes::FailedToParse,
- str::stream() << AggregateCommand::kRequestReshardingResumeTokenFieldName
+ str::stream() << AggregateCommandRequest::kRequestReshardingResumeTokenFieldName
<< " must be a boolean type",
!requestReshardingResumeTokenElem || requestReshardingResumeTokenElem.isBoolean());
bool hasRequestReshardingResumeToken =
requestReshardingResumeTokenElem && requestReshardingResumeTokenElem.boolean();
uassert(ErrorCodes::FailedToParse,
- str::stream() << AggregateCommand::kRequestReshardingResumeTokenFieldName
+ str::stream() << AggregateCommandRequest::kRequestReshardingResumeTokenFieldName
<< " must only be set for the oplog namespace, not " << nss,
!hasRequestReshardingResumeToken || nss.isOplog());
}
-void validateRequestForAPIVersion(const OperationContext* opCtx, const AggregateCommand& request) {
+void validateRequestForAPIVersion(const OperationContext* opCtx,
+ const AggregateCommandRequest& request) {
invariant(opCtx);
auto apiParameters = APIParameters::get(opCtx);
@@ -221,7 +222,7 @@ void validateRequestForAPIVersion(const OperationContext* opCtx, const Aggregate
}
}
-PlanExecutorPipeline::ResumableScanType getResumableScanType(const AggregateCommand& request,
+PlanExecutorPipeline::ResumableScanType getResumableScanType(const AggregateCommandRequest& request,
bool isChangeStream) {
// $changeStream cannot be run on the oplog, and $_requestReshardingResumeToken can only be run
// on the oplog. An aggregation request with both should therefore never reach this point.
@@ -238,7 +239,7 @@ PlanExecutorPipeline::ResumableScanType getResumableScanType(const AggregateComm
}
} // namespace aggregation_request_helper
-// Custom serializers/deserializers for AggregateCommand.
+// Custom serializers/deserializers for AggregateCommandRequest.
boost::optional<mongo::ExplainOptions::Verbosity> parseExplainModeFromBSON(
const BSONElement& explainElem) {
@@ -258,7 +259,7 @@ void serializeExplainToBSON(const mongo::ExplainOptions::Verbosity& explain,
BSONObjBuilder* builder) {
// Note that we do not serialize 'explain' field to the command object. This serializer only
// serializes an empty cursor object for field 'cursor' when it is an explain command.
- builder->append(AggregateCommand::kCursorFieldName, BSONObj());
+ builder->append(AggregateCommandRequest::kCursorFieldName, BSONObj());
return;
}
@@ -274,8 +275,9 @@ mongo::SimpleCursorOptions parseAggregateCursorFromBSON(const BSONElement& curso
"cursor field must be missing or an object",
cursorElem.type() == mongo::Object);
- SimpleCursorOptions cursor = SimpleCursorOptions::parse(
- IDLParserErrorContext(AggregateCommand::kCursorFieldName), cursorElem.embeddedObject());
+ SimpleCursorOptions cursor =
+ SimpleCursorOptions::parse(IDLParserErrorContext(AggregateCommandRequest::kCursorFieldName),
+ cursorElem.embeddedObject());
if (!cursor.getBatchSize())
cursor.setBatchSize(aggregation_request_helper::kDefaultBatchSize);
diff --git a/src/mongo/db/pipeline/aggregation_request_helper.h b/src/mongo/db/pipeline/aggregation_request_helper.h
index 2b2ec150e39..631fd87a278 100644
--- a/src/mongo/db/pipeline/aggregation_request_helper.h
+++ b/src/mongo/db/pipeline/aggregation_request_helper.h
@@ -48,32 +48,32 @@ namespace mongo {
template <typename T>
class StatusWith;
class Document;
-class AggregateCommand;
+class AggregateCommandRequest;
class OperationContext;
namespace aggregation_request_helper {
/**
- * Helpers to serialize/deserialize AggregateCommand.
+ * Helpers to serialize/deserialize AggregateCommandRequest.
*/
static constexpr StringData kBatchSizeField = "batchSize"_sd;
static constexpr long long kDefaultBatchSize = 101;
/**
- * Create a new instance of AggregateCommand by parsing the raw command object. Throws an exception
- * if a required field was missing, if there was an unrecognized field name, or if there was a bad
- * value for one of the fields.
+ * Create a new instance of AggregateCommandRequest by parsing the raw command object. Throws an
+ * exception if a required field was missing, if there was an unrecognized field name, or if there
+ * was a bad value for one of the fields.
*
* If we are parsing a request for an explained aggregation with an explain verbosity provided,
* then 'explainVerbosity' contains this information. In this case, 'cmdObj' may not itself
* contain the explain specifier. Otherwise, 'explainVerbosity' should be boost::none.
*/
-AggregateCommand parseFromBSON(NamespaceString nss,
- const BSONObj& cmdObj,
- boost::optional<ExplainOptions::Verbosity> explainVerbosity,
- bool apiStrict);
+AggregateCommandRequest parseFromBSON(NamespaceString nss,
+ const BSONObj& cmdObj,
+ boost::optional<ExplainOptions::Verbosity> explainVerbosity,
+ bool apiStrict);
-StatusWith<AggregateCommand> parseFromBSONForTests(
+StatusWith<AggregateCommandRequest> parseFromBSONForTests(
NamespaceString nss,
const BSONObj& cmdObj,
boost::optional<ExplainOptions::Verbosity> explainVerbosity = boost::none,
@@ -83,12 +83,12 @@ StatusWith<AggregateCommand> parseFromBSONForTests(
* Convenience overload which constructs the request's NamespaceString from the given database
* name and command object.
*/
-AggregateCommand parseFromBSON(const std::string& dbName,
- const BSONObj& cmdObj,
- boost::optional<ExplainOptions::Verbosity> explainVerbosity,
- bool apiStrict);
+AggregateCommandRequest parseFromBSON(const std::string& dbName,
+ const BSONObj& cmdObj,
+ boost::optional<ExplainOptions::Verbosity> explainVerbosity,
+ bool apiStrict);
-StatusWith<AggregateCommand> parseFromBSONForTests(
+StatusWith<AggregateCommandRequest> parseFromBSONForTests(
const std::string& dbName,
const BSONObj& cmdObj,
boost::optional<ExplainOptions::Verbosity> explainVerbosity = boost::none,
@@ -110,26 +110,27 @@ NamespaceString parseNs(const std::string& dbname, const BSONObj& cmdObj);
* command, like: {explain: {aggregate: ...}, ...}, explain options are not part of the aggregate
* command object.
*/
-Document serializeToCommandDoc(const AggregateCommand& request);
+Document serializeToCommandDoc(const AggregateCommandRequest& request);
-BSONObj serializeToCommandObj(const AggregateCommand& request);
+BSONObj serializeToCommandObj(const AggregateCommandRequest& request);
/**
- * Validates if 'AggregateCommand' specs complies with API versioning. Throws uassert in case of
- * any failure.
+ * Validates if 'AggregateCommandRequest' specs complies with API versioning. Throws uassert in case
+ * of any failure.
*/
-void validateRequestForAPIVersion(const OperationContext* opCtx, const AggregateCommand& request);
+void validateRequestForAPIVersion(const OperationContext* opCtx,
+ const AggregateCommandRequest& request);
/**
* Returns the type of resumable scan required by this aggregation, if applicable. Otherwise returns
* ResumableScanType::kNone.
*/
-PlanExecutorPipeline::ResumableScanType getResumableScanType(const AggregateCommand& request,
+PlanExecutorPipeline::ResumableScanType getResumableScanType(const AggregateCommandRequest& request,
bool isChangeStream);
} // namespace aggregation_request_helper
/**
- * Custom serializers/deserializers for AggregateCommand.
+ * Custom serializers/deserializers for AggregateCommandRequest.
*/
boost::optional<mongo::ExplainOptions::Verbosity> parseExplainModeFromBSON(
diff --git a/src/mongo/db/pipeline/aggregation_request_test.cpp b/src/mongo/db/pipeline/aggregation_request_test.cpp
index 0ad194bfc9f..66bac44423c 100644
--- a/src/mongo/db/pipeline/aggregation_request_test.cpp
+++ b/src/mongo/db/pipeline/aggregation_request_test.cpp
@@ -69,7 +69,7 @@ TEST(AggregationRequestTest, ShouldParseAllKnownOptions) {
"'local'}");
auto uuid = UUID::gen();
BSONObjBuilder uuidBob;
- uuid.appendToBuilder(&uuidBob, AggregateCommand::kCollectionUUIDFieldName);
+ uuid.appendToBuilder(&uuidBob, AggregateCommandRequest::kCollectionUUIDFieldName);
inputBson = inputBson.addField(uuidBob.obj().firstElement());
auto request =
@@ -176,19 +176,19 @@ TEST(AggregationRequestTest, ShouldParseExplainFlagWithReadConcern) {
TEST(AggregationRequestTest, ShouldOnlySerializeRequiredFieldsIfNoOptionalFieldsAreSpecified) {
NamespaceString nss("a.collection");
- AggregateCommand request(nss, {});
+ AggregateCommandRequest request(nss, {});
auto expectedSerialization =
- Document{{AggregateCommand::kCommandName, nss.coll()},
- {AggregateCommand::kPipelineFieldName, std::vector<Value>{}},
- {AggregateCommand::kCursorFieldName, Value(kDefaultCursorOptionDocument)}};
+ Document{{AggregateCommandRequest::kCommandName, nss.coll()},
+ {AggregateCommandRequest::kPipelineFieldName, std::vector<Value>{}},
+ {AggregateCommandRequest::kCursorFieldName, Value(kDefaultCursorOptionDocument)}};
ASSERT_DOCUMENT_EQ(aggregation_request_helper::serializeToCommandDoc(request),
expectedSerialization);
}
TEST(AggregationRequestTest, ShouldSerializeOptionalValuesIfSet) {
NamespaceString nss("a.collection");
- AggregateCommand request(nss, {});
+ AggregateCommandRequest request(nss, {});
request.setAllowDiskUse(true);
request.setFromMongos(true);
request.setNeedsMerge(true);
@@ -216,50 +216,50 @@ TEST(AggregationRequestTest, ShouldSerializeOptionalValuesIfSet) {
auto uuid = UUID::gen();
request.setCollectionUUID(uuid);
- auto expectedSerialization =
- Document{{AggregateCommand::kCommandName, nss.coll()},
- {AggregateCommand::kPipelineFieldName, std::vector<Value>{}},
- {AggregateCommand::kAllowDiskUseFieldName, true},
- {AggregateCommand::kCursorFieldName, Value(Document({{kBatchSizeFieldName, 10}}))},
- {query_request_helper::cmdOptionMaxTimeMS, 10},
- {AggregateCommand::kBypassDocumentValidationFieldName, true},
- {repl::ReadConcernArgs::kReadConcernFieldName, readConcernObj},
- {AggregateCommand::kCollationFieldName, collationObj},
- {AggregateCommand::kHintFieldName, hintObj},
- {AggregateCommand::kLetFieldName, letParamsObj},
- {AggregateCommand::kNeedsMergeFieldName, true},
- {AggregateCommand::kFromMongosFieldName, true},
- {query_request_helper::kUnwrappedReadPrefField, readPrefObj},
- {AggregateCommand::kRequestReshardingResumeTokenFieldName, true},
- {AggregateCommand::kIsMapReduceCommandFieldName, true},
- {AggregateCommand::kCollectionUUIDFieldName, uuid}};
+ auto expectedSerialization = Document{
+ {AggregateCommandRequest::kCommandName, nss.coll()},
+ {AggregateCommandRequest::kPipelineFieldName, std::vector<Value>{}},
+ {AggregateCommandRequest::kAllowDiskUseFieldName, true},
+ {AggregateCommandRequest::kCursorFieldName, Value(Document({{kBatchSizeFieldName, 10}}))},
+ {query_request_helper::cmdOptionMaxTimeMS, 10},
+ {AggregateCommandRequest::kBypassDocumentValidationFieldName, true},
+ {repl::ReadConcernArgs::kReadConcernFieldName, readConcernObj},
+ {AggregateCommandRequest::kCollationFieldName, collationObj},
+ {AggregateCommandRequest::kHintFieldName, hintObj},
+ {AggregateCommandRequest::kLetFieldName, letParamsObj},
+ {AggregateCommandRequest::kNeedsMergeFieldName, true},
+ {AggregateCommandRequest::kFromMongosFieldName, true},
+ {query_request_helper::kUnwrappedReadPrefField, readPrefObj},
+ {AggregateCommandRequest::kRequestReshardingResumeTokenFieldName, true},
+ {AggregateCommandRequest::kIsMapReduceCommandFieldName, true},
+ {AggregateCommandRequest::kCollectionUUIDFieldName, uuid}};
ASSERT_DOCUMENT_EQ(aggregation_request_helper::serializeToCommandDoc(request),
expectedSerialization);
}
TEST(AggregationRequestTest, ShouldSerializeBatchSizeIfSetAndExplainFalse) {
NamespaceString nss("a.collection");
- AggregateCommand request(nss, {});
+ AggregateCommandRequest request(nss, {});
SimpleCursorOptions cursor;
cursor.setBatchSize(10);
request.setCursor(cursor);
auto expectedSerialization = Document{
- {AggregateCommand::kCommandName, nss.coll()},
- {AggregateCommand::kPipelineFieldName, std::vector<Value>{}},
- {AggregateCommand::kCursorFieldName, Value(Document({{kBatchSizeFieldName, 10}}))}};
+ {AggregateCommandRequest::kCommandName, nss.coll()},
+ {AggregateCommandRequest::kPipelineFieldName, std::vector<Value>{}},
+ {AggregateCommandRequest::kCursorFieldName, Value(Document({{kBatchSizeFieldName, 10}}))}};
ASSERT_DOCUMENT_EQ(aggregation_request_helper::serializeToCommandDoc(request),
expectedSerialization);
}
TEST(AggregationRequestTest, ShouldSerialiseAggregateFieldToOneIfCollectionIsAggregateOneNSS) {
NamespaceString nss = NamespaceString::makeCollectionlessAggregateNSS("a");
- AggregateCommand request(nss, {});
+ AggregateCommandRequest request(nss, {});
auto expectedSerialization =
- Document{{AggregateCommand::kCommandName, 1},
- {AggregateCommand::kPipelineFieldName, std::vector<Value>{}},
- {AggregateCommand::kCursorFieldName,
+ Document{{AggregateCommandRequest::kCommandName, 1},
+ {AggregateCommandRequest::kPipelineFieldName, std::vector<Value>{}},
+ {AggregateCommandRequest::kCursorFieldName,
Value(Document({{aggregation_request_helper::kBatchSizeField,
aggregation_request_helper::kDefaultBatchSize}}))}};
@@ -292,16 +292,16 @@ TEST(AggregationRequestTest, ShouldAcceptHintAsString) {
TEST(AggregationRequestTest, ShouldNotSerializeBatchSizeWhenExplainSet) {
NamespaceString nss("a.collection");
- AggregateCommand request(nss, {});
+ AggregateCommandRequest request(nss, {});
SimpleCursorOptions cursor;
cursor.setBatchSize(10);
request.setCursor(cursor);
request.setExplain(ExplainOptions::Verbosity::kQueryPlanner);
auto expectedSerialization =
- Document{{AggregateCommand::kCommandName, nss.coll()},
- {AggregateCommand::kPipelineFieldName, std::vector<Value>{}},
- {AggregateCommand::kCursorFieldName, Value(Document())}};
+ Document{{AggregateCommandRequest::kCommandName, nss.coll()},
+ {AggregateCommandRequest::kPipelineFieldName, std::vector<Value>{}},
+ {AggregateCommandRequest::kCursorFieldName, Value(Document())}};
ASSERT_DOCUMENT_EQ(aggregation_request_helper::serializeToCommandDoc(request),
expectedSerialization);
}
@@ -320,8 +320,8 @@ BSONObj constructInvalidRequest(const BSONObj& validRequest, const BSONObj& inva
// An aggregate command expects the first field in the request to be 'aggregate'. As such, we
// pull out the aggregate field from whichever BSONObj supplied it and append it before any
// other fields.
- auto validAggregateField = validRequest.getField(AggregateCommand::kCommandName);
- auto invalidAggregateField = invalidFields.getField(AggregateCommand::kCommandName);
+ auto validAggregateField = validRequest.getField(AggregateCommandRequest::kCommandName);
+ auto invalidAggregateField = invalidFields.getField(AggregateCommandRequest::kCommandName);
if (!invalidAggregateField.eoo()) {
invalidRequestBuilder.append(invalidAggregateField);
} else {
@@ -730,7 +730,7 @@ TEST(AggregationRequestTest, ShouldRejectInvalidCollectionUUID) {
auto uuid = UUID::gen();
BSONObjBuilder validRequestBuilder(
fromjson("{aggregate: 'collection', cursor: {}, pipeline: [{$match: {}}], $db: 'a'}"));
- uuid.appendToBuilder(&validRequestBuilder, AggregateCommand::kCollectionUUIDFieldName);
+ uuid.appendToBuilder(&validRequestBuilder, AggregateCommandRequest::kCollectionUUIDFieldName);
const BSONObj validRequest = validRequestBuilder.done();
const BSONObj invalidCollectionUUID = fromjson("{collectionUUID: 2}");
aggregationRequestParseFailureHelper(
diff --git a/src/mongo/db/pipeline/dispatch_shard_pipeline_test.cpp b/src/mongo/db/pipeline/dispatch_shard_pipeline_test.cpp
index 8f21cad7337..1a79b972817 100644
--- a/src/mongo/db/pipeline/dispatch_shard_pipeline_test.cpp
+++ b/src/mongo/db/pipeline/dispatch_shard_pipeline_test.cpp
@@ -52,8 +52,8 @@ TEST_F(DispatchShardPipelineTest, DoesNotSplitPipelineIfTargetingOneShard) {
};
auto pipeline = Pipeline::create(
{parseStage(stages[0]), parseStage(stages[1]), parseStage(stages[2])}, expCtx());
- const Document serializedCommand =
- aggregation_request_helper::serializeToCommandDoc(AggregateCommand(expCtx()->ns, stages));
+ const Document serializedCommand = aggregation_request_helper::serializeToCommandDoc(
+ AggregateCommandRequest(expCtx()->ns, stages));
const bool hasChangeStream = false;
auto future = launchAsync([&] {
@@ -83,8 +83,8 @@ TEST_F(DispatchShardPipelineTest, DoesSplitPipelineIfMatchSpansTwoShards) {
};
auto pipeline = Pipeline::create(
{parseStage(stages[0]), parseStage(stages[1]), parseStage(stages[2])}, expCtx());
- const Document serializedCommand =
- aggregation_request_helper::serializeToCommandDoc(AggregateCommand(expCtx()->ns, stages));
+ const Document serializedCommand = aggregation_request_helper::serializeToCommandDoc(
+ AggregateCommandRequest(expCtx()->ns, stages));
const bool hasChangeStream = false;
auto future = launchAsync([&] {
@@ -117,8 +117,8 @@ TEST_F(DispatchShardPipelineTest, DispatchShardPipelineRetriesOnNetworkError) {
};
auto pipeline = Pipeline::create(
{parseStage(stages[0]), parseStage(stages[1]), parseStage(stages[2])}, expCtx());
- const Document serializedCommand =
- aggregation_request_helper::serializeToCommandDoc(AggregateCommand(expCtx()->ns, stages));
+ const Document serializedCommand = aggregation_request_helper::serializeToCommandDoc(
+ AggregateCommandRequest(expCtx()->ns, stages));
const bool hasChangeStream = false;
auto future = launchAsync([&] {
// Shouldn't throw.
@@ -162,8 +162,8 @@ TEST_F(DispatchShardPipelineTest, DispatchShardPipelineDoesNotRetryOnStaleConfig
};
auto pipeline = Pipeline::create(
{parseStage(stages[0]), parseStage(stages[1]), parseStage(stages[2])}, expCtx());
- const Document serializedCommand =
- aggregation_request_helper::serializeToCommandDoc(AggregateCommand(expCtx()->ns, stages));
+ const Document serializedCommand = aggregation_request_helper::serializeToCommandDoc(
+ AggregateCommandRequest(expCtx()->ns, stages));
const bool hasChangeStream = false;
auto future = launchAsync([&] {
ASSERT_THROWS_CODE(sharded_agg_helpers::dispatchShardPipeline(
@@ -191,8 +191,8 @@ TEST_F(DispatchShardPipelineTest, WrappedDispatchDoesRetryOnStaleConfigError) {
};
auto pipeline = Pipeline::create(
{parseStage(stages[0]), parseStage(stages[1]), parseStage(stages[2])}, expCtx());
- const Document serializedCommand =
- aggregation_request_helper::serializeToCommandDoc(AggregateCommand(expCtx()->ns, stages));
+ const Document serializedCommand = aggregation_request_helper::serializeToCommandDoc(
+ AggregateCommandRequest(expCtx()->ns, stages));
const bool hasChangeStream = false;
auto future = launchAsync([&] {
// Shouldn't throw.
diff --git a/src/mongo/db/pipeline/document_source.h b/src/mongo/db/pipeline/document_source.h
index 2fec3915f13..89e4c9d6905 100644
--- a/src/mongo/db/pipeline/document_source.h
+++ b/src/mongo/db/pipeline/document_source.h
@@ -66,7 +66,7 @@ class Document;
/**
* Registers a DocumentSource to have the name 'key'.
*
- * 'liteParser' takes an AggregateCommand and a BSONElement and returns a
+ * 'liteParser' takes an AggregateCommandRequest and a BSONElement and returns a
* LiteParsedDocumentSource. This is used for checks that need to happen before a full parse,
* such as checks about which namespaces are referenced by this aggregation.
*
diff --git a/src/mongo/db/pipeline/document_source_change_stream.cpp b/src/mongo/db/pipeline/document_source_change_stream.cpp
index d1e51781de3..ce63dd27df2 100644
--- a/src/mongo/db/pipeline/document_source_change_stream.cpp
+++ b/src/mongo/db/pipeline/document_source_change_stream.cpp
@@ -516,7 +516,7 @@ list<intrusive_ptr<DocumentSource>> DocumentSourceChangeStream::createFromBson(
BSONObj DocumentSourceChangeStream::replaceResumeTokenInCommand(BSONObj originalCmdObj,
Document resumeToken) {
Document originalCmd(originalCmdObj);
- auto pipeline = originalCmd[AggregateCommand::kPipelineFieldName].getArray();
+ auto pipeline = originalCmd[AggregateCommandRequest::kPipelineFieldName].getArray();
// A $changeStream must be the first element of the pipeline in order to be able
// to replace (or add) a resume token.
invariant(!pipeline[0][DocumentSourceChangeStream::kStageName].missing());
@@ -531,7 +531,7 @@ BSONObj DocumentSourceChangeStream::replaceResumeTokenInCommand(BSONObj original
pipeline[0] =
Value(Document{{DocumentSourceChangeStream::kStageName, changeStreamStage.freeze()}});
MutableDocument newCmd(std::move(originalCmd));
- newCmd[AggregateCommand::kPipelineFieldName] = Value(pipeline);
+ newCmd[AggregateCommandRequest::kPipelineFieldName] = Value(pipeline);
return newCmd.freeze().toBson();
}
diff --git a/src/mongo/db/pipeline/document_source_group_test.cpp b/src/mongo/db/pipeline/document_source_group_test.cpp
index 6ce0d370318..de6252449eb 100644
--- a/src/mongo/db/pipeline/document_source_group_test.cpp
+++ b/src/mongo/db/pipeline/document_source_group_test.cpp
@@ -257,7 +257,7 @@ public:
Base()
: _opCtx(makeOperationContext()),
_ctx(new ExpressionContextForTest(_opCtx.get(),
- AggregateCommand(NamespaceString(ns), {}))),
+ AggregateCommandRequest(NamespaceString(ns), {}))),
_tempDir("DocumentSourceGroupTest") {}
protected:
@@ -265,8 +265,8 @@ protected:
BSONObj namedSpec = BSON("$group" << spec);
BSONElement specElement = namedSpec.firstElement();
- intrusive_ptr<ExpressionContextForTest> expressionContext =
- new ExpressionContextForTest(_opCtx.get(), AggregateCommand(NamespaceString(ns), {}));
+ intrusive_ptr<ExpressionContextForTest> expressionContext = new ExpressionContextForTest(
+ _opCtx.get(), AggregateCommandRequest(NamespaceString(ns), {}));
// For $group, 'inShard' implies 'fromMongos' and 'needsMerge'.
expressionContext->fromMongos = expressionContext->needsMerge = inShard;
expressionContext->inMongos = inMongos;
diff --git a/src/mongo/db/pipeline/document_source_unwind_test.cpp b/src/mongo/db/pipeline/document_source_unwind_test.cpp
index fa4519a6832..aa8a550ec06 100644
--- a/src/mongo/db/pipeline/document_source_unwind_test.cpp
+++ b/src/mongo/db/pipeline/document_source_unwind_test.cpp
@@ -72,7 +72,7 @@ public:
: _queryServiceContext(std::make_unique<QueryTestServiceContext>()),
_opCtx(_queryServiceContext->makeOperationContext()),
_ctx(new ExpressionContextForTest(_opCtx.get(),
- AggregateCommand(NamespaceString(ns), {}))) {}
+ AggregateCommandRequest(NamespaceString(ns), {}))) {}
virtual ~CheckResultsBase() {}
diff --git a/src/mongo/db/pipeline/expression_context.cpp b/src/mongo/db/pipeline/expression_context.cpp
index d3c4d149593..3dcc420e976 100644
--- a/src/mongo/db/pipeline/expression_context.cpp
+++ b/src/mongo/db/pipeline/expression_context.cpp
@@ -47,7 +47,7 @@ ExpressionContext::ResolvedNamespace::ResolvedNamespace(NamespaceString ns,
: ns(std::move(ns)), pipeline(std::move(pipeline)) {}
ExpressionContext::ExpressionContext(OperationContext* opCtx,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
std::unique_ptr<CollatorInterface> collator,
std::shared_ptr<MongoProcessInterface> processInterface,
StringMap<ResolvedNamespace> resolvedNamespaces,
diff --git a/src/mongo/db/pipeline/expression_context.h b/src/mongo/db/pipeline/expression_context.h
index d483834be18..8e2be4cdb2b 100644
--- a/src/mongo/db/pipeline/expression_context.h
+++ b/src/mongo/db/pipeline/expression_context.h
@@ -56,7 +56,7 @@
namespace mongo {
-class AggregateCommand;
+class AggregateCommandRequest;
class ExpressionContext : public RefCountable {
public:
@@ -104,7 +104,7 @@ public:
* 'resolvedNamespaces' maps collection names (not full namespaces) to ResolvedNamespaces.
*/
ExpressionContext(OperationContext* opCtx,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
std::unique_ptr<CollatorInterface> collator,
std::shared_ptr<MongoProcessInterface> mongoProcessInterface,
StringMap<ExpressionContext::ResolvedNamespace> resolvedNamespaces,
@@ -113,7 +113,7 @@ public:
/**
* Constructs an ExpressionContext to be used for Pipeline parsing and evaluation. This version
- * requires finer-grained parameters but does not require an AggregateCommand.
+ * requires finer-grained parameters but does not require an AggregateCommandRequest.
* 'resolvedNamespaces' maps collection names (not full namespaces) to ResolvedNamespaces.
*/
ExpressionContext(OperationContext* opCtx,
diff --git a/src/mongo/db/pipeline/expression_context_for_test.h b/src/mongo/db/pipeline/expression_context_for_test.h
index 85d8dbf7bde..6cd98445d8f 100644
--- a/src/mongo/db/pipeline/expression_context_for_test.h
+++ b/src/mongo/db/pipeline/expression_context_for_test.h
@@ -141,7 +141,7 @@ public:
* Constructor which sets the given OperationContext on the ExpressionContextForTest. This will
* also resolve the ExpressionContextForTest's ServiceContext from the OperationContext.
*/
- ExpressionContextForTest(OperationContext* opCtx, const AggregateCommand& request)
+ ExpressionContextForTest(OperationContext* opCtx, const AggregateCommandRequest& request)
: ExpressionContext(
opCtx, request, nullptr, std::make_shared<StubMongoProcessInterface>(), {}, {}),
_serviceContext(opCtx->getServiceContext()) {
diff --git a/src/mongo/db/pipeline/expression_walker_test.cpp b/src/mongo/db/pipeline/expression_walker_test.cpp
index 0a227bbe884..6f4945c8628 100644
--- a/src/mongo/db/pipeline/expression_walker_test.cpp
+++ b/src/mongo/db/pipeline/expression_walker_test.cpp
@@ -55,7 +55,7 @@ protected:
ASSERT_EQUALS(inputBson["pipeline"].type(), BSONType::Array);
auto rawPipeline = parsePipelineFromBSON(inputBson["pipeline"]);
NamespaceString testNss("test", "collection");
- auto command = AggregateCommand{testNss, rawPipeline};
+ auto command = AggregateCommandRequest{testNss, rawPipeline};
return Pipeline::parse(command.getPipeline(), getExpCtx());
}
diff --git a/src/mongo/db/pipeline/lite_parsed_pipeline.h b/src/mongo/db/pipeline/lite_parsed_pipeline.h
index 01aff5cf78b..be9601150e0 100644
--- a/src/mongo/db/pipeline/lite_parsed_pipeline.h
+++ b/src/mongo/db/pipeline/lite_parsed_pipeline.h
@@ -53,7 +53,7 @@ public:
* May throw a AssertionException if there is an invalid stage specification, although full
* validation happens later, during Pipeline construction.
*/
- LiteParsedPipeline(const AggregateCommand& request)
+ LiteParsedPipeline(const AggregateCommandRequest& request)
: LiteParsedPipeline(request.getNamespace(), request.getPipeline()) {}
LiteParsedPipeline(const NamespaceString& nss, const std::vector<BSONObj>& pipelineStages) {
diff --git a/src/mongo/db/pipeline/pipeline_d.cpp b/src/mongo/db/pipeline/pipeline_d.cpp
index 3c964246093..1750ce38027 100644
--- a/src/mongo/db/pipeline/pipeline_d.cpp
+++ b/src/mongo/db/pipeline/pipeline_d.cpp
@@ -89,7 +89,7 @@ using boost::intrusive_ptr;
using std::shared_ptr;
using std::string;
using std::unique_ptr;
-using write_ops::Insert;
+using write_ops::InsertCommandRequest;
namespace {
/**
@@ -193,10 +193,10 @@ StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> attemptToGetExe
BSONObj sortObj,
SkipThenLimit skipThenLimit,
boost::optional<std::string> groupIdForDistinctScan,
- const AggregateCommand* aggRequest,
+ const AggregateCommandRequest* aggRequest,
const size_t plannerOpts,
const MatchExpressionParser::AllowedFeatureSet& matcherFeatures) {
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
query_request_helper::setTailableMode(expCtx->tailableMode, findCommand.get());
findCommand->setFilter(queryObj.getOwned());
findCommand->setProjection(projectionObj.getOwned());
@@ -419,7 +419,7 @@ PipelineD::buildInnerQueryExecutorSample(DocumentSourceSample* sampleStage,
std::pair<PipelineD::AttachExecutorCallback, std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>>
PipelineD::buildInnerQueryExecutor(const CollectionPtr& collection,
const NamespaceString& nss,
- const AggregateCommand* aggRequest,
+ const AggregateCommandRequest* aggRequest,
Pipeline* pipeline) {
auto expCtx = pipeline->getContext();
@@ -469,10 +469,11 @@ void PipelineD::attachInnerQueryExecutorToPipeline(
}
}
-void PipelineD::buildAndAttachInnerQueryExecutorToPipeline(const CollectionPtr& collection,
- const NamespaceString& nss,
- const AggregateCommand* aggRequest,
- Pipeline* pipeline) {
+void PipelineD::buildAndAttachInnerQueryExecutorToPipeline(
+ const CollectionPtr& collection,
+ const NamespaceString& nss,
+ const AggregateCommandRequest* aggRequest,
+ Pipeline* pipeline) {
auto callback = PipelineD::buildInnerQueryExecutor(collection, nss, aggRequest, pipeline);
PipelineD::attachInnerQueryExecutorToPipeline(
@@ -592,7 +593,7 @@ auto buildProjectionForPushdown(const DepsTracker& deps, Pipeline* pipeline) {
std::pair<PipelineD::AttachExecutorCallback, std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>>
PipelineD::buildInnerQueryExecutorGeneric(const CollectionPtr& collection,
const NamespaceString& nss,
- const AggregateCommand* aggRequest,
+ const AggregateCommandRequest* aggRequest,
Pipeline* pipeline) {
// Make a last effort to optimize pipeline stages before potentially detaching them to be pushed
// down into the query executor.
@@ -683,7 +684,7 @@ PipelineD::buildInnerQueryExecutorGeneric(const CollectionPtr& collection,
std::pair<PipelineD::AttachExecutorCallback, std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>>
PipelineD::buildInnerQueryExecutorGeoNear(const CollectionPtr& collection,
const NamespaceString& nss,
- const AggregateCommand* aggRequest,
+ const AggregateCommandRequest* aggRequest,
Pipeline* pipeline) {
uassert(ErrorCodes::NamespaceNotFound,
str::stream() << "$geoNear requires a geo index to run, but " << nss.ns()
@@ -751,7 +752,7 @@ StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> PipelineD::prep
QueryMetadataBitSet unavailableMetadata,
const BSONObj& queryObj,
SkipThenLimit skipThenLimit,
- const AggregateCommand* aggRequest,
+ const AggregateCommandRequest* aggRequest,
const MatchExpressionParser::AllowedFeatureSet& matcherFeatures,
bool* hasNoRequirements) {
invariant(hasNoRequirements);
diff --git a/src/mongo/db/pipeline/pipeline_d.h b/src/mongo/db/pipeline/pipeline_d.h
index ba7969550c5..89214cb1b10 100644
--- a/src/mongo/db/pipeline/pipeline_d.h
+++ b/src/mongo/db/pipeline/pipeline_d.h
@@ -94,7 +94,7 @@ public:
static std::pair<AttachExecutorCallback, std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>>
buildInnerQueryExecutor(const CollectionPtr& collection,
const NamespaceString& nss,
- const AggregateCommand* aggRequest,
+ const AggregateCommandRequest* aggRequest,
Pipeline* pipeline);
/**
@@ -116,10 +116,11 @@ public:
* used when the executor attachment phase doesn't need to be deferred and the $cursor stage
* can be created right after buiding the executor.
*/
- static void buildAndAttachInnerQueryExecutorToPipeline(const CollectionPtr& collection,
- const NamespaceString& nss,
- const AggregateCommand* aggRequest,
- Pipeline* pipeline);
+ static void buildAndAttachInnerQueryExecutorToPipeline(
+ const CollectionPtr& collection,
+ const NamespaceString& nss,
+ const AggregateCommandRequest* aggRequest,
+ Pipeline* pipeline);
static Timestamp getLatestOplogTimestamp(const Pipeline* pipeline);
@@ -156,7 +157,7 @@ private:
static std::pair<AttachExecutorCallback, std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>>
buildInnerQueryExecutorGeneric(const CollectionPtr& collection,
const NamespaceString& nss,
- const AggregateCommand* aggRequest,
+ const AggregateCommandRequest* aggRequest,
Pipeline* pipeline);
/**
@@ -167,7 +168,7 @@ private:
static std::pair<AttachExecutorCallback, std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>>
buildInnerQueryExecutorGeoNear(const CollectionPtr& collection,
const NamespaceString& nss,
- const AggregateCommand* aggRequest,
+ const AggregateCommandRequest* aggRequest,
Pipeline* pipeline);
/**
@@ -205,7 +206,7 @@ private:
QueryMetadataBitSet metadataAvailable,
const BSONObj& queryObj,
SkipThenLimit skipThenLimit,
- const AggregateCommand* aggRequest,
+ const AggregateCommandRequest* aggRequest,
const MatchExpressionParser::AllowedFeatureSet& matcherFeatures,
bool* hasNoRequirements);
};
diff --git a/src/mongo/db/pipeline/pipeline_metadata_tree_test.cpp b/src/mongo/db/pipeline/pipeline_metadata_tree_test.cpp
index 38d3fc10188..8b8f6597596 100644
--- a/src/mongo/db/pipeline/pipeline_metadata_tree_test.cpp
+++ b/src/mongo/db/pipeline/pipeline_metadata_tree_test.cpp
@@ -79,7 +79,7 @@ protected:
ASSERT_EQUALS(inputBson["pipeline"].type(), BSONType::Array);
auto rawPipeline = parsePipelineFromBSON(inputBson["pipeline"]);
NamespaceString testNss("test", "collection");
- AggregateCommand request(testNss, rawPipeline);
+ AggregateCommandRequest request(testNss, rawPipeline);
getExpCtx()->ns = testNss;
return Pipeline::parse(request.getPipeline(), getExpCtx());
diff --git a/src/mongo/db/pipeline/pipeline_test.cpp b/src/mongo/db/pipeline/pipeline_test.cpp
index 88637498adc..6d9ba462d35 100644
--- a/src/mongo/db/pipeline/pipeline_test.cpp
+++ b/src/mongo/db/pipeline/pipeline_test.cpp
@@ -122,7 +122,7 @@ void assertPipelineOptimizesAndSerializesTo(std::string inputPipeJson,
ASSERT_EQUALS(stageElem.type(), BSONType::Object);
rawPipeline.push_back(stageElem.embeddedObject());
}
- AggregateCommand request(kTestNss, rawPipeline);
+ AggregateCommandRequest request(kTestNss, rawPipeline);
intrusive_ptr<ExpressionContextForTest> ctx =
new ExpressionContextForTest(opCtx.get(), request);
ctx->mongoProcessInterface = std::make_shared<StubExplainInterface>();
@@ -2470,7 +2470,7 @@ public:
ASSERT_EQUALS(stageElem.type(), BSONType::Object);
rawPipeline.push_back(stageElem.embeddedObject());
}
- AggregateCommand request(kTestNss, rawPipeline);
+ AggregateCommandRequest request(kTestNss, rawPipeline);
intrusive_ptr<ExpressionContextForTest> ctx = createExpressionContext(request);
TempDir tempDir("PipelineTest");
ctx->tempDir = tempDir.path();
@@ -2500,7 +2500,7 @@ public:
virtual ~Base() {}
virtual intrusive_ptr<ExpressionContextForTest> createExpressionContext(
- const AggregateCommand& request) {
+ const AggregateCommandRequest& request) {
return new ExpressionContextForTest(&_opCtx, request);
}
@@ -3022,7 +3022,7 @@ class MergeWithUnshardedCollection : public ShardMergerBase {
class MergeWithShardedCollection : public ShardMergerBase {
intrusive_ptr<ExpressionContextForTest> createExpressionContext(
- const AggregateCommand& request) override {
+ const AggregateCommandRequest& request) override {
class ProcessInterface : public StubMongoProcessInterface {
bool isSharded(OperationContext* opCtx, const NamespaceString& ns) override {
return true;
@@ -3256,7 +3256,7 @@ TEST(PipelineInitialSource, GeoNearInitialQuery) {
const std::vector<BSONObj> rawPipeline = {
fromjson("{$geoNear: {distanceField: 'd', near: [0, 0], query: {a: 1}}}")};
intrusive_ptr<ExpressionContextForTest> ctx = new ExpressionContextForTest(
- &_opCtx, AggregateCommand(NamespaceString("a.collection"), rawPipeline));
+ &_opCtx, AggregateCommandRequest(NamespaceString("a.collection"), rawPipeline));
auto pipe = Pipeline::parse(rawPipeline, ctx);
ASSERT_BSONOBJ_EQ(pipe->getInitialQuery(), BSON("a" << 1));
}
@@ -3265,7 +3265,7 @@ TEST(PipelineInitialSource, MatchInitialQuery) {
OperationContextNoop _opCtx;
const std::vector<BSONObj> rawPipeline = {fromjson("{$match: {'a': 4}}")};
intrusive_ptr<ExpressionContextForTest> ctx = new ExpressionContextForTest(
- &_opCtx, AggregateCommand(NamespaceString("a.collection"), rawPipeline));
+ &_opCtx, AggregateCommandRequest(NamespaceString("a.collection"), rawPipeline));
auto pipe = Pipeline::parse(rawPipeline, ctx);
ASSERT_BSONOBJ_EQ(pipe->getInitialQuery(), BSON("a" << 4));
diff --git a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp
index e4a5a266954..40423882f65 100644
--- a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp
+++ b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp
@@ -588,13 +588,12 @@ CommonMongodProcessInterface::ensureFieldsUniqueOrResolveDocumentKey(
return {*fieldPaths, targetCollectionVersion};
}
-write_ops::Insert CommonMongodProcessInterface::buildInsertOp(const NamespaceString& nss,
- std::vector<BSONObj>&& objs,
- bool bypassDocValidation) {
- write_ops::Insert insertOp(nss);
+write_ops::InsertCommandRequest CommonMongodProcessInterface::buildInsertOp(
+ const NamespaceString& nss, std::vector<BSONObj>&& objs, bool bypassDocValidation) {
+ write_ops::InsertCommandRequest insertOp(nss);
insertOp.setDocuments(std::move(objs));
- insertOp.setWriteCommandBase([&] {
- write_ops::WriteCommandBase wcb;
+ insertOp.setWriteCommandRequestBase([&] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(false);
wcb.setBypassDocumentValidation(bypassDocValidation);
return wcb;
@@ -602,13 +601,13 @@ write_ops::Insert CommonMongodProcessInterface::buildInsertOp(const NamespaceStr
return insertOp;
}
-write_ops::Update CommonMongodProcessInterface::buildUpdateOp(
+write_ops::UpdateCommandRequest CommonMongodProcessInterface::buildUpdateOp(
const boost::intrusive_ptr<ExpressionContext>& expCtx,
const NamespaceString& nss,
BatchedObjects&& batch,
UpsertType upsert,
bool multi) {
- write_ops::Update updateOp(nss);
+ write_ops::UpdateCommandRequest updateOp(nss);
updateOp.setUpdates([&] {
std::vector<write_ops::UpdateOpEntry> updateEntries;
for (auto&& obj : batch) {
@@ -627,8 +626,8 @@ write_ops::Update CommonMongodProcessInterface::buildUpdateOp(
}
return updateEntries;
}());
- updateOp.setWriteCommandBase([&] {
- write_ops::WriteCommandBase wcb;
+ updateOp.setWriteCommandRequestBase([&] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(false);
wcb.setBypassDocumentValidation(expCtx->bypassDocumentValidation);
return wcb;
diff --git a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.h b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.h
index 4706c259864..185eca653cf 100644
--- a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.h
+++ b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.h
@@ -112,18 +112,19 @@ protected:
/**
* Builds an ordered insert op on namespace 'nss' and documents to be written 'objs'.
*/
- write_ops::Insert buildInsertOp(const NamespaceString& nss,
- std::vector<BSONObj>&& objs,
- bool bypassDocValidation);
+ write_ops::InsertCommandRequest buildInsertOp(const NamespaceString& nss,
+ std::vector<BSONObj>&& objs,
+ bool bypassDocValidation);
/**
* Builds an ordered update op on namespace 'nss' with update entries contained in 'batch'.
*/
- write_ops::Update buildUpdateOp(const boost::intrusive_ptr<ExpressionContext>& expCtx,
- const NamespaceString& nss,
- BatchedObjects&& batch,
- UpsertType upsert,
- bool multi);
+ write_ops::UpdateCommandRequest buildUpdateOp(
+ const boost::intrusive_ptr<ExpressionContext>& expCtx,
+ const NamespaceString& nss,
+ BatchedObjects&& batch,
+ UpsertType upsert,
+ bool multi);
BSONObj _reportCurrentOpForClient(OperationContext* opCtx,
Client* client,
diff --git a/src/mongo/db/pipeline/sharded_agg_helpers.cpp b/src/mongo/db/pipeline/sharded_agg_helpers.cpp
index 3bec7700e30..a3296e95f45 100644
--- a/src/mongo/db/pipeline/sharded_agg_helpers.cpp
+++ b/src/mongo/db/pipeline/sharded_agg_helpers.cpp
@@ -101,7 +101,7 @@ RemoteCursor openChangeStreamNewShardMonitor(const boost::intrusive_ptr<Expressi
Timestamp startMonitoringAtTime) {
const auto& configShard = Grid::get(expCtx->opCtx)->shardRegistry()->getConfigShard();
// Pipeline: {$changeStream: {startAtOperationTime: [now], allowToRunOnConfigDB: true}}
- AggregateCommand aggReq(
+ AggregateCommandRequest aggReq(
ShardType::ConfigNS,
{BSON(DocumentSourceChangeStream::kStageName
<< BSON(DocumentSourceChangeStreamSpec::kStartAtOperationTimeFieldName
@@ -146,19 +146,19 @@ BSONObj genericTransformForShards(MutableDocument&& cmdForShards,
auto [legacyRuntimeConstants, unusedSerializedVariables] =
expCtx->variablesParseState.transitionalCompatibilitySerialize(expCtx->variables);
- cmdForShards[AggregateCommand::kLegacyRuntimeConstantsFieldName] =
+ cmdForShards[AggregateCommandRequest::kLegacyRuntimeConstantsFieldName] =
Value(legacyRuntimeConstants.toBSON());
} else {
// Either this is a "modern" cluster or we are a mongos and can assume the shards are
// "modern" and will understand the 'let' parameter.
- cmdForShards[AggregateCommand::kLetFieldName] =
+ cmdForShards[AggregateCommandRequest::kLetFieldName] =
Value(expCtx->variablesParseState.serialize(expCtx->variables));
}
- cmdForShards[AggregateCommand::kFromMongosFieldName] = Value(expCtx->inMongos);
+ cmdForShards[AggregateCommandRequest::kFromMongosFieldName] = Value(expCtx->inMongos);
if (!collationObj.isEmpty()) {
- cmdForShards[AggregateCommand::kCollationFieldName] = Value(collationObj);
+ cmdForShards[AggregateCommandRequest::kCollationFieldName] = Value(collationObj);
}
// If this is a request for an aggregation explain, then we must wrap the aggregate inside an
@@ -602,16 +602,18 @@ void abandonCacheIfSentToShards(Pipeline* shardsPipeline) {
std::unique_ptr<Pipeline, PipelineDeleter> targetShardsAndAddMergeCursors(
const boost::intrusive_ptr<ExpressionContext>& expCtx,
- stdx::variant<std::unique_ptr<Pipeline, PipelineDeleter>, AggregateCommand> targetRequest,
+ stdx::variant<std::unique_ptr<Pipeline, PipelineDeleter>, AggregateCommandRequest>
+ targetRequest,
boost::optional<BSONObj> shardCursorsSortSpec) {
auto&& [aggRequest, pipeline] = [&] {
return stdx::visit(
visit_helper::Overloaded{
[&](std::unique_ptr<Pipeline, PipelineDeleter>&& pipeline) {
- return std::make_pair(AggregateCommand(expCtx->ns, pipeline->serializeToBson()),
- std::move(pipeline));
+ return std::make_pair(
+ AggregateCommandRequest(expCtx->ns, pipeline->serializeToBson()),
+ std::move(pipeline));
},
- [&](AggregateCommand&& aggRequest) {
+ [&](AggregateCommandRequest&& aggRequest) {
auto rawPipeline = aggRequest.getPipeline();
return std::make_pair(std::move(aggRequest),
Pipeline::parse(std::move(rawPipeline), expCtx));
@@ -622,8 +624,8 @@ std::unique_ptr<Pipeline, PipelineDeleter> targetShardsAndAddMergeCursors(
invariant(pipeline->getSources().empty() ||
!dynamic_cast<DocumentSourceMergeCursors*>(pipeline->getSources().front().get()));
- // The default value for 'allowDiskUse' and 'maxTimeMS' in the AggregateCommand may not match
- // what was set on the originating command, so copy it from the ExpressionContext.
+ // The default value for 'allowDiskUse' and 'maxTimeMS' in the AggregateCommandRequest may not
+ // match what was set on the originating command, so copy it from the ExpressionContext.
aggRequest.setAllowDiskUse(expCtx->allowDiskUse);
if (auto maxTimeMS = expCtx->opCtx->getRemainingMaxTimeMillis();
@@ -669,7 +671,7 @@ std::unique_ptr<Pipeline, PipelineDeleter> targetShardsAndAddMergeCursors(
std::unique_ptr<Pipeline, PipelineDeleter> runPipelineDirectlyOnSingleShard(
const boost::intrusive_ptr<ExpressionContext>& expCtx,
- AggregateCommand request,
+ AggregateCommandRequest request,
ShardId shardId) {
invariant(!request.getExplain());
@@ -793,7 +795,7 @@ BSONObj createPassthroughCommandForShard(
// Create the command for the shards.
MutableDocument targetedCmd(serializedCommand);
if (pipeline) {
- targetedCmd[AggregateCommand::kPipelineFieldName] = Value(pipeline->serialize());
+ targetedCmd[AggregateCommandRequest::kPipelineFieldName] = Value(pipeline->serialize());
}
return genericTransformForShards(
@@ -811,12 +813,12 @@ BSONObj createCommandForTargetedShards(const boost::intrusive_ptr<ExpressionCont
// has defaulted any arguments or otherwise changed the spec. For example, $listSessions may
// have detected a logged in user and appended that user name to the $listSessions spec to
// send to the shards.
- targetedCmd[AggregateCommand::kPipelineFieldName] =
+ targetedCmd[AggregateCommandRequest::kPipelineFieldName] =
Value(splitPipeline.shardsPipeline->serialize());
// When running on many shards with the exchange we may not need merging.
if (needsMerge) {
- targetedCmd[AggregateCommand::kNeedsMergeFieldName] = Value(true);
+ targetedCmd[AggregateCommandRequest::kNeedsMergeFieldName] = Value(true);
// If there aren't any stages like $out in the pipeline being sent to the shards, remove the
// write concern. The write concern should only be applied when there are writes performed
@@ -829,10 +831,10 @@ BSONObj createCommandForTargetedShards(const boost::intrusive_ptr<ExpressionCont
}
}
- targetedCmd[AggregateCommand::kCursorFieldName] =
+ targetedCmd[AggregateCommandRequest::kCursorFieldName] =
Value(DOC(aggregation_request_helper::kBatchSizeField << 0));
- targetedCmd[AggregateCommand::kExchangeFieldName] =
+ targetedCmd[AggregateCommandRequest::kExchangeFieldName] =
exchangeSpec ? Value(exchangeSpec->exchangeSpec.toBSON()) : Value();
return genericTransformForShards(
@@ -1165,7 +1167,7 @@ BSONObj targetShardsForExplain(Pipeline* ownedPipeline) {
return stages;
}();
- AggregateCommand aggRequest(expCtx->ns, rawStages);
+ AggregateCommandRequest aggRequest(expCtx->ns, rawStages);
LiteParsedPipeline liteParsedPipeline(aggRequest);
auto hasChangeStream = liteParsedPipeline.hasChangeStream();
auto shardDispatchResults =
diff --git a/src/mongo/db/pipeline/sharded_agg_helpers.h b/src/mongo/db/pipeline/sharded_agg_helpers.h
index 2f8831f8bfa..1114c1a1d1a 100644
--- a/src/mongo/db/pipeline/sharded_agg_helpers.h
+++ b/src/mongo/db/pipeline/sharded_agg_helpers.h
@@ -198,13 +198,14 @@ std::unique_ptr<Pipeline, PipelineDeleter> attachCursorToPipeline(Pipeline* owne
* beginning with that DocumentSourceMergeCursors stage. Note that one of the 'remote' cursors might
* be this node itself.
*
- * Use the AggregateCommand alternative for 'targetRequest' to explicitly specify command options
- * (e.g. read concern) to the shards when establishing remote cursors. Note that doing so incurs the
- * cost of parsing the pipeline.
+ * Use the AggregateCommandRequest alternative for 'targetRequest' to explicitly specify command
+ * options (e.g. read concern) to the shards when establishing remote cursors. Note that doing so
+ * incurs the cost of parsing the pipeline.
*/
std::unique_ptr<Pipeline, PipelineDeleter> targetShardsAndAddMergeCursors(
const boost::intrusive_ptr<ExpressionContext>& expCtx,
- stdx::variant<std::unique_ptr<Pipeline, PipelineDeleter>, AggregateCommand> targetRequest,
+ stdx::variant<std::unique_ptr<Pipeline, PipelineDeleter>, AggregateCommandRequest>
+ targetRequest,
boost::optional<BSONObj> shardCursorsSortSpec = boost::none);
/**
@@ -216,11 +217,11 @@ std::unique_ptr<Pipeline, PipelineDeleter> targetShardsAndAddMergeCursors(
* especially useful for reading from unsharded collections such as config.transactions and
* local.oplog.rs that cannot be targeted by targetShardsAndAddMergeCursors().
*
- * Note that the specified AggregateCommand must not be for an explain command.
+ * Note that the specified AggregateCommandRequest must not be for an explain command.
*/
std::unique_ptr<Pipeline, PipelineDeleter> runPipelineDirectlyOnSingleShard(
const boost::intrusive_ptr<ExpressionContext>& expCtx,
- AggregateCommand request,
+ AggregateCommandRequest request,
ShardId shardId);
} // namespace sharded_agg_helpers
diff --git a/src/mongo/db/query/README.md b/src/mongo/db/query/README.md
index ffb98c9fe7a..ec3e0c203e4 100644
--- a/src/mongo/db/query/README.md
+++ b/src/mongo/db/query/README.md
@@ -86,7 +86,7 @@ commands:
count:
description: "Parser for the 'count' command."
command_name: count
- cpp_name: CountCommand
+ cpp_name: CountCommandRequest
strict: true
namespace: concatenate_with_db_or_uuid
fields:
@@ -111,7 +111,7 @@ we don't have to write any code to handle that.
The generated file will have methods to get and set all the members, and
will return a boost::optional for optional fields. In the example above,
-it will generate a CountCommand::getQuery() method, among others.
+it will generate a CountCommandRequest::getQuery() method, among others.
### Other actions performed during this stage
@@ -215,9 +215,9 @@ Once we have parsed the command and checked authorization, we move on to parsing
parts of the query. Once again, we will focus on the find and aggregate commands.
### Find command parsing
-The find command is parsed entirely by the IDL. Initially the IDL parser creates a FindCommand. As
-mentioned above, the IDL parser does all of the required type checking and stores all options for
-the query. The FindCommand is then turned into a CanonicalQuery. The CanonicalQuery
+The find command is parsed entirely by the IDL. The IDL parser first creates a FindCommandRequest.
+As mentioned above, the IDL parser does all of the required type checking and stores all options for
+the query. The FindCommandRequest is then turned into a CanonicalQuery. The CanonicalQuery
parses the collation and the filter while just holding the rest of the IDL parsed fields.
The parsing of the collation is straightforward: for each field that is allowed to be in the object,
we check for that field and then build the collation from the parsed fields.
@@ -270,7 +270,7 @@ give a summary of how each is parsed, but not get into the same level of detail.
* count : Parsed by IDL and then turned into a CountStage which can be executed in a similar way to
a find command.
* distinct : The distinct specific arguments are parsed by IDL, and the generic command arguments
- are parsed by custom code. They are then combined into a FindCommand (mentioned above),
+ are parsed by custom code. They are then combined into a FindCommandRequest (mentioned above),
canonicalized, packaged into a ParsedDistinct, which is eventually turned into an executable
stage.
* mapReduce : Parsed by IDL and then turned into an equivalent aggregation command.
diff --git a/src/mongo/db/query/canonical_query.cpp b/src/mongo/db/query/canonical_query.cpp
index 2b24dac9f9a..99771b5f043 100644
--- a/src/mongo/db/query/canonical_query.cpp
+++ b/src/mongo/db/query/canonical_query.cpp
@@ -66,7 +66,7 @@ StatusWith<std::unique_ptr<CanonicalQuery>> CanonicalQuery::canonicalize(
const ExtensionsCallback& extensionsCallback,
MatchExpressionParser::AllowedFeatureSet allowedFeatures) {
bool explain = false;
- // Make FindCommand.
+ // Make FindCommandRequest.
auto status = query_request_helper::fromLegacyQueryMessage(qm, &explain);
if (!status.isOK()) {
return status.getStatus();
@@ -79,13 +79,13 @@ StatusWith<std::unique_ptr<CanonicalQuery>> CanonicalQuery::canonicalize(
// static
StatusWith<std::unique_ptr<CanonicalQuery>> CanonicalQuery::canonicalize(
OperationContext* opCtx,
- std::unique_ptr<FindCommand> findCommand,
+ std::unique_ptr<FindCommandRequest> findCommand,
bool explain,
const boost::intrusive_ptr<ExpressionContext>& expCtx,
const ExtensionsCallback& extensionsCallback,
MatchExpressionParser::AllowedFeatureSet allowedFeatures,
const ProjectionPolicies& projectionPolicies) {
- auto status = query_request_helper::validateFindCommand(*findCommand);
+ auto status = query_request_helper::validateFindCommandRequest(*findCommand);
if (!status.isOK()) {
return status;
}
@@ -111,7 +111,7 @@ StatusWith<std::unique_ptr<CanonicalQuery>> CanonicalQuery::canonicalize(
findCommand->getLet());
} else {
newExpCtx = expCtx;
- // A collator can enter through both the FindCommand and ExpressionContext arguments.
+ // A collator can enter through both the FindCommandRequest and ExpressionContext arguments.
// This invariant ensures that both collators are the same because downstream we
// pull the collator from only one of the ExpressionContext carrier.
if (collator.get() && expCtx->getCollator()) {
@@ -158,14 +158,14 @@ StatusWith<std::unique_ptr<CanonicalQuery>> CanonicalQuery::canonicalize(
// static
StatusWith<std::unique_ptr<CanonicalQuery>> CanonicalQuery::canonicalize(
OperationContext* opCtx, const CanonicalQuery& baseQuery, MatchExpression* root) {
- auto findCommand = std::make_unique<FindCommand>(baseQuery.nss());
+ auto findCommand = std::make_unique<FindCommandRequest>(baseQuery.nss());
BSONObjBuilder builder;
root->serialize(&builder, true);
findCommand->setFilter(builder.obj());
- findCommand->setProjection(baseQuery.getFindCommand().getProjection().getOwned());
- findCommand->setSort(baseQuery.getFindCommand().getSort().getOwned());
- findCommand->setCollation(baseQuery.getFindCommand().getCollation().getOwned());
- auto status = query_request_helper::validateFindCommand(*findCommand);
+ findCommand->setProjection(baseQuery.getFindCommandRequest().getProjection().getOwned());
+ findCommand->setSort(baseQuery.getFindCommandRequest().getSort().getOwned());
+ findCommand->setCollation(baseQuery.getFindCommandRequest().getCollation().getOwned());
+ auto status = query_request_helper::validateFindCommandRequest(*findCommand);
if (!status.isOK()) {
return status;
}
@@ -188,7 +188,7 @@ StatusWith<std::unique_ptr<CanonicalQuery>> CanonicalQuery::canonicalize(
Status CanonicalQuery::init(OperationContext* opCtx,
boost::intrusive_ptr<ExpressionContext> expCtx,
- std::unique_ptr<FindCommand> findCommand,
+ std::unique_ptr<FindCommandRequest> findCommand,
bool canHaveNoopMatchNodes,
std::unique_ptr<MatchExpression> root,
const ProjectionPolicies& projectionPolicies) {
@@ -342,7 +342,7 @@ bool hasNodeInSubtree(MatchExpression* root,
}
StatusWith<QueryMetadataBitSet> CanonicalQuery::isValid(MatchExpression* root,
- const FindCommand& findCommand) {
+ const FindCommandRequest& findCommand) {
QueryMetadataBitSet unavailableMetadata{};
// There can only be one TEXT. If there is a TEXT, it cannot appear inside a NOR.
diff --git a/src/mongo/db/query/canonical_query.h b/src/mongo/db/query/canonical_query.h
index 4b148557710..e6d3d8c2171 100644
--- a/src/mongo/db/query/canonical_query.h
+++ b/src/mongo/db/query/canonical_query.h
@@ -77,7 +77,7 @@ public:
*/
static StatusWith<std::unique_ptr<CanonicalQuery>> canonicalize(
OperationContext* opCtx,
- std::unique_ptr<FindCommand> findCommand,
+ std::unique_ptr<FindCommandRequest> findCommand,
bool explain = false,
const boost::intrusive_ptr<ExpressionContext>& expCtx = nullptr,
const ExtensionsCallback& extensionsCallback = ExtensionsCallbackNoop(),
@@ -118,7 +118,7 @@ public:
* error.
*/
static StatusWith<QueryMetadataBitSet> isValid(MatchExpression* root,
- const FindCommand& findCommand);
+ const FindCommandRequest& findCommand);
const NamespaceString nss() const {
invariant(_findCommand->getNamespaceOrUUID().nss());
@@ -137,7 +137,7 @@ public:
const BSONObj& getQueryObj() const {
return _findCommand->getFilter();
}
- const FindCommand& getFindCommand() const {
+ const FindCommandRequest& getFindCommandRequest() const {
return *_findCommand;
}
@@ -237,7 +237,7 @@ private:
Status init(OperationContext* opCtx,
boost::intrusive_ptr<ExpressionContext> expCtx,
- std::unique_ptr<FindCommand> findCommand,
+ std::unique_ptr<FindCommandRequest> findCommand,
bool canHaveNoopMatchNodes,
std::unique_ptr<MatchExpression> root,
const ProjectionPolicies& projectionPolicies);
@@ -250,7 +250,7 @@ private:
boost::intrusive_ptr<ExpressionContext> _expCtx;
- std::unique_ptr<FindCommand> _findCommand;
+ std::unique_ptr<FindCommandRequest> _findCommand;
std::unique_ptr<MatchExpression> _root;
diff --git a/src/mongo/db/query/canonical_query_encoder.cpp b/src/mongo/db/query/canonical_query_encoder.cpp
index 41e7af395f8..c9821b90440 100644
--- a/src/mongo/db/query/canonical_query_encoder.cpp
+++ b/src/mongo/db/query/canonical_query_encoder.cpp
@@ -478,9 +478,8 @@ void encodeKeyForMatch(const MatchExpression* tree, StringBuilder* keyBuilder) {
}
/**
- * Encodes sort order into cache key.
- * Sort order is normalized because it provided by
- * FindCommand.
+ * Encodes sort order into cache key. Sort order is normalized because it provided by
+ * FindCommandRequest.
*/
void encodeKeyForSort(const BSONObj& sortObj, StringBuilder* keyBuilder) {
if (sortObj.isEmpty()) {
@@ -567,7 +566,7 @@ namespace canonical_query_encoder {
CanonicalQuery::QueryShapeString encode(const CanonicalQuery& cq) {
StringBuilder keyBuilder;
encodeKeyForMatch(cq.root(), &keyBuilder);
- encodeKeyForSort(cq.getFindCommand().getSort(), &keyBuilder);
+ encodeKeyForSort(cq.getFindCommandRequest().getSort(), &keyBuilder);
encodeKeyForProj(cq.getProj(), &keyBuilder);
encodeCollation(cq.getCollator(), &keyBuilder);
diff --git a/src/mongo/db/query/canonical_query_encoder_test.cpp b/src/mongo/db/query/canonical_query_encoder_test.cpp
index f54f7b7398b..2a5020ff6d0 100644
--- a/src/mongo/db/query/canonical_query_encoder_test.cpp
+++ b/src/mongo/db/query/canonical_query_encoder_test.cpp
@@ -55,7 +55,7 @@ unique_ptr<CanonicalQuery> canonicalize(BSONObj query,
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(query.getOwned());
findCommand->setSort(sort.getOwned());
findCommand->setProjection(proj.getOwned());
diff --git a/src/mongo/db/query/canonical_query_test.cpp b/src/mongo/db/query/canonical_query_test.cpp
index 2f0f2e02d4a..3d5f27431a9 100644
--- a/src/mongo/db/query/canonical_query_test.cpp
+++ b/src/mongo/db/query/canonical_query_test.cpp
@@ -179,7 +179,7 @@ unique_ptr<CanonicalQuery> canonicalize(const char* queryStr,
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(fromjson(queryStr));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx.get(),
@@ -199,7 +199,7 @@ std::unique_ptr<CanonicalQuery> canonicalize(const char* queryStr,
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(fromjson(queryStr));
findCommand->setSort(fromjson(sortStr));
findCommand->setProjection(fromjson(projStr));
@@ -282,11 +282,12 @@ TEST(CanonicalQueryTest, CanonicalizeFromBaseQuery) {
BSONObjBuilder expectedFilter;
firstClauseExpr->serialize(&expectedFilter);
- ASSERT_BSONOBJ_EQ(childCq->getFindCommand().getFilter(), expectedFilter.obj());
+ ASSERT_BSONOBJ_EQ(childCq->getFindCommandRequest().getFilter(), expectedFilter.obj());
- ASSERT_BSONOBJ_EQ(childCq->getFindCommand().getProjection(),
- baseCq->getFindCommand().getProjection());
- ASSERT_BSONOBJ_EQ(childCq->getFindCommand().getSort(), baseCq->getFindCommand().getSort());
+ ASSERT_BSONOBJ_EQ(childCq->getFindCommandRequest().getProjection(),
+ baseCq->getFindCommandRequest().getProjection());
+ ASSERT_BSONOBJ_EQ(childCq->getFindCommandRequest().getSort(),
+ baseCq->getFindCommandRequest().getSort());
ASSERT_TRUE(childCq->getExplain());
}
@@ -294,7 +295,7 @@ TEST(CanonicalQueryTest, CanonicalQueryFromQRWithNoCollation) {
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
auto cq = assertGet(CanonicalQuery::canonicalize(opCtx.get(), std::move(findCommand)));
ASSERT_TRUE(cq->getCollator() == nullptr);
}
@@ -303,7 +304,7 @@ TEST(CanonicalQueryTest, CanonicalQueryFromQRWithCollation) {
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setCollation(BSON("locale"
<< "reverse"));
auto cq = assertGet(CanonicalQuery::canonicalize(opCtx.get(), std::move(findCommand)));
@@ -315,7 +316,7 @@ TEST(CanonicalQueryTest, CanonicalQueryFromBaseQueryWithNoCollation) {
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(fromjson("{$or:[{a:1,b:1},{a:1,c:1}]}"));
auto baseCq = assertGet(CanonicalQuery::canonicalize(opCtx.get(), std::move(findCommand)));
MatchExpression* firstClauseExpr = baseCq->root()->getChild(0);
@@ -328,7 +329,7 @@ TEST(CanonicalQueryTest, CanonicalQueryFromBaseQueryWithCollation) {
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(fromjson("{$or:[{a:1,b:1},{a:1,c:1}]}"));
findCommand->setCollation(BSON("locale"
<< "reverse"));
@@ -344,7 +345,7 @@ TEST(CanonicalQueryTest, SettingCollatorUpdatesCollatorAndMatchExpression) {
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(fromjson("{a: 'foo', b: {$in: ['bar', 'baz']}}"));
auto cq = assertGet(CanonicalQuery::canonicalize(opCtx.get(), std::move(findCommand)));
ASSERT_EQUALS(2U, cq->root()->numChildren());
@@ -398,7 +399,7 @@ void assertValidSortOrder(BSONObj sort, BSONObj filter = BSONObj{}) {
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(filter);
findCommand->setSort(sort);
auto statusWithCQ =
@@ -424,7 +425,7 @@ void assertInvalidSortOrder(BSONObj sort) {
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setSort(sort);
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx.get(), std::move(findCommand));
ASSERT_NOT_OK(statusWithCQ.getStatus());
diff --git a/src/mongo/db/query/classic_stage_builder.cpp b/src/mongo/db/query/classic_stage_builder.cpp
index c26e0777765..bc9a9ab756b 100644
--- a/src/mongo/db/query/classic_stage_builder.cpp
+++ b/src/mongo/db/query/classic_stage_builder.cpp
@@ -161,30 +161,33 @@ std::unique_ptr<PlanStage> ClassicStageBuilder::build(const QuerySolutionNode* r
case STAGE_PROJECTION_DEFAULT: {
auto pn = static_cast<const ProjectionNodeDefault*>(root);
auto childStage = build(pn->children[0]);
- return std::make_unique<ProjectionStageDefault>(_cq.getExpCtx(),
- _cq.getFindCommand().getProjection(),
- _cq.getProj(),
- _ws,
- std::move(childStage));
+ return std::make_unique<ProjectionStageDefault>(
+ _cq.getExpCtx(),
+ _cq.getFindCommandRequest().getProjection(),
+ _cq.getProj(),
+ _ws,
+ std::move(childStage));
}
case STAGE_PROJECTION_COVERED: {
auto pn = static_cast<const ProjectionNodeCovered*>(root);
auto childStage = build(pn->children[0]);
- return std::make_unique<ProjectionStageCovered>(_cq.getExpCtxRaw(),
- _cq.getFindCommand().getProjection(),
- _cq.getProj(),
- _ws,
- std::move(childStage),
- pn->coveredKeyObj);
+ return std::make_unique<ProjectionStageCovered>(
+ _cq.getExpCtxRaw(),
+ _cq.getFindCommandRequest().getProjection(),
+ _cq.getProj(),
+ _ws,
+ std::move(childStage),
+ pn->coveredKeyObj);
}
case STAGE_PROJECTION_SIMPLE: {
auto pn = static_cast<const ProjectionNodeSimple*>(root);
auto childStage = build(pn->children[0]);
- return std::make_unique<ProjectionStageSimple>(_cq.getExpCtxRaw(),
- _cq.getFindCommand().getProjection(),
- _cq.getProj(),
- _ws,
- std::move(childStage));
+ return std::make_unique<ProjectionStageSimple>(
+ _cq.getExpCtxRaw(),
+ _cq.getFindCommandRequest().getProjection(),
+ _cq.getProj(),
+ _ws,
+ std::move(childStage));
}
case STAGE_LIMIT: {
const LimitNode* ln = static_cast<const LimitNode*>(root);
diff --git a/src/mongo/db/query/classic_stage_builder_test.cpp b/src/mongo/db/query/classic_stage_builder_test.cpp
index b7761ef474f..4e8f87140b7 100644
--- a/src/mongo/db/query/classic_stage_builder_test.cpp
+++ b/src/mongo/db/query/classic_stage_builder_test.cpp
@@ -68,7 +68,7 @@ public:
* Builds a PlanStage using the given WorkingSet and QuerySolution.
*/
std::unique_ptr<PlanStage> buildPlanStage(std::unique_ptr<QuerySolution> querySolution) {
- auto findCommand = std::make_unique<FindCommand>(kNss);
+ auto findCommand = std::make_unique<FindCommandRequest>(kNss);
auto expCtx = make_intrusive<ExpressionContext>(opCtx(), nullptr, kNss);
auto statusWithCQ =
CanonicalQuery::canonicalize(opCtx(), std::move(findCommand), false, expCtx);
diff --git a/src/mongo/db/query/count_command.idl b/src/mongo/db/query/count_command.idl
index df55cddcea0..85e6579555d 100644
--- a/src/mongo/db/query/count_command.idl
+++ b/src/mongo/db/query/count_command.idl
@@ -58,7 +58,7 @@ commands:
count:
description: "Parser for the 'count' command."
command_name: count
- cpp_name: CountCommand
+ cpp_name: CountCommandRequest
strict: true
namespace: concatenate_with_db_or_uuid
api_version: ""
diff --git a/src/mongo/db/query/count_command_as_aggregation_command.cpp b/src/mongo/db/query/count_command_as_aggregation_command.cpp
index 668baeb7c6b..b719ab77c86 100644
--- a/src/mongo/db/query/count_command_as_aggregation_command.cpp
+++ b/src/mongo/db/query/count_command_as_aggregation_command.cpp
@@ -47,7 +47,7 @@ const char kMaxTimeMSField[] = "maxTimeMS";
const char kReadConcernField[] = "readConcern";
} // namespace
-StatusWith<BSONObj> countCommandAsAggregationCommand(const CountCommand& cmd,
+StatusWith<BSONObj> countCommandAsAggregationCommand(const CountCommandRequest& cmd,
const NamespaceString& nss) {
BSONObjBuilder aggregationBuilder;
aggregationBuilder.append("aggregate", nss.coll());
diff --git a/src/mongo/db/query/count_command_as_aggregation_command.h b/src/mongo/db/query/count_command_as_aggregation_command.h
index 05583f36e5a..05233278765 100644
--- a/src/mongo/db/query/count_command_as_aggregation_command.h
+++ b/src/mongo/db/query/count_command_as_aggregation_command.h
@@ -36,9 +36,9 @@
namespace mongo {
/**
- * Converts this CountCommand into an aggregation.
+ * Converts this CountCommandRequest into an aggregation.
*/
-StatusWith<BSONObj> countCommandAsAggregationCommand(const CountCommand& cmd,
+StatusWith<BSONObj> countCommandAsAggregationCommand(const CountCommandRequest& cmd,
const NamespaceString& nss);
} // namespace mongo
diff --git a/src/mongo/db/query/count_command_test.cpp b/src/mongo/db/query/count_command_test.cpp
index 5792ee2e12b..c0039f46a3d 100644
--- a/src/mongo/db/query/count_command_test.cpp
+++ b/src/mongo/db/query/count_command_test.cpp
@@ -51,7 +51,7 @@ TEST(CountCommandTest, ParserDealsWithMissingFieldsCorrectly) {
<< "$db"
<< "TestDB"
<< "query" << BSON("a" << BSON("$lte" << 10)));
- auto countCmd = CountCommand::parse(ctxt, commandObj);
+ auto countCmd = CountCommandRequest::parse(ctxt, commandObj);
ASSERT_BSONOBJ_EQ(countCmd.getQuery(), fromjson("{ a : { '$lte' : 10 } }"));
@@ -81,7 +81,7 @@ TEST(CountCommandTest, ParserParsesCommandWithAllFieldsCorrectly) {
<< "comment"
<< "aComment"
<< "maxTimeMS" << 10000);
- const auto countCmd = CountCommand::parse(ctxt, commandObj);
+ const auto countCmd = CountCommandRequest::parse(ctxt, commandObj);
ASSERT_BSONOBJ_EQ(countCmd.getQuery(), fromjson("{ a : { '$gte' : 11 } }"));
ASSERT_EQ(countCmd.getLimit().get(), 100);
@@ -100,7 +100,7 @@ TEST(CountCommandTest, ParsingNegativeLimitGivesPositiveLimit) {
<< "$db"
<< "TestDB"
<< "limit" << -100);
- const auto countCmd = CountCommand::parse(ctxt, commandObj);
+ const auto countCmd = CountCommandRequest::parse(ctxt, commandObj);
ASSERT_EQ(countCmd.getLimit().get(), 100);
}
@@ -114,42 +114,42 @@ TEST(CountCommandTest, LimitCannotBeMinLong) {
<< std::numeric_limits<long long>::min());
ASSERT_THROWS_CODE(
- CountCommand::parse(ctxt, commandObj), AssertionException, ErrorCodes::BadValue);
+ CountCommandRequest::parse(ctxt, commandObj), AssertionException, ErrorCodes::BadValue);
}
TEST(CountCommandTest, FailParseBadSkipValue) {
- ASSERT_THROWS_CODE(
- CountCommand::parse(ctxt,
- BSON("count"
- << "TestColl"
- << "$db"
- << "TestDB"
- << "query" << BSON("a" << BSON("$gte" << 11)) << "skip" << -1000)),
- AssertionException,
- ErrorCodes::FailedToParse);
+ ASSERT_THROWS_CODE(CountCommandRequest::parse(ctxt,
+ BSON("count"
+ << "TestColl"
+ << "$db"
+ << "TestDB"
+ << "query" << BSON("a" << BSON("$gte" << 11))
+ << "skip" << -1000)),
+ AssertionException,
+ ErrorCodes::FailedToParse);
}
TEST(CountCommandTest, FailParseBadCollationType) {
ASSERT_THROWS_CODE(
- CountCommand::parse(ctxt,
- BSON("count"
- << "TestColl"
- << "$db"
- << "TestDB"
- << "query" << BSON("a" << BSON("$gte" << 11)) << "collation"
- << "en_US")),
+ CountCommandRequest::parse(ctxt,
+ BSON("count"
+ << "TestColl"
+ << "$db"
+ << "TestDB"
+ << "query" << BSON("a" << BSON("$gte" << 11)) << "collation"
+ << "en_US")),
AssertionException,
ErrorCodes::TypeMismatch);
}
TEST(CountCommandTest, FailParseUnknownField) {
- ASSERT_THROWS_CODE(CountCommand::parse(ctxt,
- BSON("count"
- << "TestColl"
- << "$db"
- << "TestDB"
- << "foo"
- << "bar")),
+ ASSERT_THROWS_CODE(CountCommandRequest::parse(ctxt,
+ BSON("count"
+ << "TestColl"
+ << "$db"
+ << "TestDB"
+ << "foo"
+ << "bar")),
AssertionException,
40415);
}
@@ -160,7 +160,7 @@ TEST(CountCommandTest, ConvertToAggregationWithHint) {
<< "$db"
<< "TestDB"
<< "hint" << BSON("x" << 1));
- auto countCmd = CountCommand::parse(ctxt, commandObj);
+ auto countCmd = CountCommandRequest::parse(ctxt, commandObj);
auto agg = uassertStatusOK(countCommandAsAggregationCommand(countCmd, testns));
auto cmdObj = OpMsgRequest::fromDBAndBody(testns.db(), agg).body;
@@ -182,7 +182,7 @@ TEST(CountCommandTest, ConvertToAggregationWithQueryAndFilterAndLimit) {
<< "$db"
<< "TestDB"
<< "limit" << 200 << "skip" << 300 << "query" << BSON("x" << 7));
- auto countCmd = CountCommand::parse(ctxt, commandObj);
+ auto countCmd = CountCommandRequest::parse(ctxt, commandObj);
auto agg = uassertStatusOK(countCommandAsAggregationCommand(countCmd, testns));
auto cmdObj = OpMsgRequest::fromDBAndBody(testns.db(), agg).body;
@@ -204,11 +204,11 @@ TEST(CountCommandTest, ConvertToAggregationWithQueryAndFilterAndLimit) {
}
TEST(CountCommandTest, ConvertToAggregationWithMaxTimeMS) {
- auto countCmd = CountCommand::parse(ctxt,
- BSON("count"
- << "TestColl"
- << "maxTimeMS" << 100 << "$db"
- << "TestDB"));
+ auto countCmd = CountCommandRequest::parse(ctxt,
+ BSON("count"
+ << "TestColl"
+ << "maxTimeMS" << 100 << "$db"
+ << "TestDB"));
auto agg = uassertStatusOK(countCommandAsAggregationCommand(countCmd, testns));
auto cmdObj = OpMsgRequest::fromDBAndBody(testns.db(), agg).body;
@@ -225,11 +225,11 @@ TEST(CountCommandTest, ConvertToAggregationWithMaxTimeMS) {
}
TEST(CountCommandTest, ConvertToAggregationWithQueryOptions) {
- auto countCmd = CountCommand::parse(ctxt,
- BSON("count"
- << "TestColl"
- << "$db"
- << "TestDB"));
+ auto countCmd = CountCommandRequest::parse(ctxt,
+ BSON("count"
+ << "TestColl"
+ << "$db"
+ << "TestDB"));
countCmd.setQueryOptions(BSON("readPreference"
<< "secondary"));
auto agg = uassertStatusOK(countCommandAsAggregationCommand(countCmd, testns));
@@ -250,11 +250,11 @@ TEST(CountCommandTest, ConvertToAggregationWithQueryOptions) {
}
TEST(CountCommandTest, ConvertToAggregationWithReadConcern) {
- auto countCmd = CountCommand::parse(ctxt,
- BSON("count"
- << "TestColl"
- << "$db"
- << "TestDB"));
+ auto countCmd = CountCommandRequest::parse(ctxt,
+ BSON("count"
+ << "TestColl"
+ << "$db"
+ << "TestDB"));
countCmd.setReadConcern(BSON("level"
<< "linearizable"));
auto agg = uassertStatusOK(countCommandAsAggregationCommand(countCmd, testns));
diff --git a/src/mongo/db/query/count_request.h b/src/mongo/db/query/count_request.h
index e80ec9a259c..6f118d3144a 100644
--- a/src/mongo/db/query/count_request.h
+++ b/src/mongo/db/query/count_request.h
@@ -36,19 +36,19 @@
namespace mongo {
namespace count_request {
/**
- * Parses a limit for a CountCommand. If the limit is negative, returns the absolute value.
+ * Parses a limit for a CountCommandRequest. If the limit is negative, returns the absolute value.
* Throws on invalid values.
*/
long long countParseLimit(const BSONElement& element);
/**
- * Parses a skip for a CountCommand. Errors if the value passed is negative.
+ * Parses a skip for a CountCommandRequest. Errors if the value passed is negative.
* Throws on invalid values.
*/
long long countParseSkip(const BSONElement& element);
/**
- * Parses a maxTimeMS for a CountCommand. Errors if the value passed is negative.
+ * Parses a maxTimeMS for a CountCommandRequest. Errors if the value passed is negative.
* Throws on invalid values.
*/
long long countParseMaxTime(const BSONElement& element);
diff --git a/src/mongo/db/query/distinct_command.idl b/src/mongo/db/query/distinct_command.idl
index 8d9750df6fd..668ff5b48d3 100644
--- a/src/mongo/db/query/distinct_command.idl
+++ b/src/mongo/db/query/distinct_command.idl
@@ -36,7 +36,7 @@ commands:
distinct:
description: "Parser for the 'distinct' command."
command_name: distinct
- cpp_name: DistinctCommand
+ cpp_name: DistinctCommandRequest
namespace: concatenate_with_db_or_uuid
api_version: ""
strict: true
diff --git a/src/mongo/db/query/find.cpp b/src/mongo/db/query/find.cpp
index 355858e2ccf..299d7a97480 100644
--- a/src/mongo/db/query/find.cpp
+++ b/src/mongo/db/query/find.cpp
@@ -85,7 +85,7 @@ bool shouldSaveCursor(OperationContext* opCtx,
const CollectionPtr& collection,
PlanExecutor::ExecState finalState,
PlanExecutor* exec) {
- const FindCommand& findCommand = exec->getCanonicalQuery()->getFindCommand();
+ const FindCommandRequest& findCommand = exec->getCanonicalQuery()->getFindCommandRequest();
if (findCommand.getSingleBatch()) {
return false;
}
@@ -631,7 +631,7 @@ bool runQuery(OperationContext* opCtx,
opCtx, nss, secondaryOk));
}
- const FindCommand& findCommand = cq->getFindCommand();
+ const FindCommandRequest& findCommand = cq->getFindCommandRequest();
// Get the execution plan for the query.
constexpr auto verbosity = ExplainOptions::Verbosity::kExecAllPlans;
const bool isExplain = cq->getExplain();
diff --git a/src/mongo/db/query/find_command.idl b/src/mongo/db/query/find_command.idl
index c6ccaf9661f..af76c9abde8 100644
--- a/src/mongo/db/query/find_command.idl
+++ b/src/mongo/db/query/find_command.idl
@@ -67,7 +67,7 @@ types:
commands:
find:
- cpp_name: FindCommand
+ cpp_name: FindCommandRequest
command_name: find
description: "A struct representing the find command"
strict: true
diff --git a/src/mongo/db/query/find_common.cpp b/src/mongo/db/query/find_common.cpp
index 02191c367eb..4f34e0b1cf4 100644
--- a/src/mongo/db/query/find_common.cpp
+++ b/src/mongo/db/query/find_common.cpp
@@ -58,7 +58,7 @@ MONGO_FAIL_POINT_DEFINE(failGetMoreAfterCursorCheckout);
const OperationContext::Decoration<AwaitDataState> awaitDataState =
OperationContext::declareDecoration<AwaitDataState>();
-bool FindCommon::enoughForFirstBatch(const FindCommand& findCommand, long long numDocs) {
+bool FindCommon::enoughForFirstBatch(const FindCommandRequest& findCommand, long long numDocs) {
auto effectiveBatchSize =
findCommand.getBatchSize() ? findCommand.getBatchSize() : findCommand.getNtoreturn();
if (!effectiveBatchSize) {
diff --git a/src/mongo/db/query/find_common.h b/src/mongo/db/query/find_common.h
index 3fc2b9b0e76..14118cdea03 100644
--- a/src/mongo/db/query/find_common.h
+++ b/src/mongo/db/query/find_common.h
@@ -54,7 +54,7 @@ extern const OperationContext::Decoration<AwaitDataState> awaitDataState;
class BSONObj;
class CanonicalQuery;
-class FindCommand;
+class FindCommandRequest;
// Failpoint for making find hang.
extern FailPoint waitInFindBeforeMakingBatch;
@@ -101,7 +101,7 @@ public:
*
* If 'qr' does not have a batchSize, the default batchSize is respected.
*/
- static bool enoughForFirstBatch(const FindCommand& findCommand, long long numDocs);
+ static bool enoughForFirstBatch(const FindCommandRequest& findCommand, long long numDocs);
/**
* Returns true if the batchSize for the getMore has been satisfied.
diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp
index 87f8b82213a..c4536c8b654 100644
--- a/src/mongo/db/query/get_executor.cpp
+++ b/src/mongo/db/query/get_executor.cpp
@@ -149,7 +149,7 @@ bool turnIxscanIntoCount(QuerySolution* soln);
* Returns 'true' if 'query' on the given 'collection' can be answered using a special IDHACK plan.
*/
bool isIdHackEligibleQuery(const CollectionPtr& collection, const CanonicalQuery& query) {
- const auto& findCommand = query.getFindCommand();
+ const auto& findCommand = query.getFindCommandRequest();
return !findCommand.getShowRecordId() && findCommand.getHint().isEmpty() &&
findCommand.getMin().isEmpty() && findCommand.getMax().isEmpty() &&
!findCommand.getSkip() && CanonicalQuery::isSimpleIdQuery(findCommand.getFilter()) &&
@@ -353,7 +353,7 @@ void fillOutPlannerParams(OperationContext* opCtx,
plannerParams->options |= QueryPlannerParams::SPLIT_LIMITED_SORT;
if (shouldWaitForOplogVisibility(
- opCtx, collection, canonicalQuery->getFindCommand().getTailable())) {
+ opCtx, collection, canonicalQuery->getFindCommandRequest().getTailable())) {
plannerParams->options |= QueryPlannerParams::OPLOG_SCAN_WAIT_FOR_VISIBLE;
}
}
@@ -580,8 +580,8 @@ public:
// If the canonical query does not have a user-specified collation and no one has given the
// CanonicalQuery a collation already, set it from the collection default.
- if (_cq->getFindCommand().getCollation().isEmpty() && _cq->getCollator() == nullptr &&
- _collection->getDefaultCollator()) {
+ if (_cq->getFindCommandRequest().getCollation().isEmpty() &&
+ _cq->getCollator() == nullptr && _collection->getDefaultCollator()) {
_cq->setCollator(_collection->getDefaultCollator()->clone());
}
@@ -600,7 +600,7 @@ public:
}
// Tailable: If the query requests tailable the collection must be capped.
- if (_cq->getFindCommand().getTailable() && !_collection->isCapped()) {
+ if (_cq->getFindCommandRequest().getTailable() && !_collection->isCapped()) {
return Status(ErrorCodes::BadValue,
str::stream() << "error processing query: " << _cq->toString()
<< " tailable cursor requested on non capped collection");
@@ -801,10 +801,10 @@ protected:
// Add a SortKeyGeneratorStage if the query requested sortKey metadata.
if (_cq->metadataDeps()[DocumentMetadataFields::kSortKey]) {
stage = std::make_unique<SortKeyGeneratorStage>(
- _cq->getExpCtxRaw(), std::move(stage), _ws, _cq->getFindCommand().getSort());
+ _cq->getExpCtxRaw(), std::move(stage), _ws, _cq->getFindCommandRequest().getSort());
}
- if (_cq->getFindCommand().getReturnKey()) {
+ if (_cq->getFindCommandRequest().getReturnKey()) {
// If returnKey was requested, add ReturnKeyStage to return only the index keys in
// the resulting documents. If a projection was also specified, it will be ignored,
// with the exception the $meta sortKey projection, which can be used along with the
@@ -822,19 +822,19 @@ protected:
// simple inclusion fast path.
// Stuff the right data into the params depending on what proj impl we use.
if (!cqProjection->isSimple()) {
- stage =
- std::make_unique<ProjectionStageDefault>(_cq->getExpCtxRaw(),
- _cq->getFindCommand().getProjection(),
- _cq->getProj(),
- _ws,
- std::move(stage));
+ stage = std::make_unique<ProjectionStageDefault>(
+ _cq->getExpCtxRaw(),
+ _cq->getFindCommandRequest().getProjection(),
+ _cq->getProj(),
+ _ws,
+ std::move(stage));
} else {
- stage =
- std::make_unique<ProjectionStageSimple>(_cq->getExpCtxRaw(),
- _cq->getFindCommand().getProjection(),
- _cq->getProj(),
- _ws,
- std::move(stage));
+ stage = std::make_unique<ProjectionStageSimple>(
+ _cq->getExpCtxRaw(),
+ _cq->getFindCommandRequest().getProjection(),
+ _cq->getProj(),
+ _ws,
+ std::move(stage));
}
}
@@ -928,7 +928,7 @@ protected:
!_cq->metadataDeps()[DocumentMetadataFields::kSortKey]);
// For the return key case, we use the common path.
- if (_cq->getFindCommand().getReturnKey()) {
+ if (_cq->getFindCommandRequest().getReturnKey()) {
return nullptr;
}
@@ -1848,7 +1848,7 @@ bool getDistinctNodeIndex(const std::vector<IndexEntry>& indices,
StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getExecutorCount(
const boost::intrusive_ptr<ExpressionContext>& expCtx,
const CollectionPtr* coll,
- const CountCommand& request,
+ const CountCommandRequest& request,
bool explain,
const NamespaceString& nss) {
const auto& collection = *coll;
@@ -1856,7 +1856,7 @@ StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getExecutorCoun
OperationContext* opCtx = expCtx->opCtx;
std::unique_ptr<WorkingSet> ws = std::make_unique<WorkingSet>();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(request.getQuery());
auto collation = request.getCollation().value_or(BSONObj());
findCommand->setCollation(collation);
@@ -2138,7 +2138,7 @@ QueryPlannerParams fillOutPlannerParamsForDistinct(OperationContext* opCtx,
const bool mayUnwindArrays = !(plannerOptions & QueryPlannerParams::STRICT_DISTINCT_ONLY);
std::unique_ptr<IndexCatalog::IndexIterator> ii =
collection->getIndexCatalog()->getIndexIterator(opCtx, false);
- auto query = parsedDistinct.getQuery()->getFindCommand().getFilter();
+ auto query = parsedDistinct.getQuery()->getFindCommandRequest().getFilter();
while (ii->more()) {
const IndexCatalogEntry* ice = ii->next();
const IndexDescriptor* desc = ice->descriptor();
@@ -2183,7 +2183,7 @@ QueryPlannerParams fillOutPlannerParamsForDistinct(OperationContext* opCtx,
}
const CanonicalQuery* canonicalQuery = parsedDistinct.getQuery();
- const BSONObj& hint = canonicalQuery->getFindCommand().getHint();
+ const BSONObj& hint = canonicalQuery->getFindCommandRequest().getHint();
applyIndexFilters(collection, *canonicalQuery, &plannerParams);
@@ -2223,7 +2223,7 @@ StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getExecutorForS
// If there's no query, we can just distinct-scan one of the indices. Not every index in
// plannerParams.indices may be suitable. Refer to getDistinctNodeIndex().
size_t distinctNodeIndex = 0;
- if (!parsedDistinct->getQuery()->getFindCommand().getFilter().isEmpty() ||
+ if (!parsedDistinct->getQuery()->getFindCommandRequest().getFilter().isEmpty() ||
parsedDistinct->getQuery()->getSortPattern() ||
!getDistinctNodeIndex(
plannerParams.indices, parsedDistinct->getKey(), collator, &distinctNodeIndex)) {
@@ -2344,7 +2344,7 @@ StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getExecutorWith
size_t plannerOptions) {
const auto& collection = *coll;
- auto findCommand = std::make_unique<FindCommand>(cq->getFindCommand());
+ auto findCommand = std::make_unique<FindCommandRequest>(cq->getFindCommandRequest());
findCommand->setProjection(BSONObj());
const boost::intrusive_ptr<ExpressionContext> expCtx;
diff --git a/src/mongo/db/query/get_executor.h b/src/mongo/db/query/get_executor.h
index 00ed169447c..92c8cf60f6c 100644
--- a/src/mongo/db/query/get_executor.h
+++ b/src/mongo/db/query/get_executor.h
@@ -176,9 +176,9 @@ bool turnIxscanIntoDistinctIxscan(QuerySolution* soln,
* A $group stage on a single field behaves similarly to a distinct command. If it has no
* accumulators or only $first accumulators, the $group command only needs to visit one document for
* each distinct value of the grouped-by (_id) field to compute its result. When there is a sort
- * order specified in parsedDistinct->getQuery()->getFindCommand().getSort(), the DISTINCT_SCAN will
- * follow that sort order, ensuring that it chooses the correct document from each group to compute
- * any $first accumulators.
+ * order specified in parsedDistinct->getQuery()->getFindCommandRequest().getSort(), DISTINCT_SCAN
+ * will follow that sort order, ensuring that it chooses the correct document from each group to
+ * compute any $first accumulators.
*
* Specify the QueryPlannerParams::STRICT_DISTINCT_ONLY flag in the 'params' argument to ensure that
* any resulting plan _guarantees_ it will return exactly one document per value of the distinct
@@ -216,7 +216,7 @@ StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getExecutorDist
StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getExecutorCount(
const boost::intrusive_ptr<ExpressionContext>& expCtx,
const CollectionPtr* collection,
- const CountCommand& request,
+ const CountCommandRequest& request,
bool explain,
const NamespaceString& nss);
diff --git a/src/mongo/db/query/get_executor_test.cpp b/src/mongo/db/query/get_executor_test.cpp
index e3ac2411131..a0e86069d28 100644
--- a/src/mongo/db/query/get_executor_test.cpp
+++ b/src/mongo/db/query/get_executor_test.cpp
@@ -74,7 +74,7 @@ unique_ptr<CanonicalQuery> canonicalize(const char* queryStr,
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(fromjson(queryStr));
findCommand->setSort(fromjson(sortStr));
findCommand->setProjection(fromjson(projStr));
diff --git a/src/mongo/db/query/getmore_command.idl b/src/mongo/db/query/getmore_command.idl
index 5ee61175118..c68cba81feb 100644
--- a/src/mongo/db/query/getmore_command.idl
+++ b/src/mongo/db/query/getmore_command.idl
@@ -38,7 +38,7 @@ imports:
commands:
getMore:
- cpp_name: GetMoreCommand
+ cpp_name: GetMoreCommandRequest
command_name: getMore
description: "Parser for the getMore command."
strict: true
diff --git a/src/mongo/db/query/kill_cursors.idl b/src/mongo/db/query/kill_cursors.idl
index 2563cd5a5d1..f9baa16bc63 100644
--- a/src/mongo/db/query/kill_cursors.idl
+++ b/src/mongo/db/query/kill_cursors.idl
@@ -44,7 +44,7 @@ types:
deserializer: "mongo::BSONElement::_numberLong"
structs:
- KillCursorsReply:
+ KillCursorsCommandReply:
description: 'Response from killCursors command'
strict: false
fields:
@@ -66,6 +66,8 @@ commands:
killCursors:
description: "Kills a specified set of cursors by ID."
command_name: killCursors
+ cpp_name: KillCursorsCommandRequest
+ reply_type: KillCursorsCommandReply
api_version: "1"
access_check:
complex:
@@ -79,8 +81,6 @@ commands:
- privilege:
resource_pattern: exact_namespace
action_type: killAnyCursor
- reply_type: KillCursorsReply
- cpp_name: KillCursorsRequest
strict: true
namespace: concatenate_with_db
fields:
diff --git a/src/mongo/db/query/killcursors_request_test.cpp b/src/mongo/db/query/killcursors_request_test.cpp
index 5535fa2c56f..692a76831e6 100644
--- a/src/mongo/db/query/killcursors_request_test.cpp
+++ b/src/mongo/db/query/killcursors_request_test.cpp
@@ -45,7 +45,7 @@ TEST(KillCursorsRequestTest, parseSuccess) {
<< "coll"
<< "cursors" << BSON_ARRAY(CursorId(123) << CursorId(456)) << "$db"
<< "db");
- KillCursorsRequest request = KillCursorsRequest::parse(ctxt, bsonObj);
+ KillCursorsCommandRequest request = KillCursorsCommandRequest::parse(ctxt, bsonObj);
ASSERT_EQ(request.getNamespace().ns(), "db.coll");
ASSERT_EQ(request.getCursorIds().size(), 2U);
ASSERT_EQ(request.getCursorIds()[0], CursorId(123));
@@ -57,7 +57,7 @@ TEST(KillCursorsRequestTest, parseCursorsFieldEmptyArray) {
<< "coll"
<< "cursors" << BSONArray() << "$db"
<< "db");
- KillCursorsRequest request = KillCursorsRequest::parse(ctxt, bsonObj);
+ KillCursorsCommandRequest request = KillCursorsCommandRequest::parse(ctxt, bsonObj);
ASSERT_EQ(request.getCursorIds().size(), 0U);
}
@@ -66,14 +66,14 @@ TEST(KillCursorsRequestTest, parseFirstFieldNotString) {
BSON("killCursors" << 99 << "cursors" << BSON_ARRAY(CursorId(123) << CursorId(456)) << "$db"
<< "db");
ASSERT_THROWS_CODE(
- KillCursorsRequest::parse(ctxt, bsonObj), AssertionException, ErrorCodes::BadValue);
+ KillCursorsCommandRequest::parse(ctxt, bsonObj), AssertionException, ErrorCodes::BadValue);
}
TEST(KillCursorsRequestTest, parseInvalidNamespace) {
auto bsonObj = BSON("killCursors"
<< "coll"
<< "cursors" << BSON_ARRAY(CursorId(123) << CursorId(456)));
- ASSERT_THROWS_CODE(KillCursorsRequest::parse(ctxt, bsonObj), AssertionException, 40414);
+ ASSERT_THROWS_CODE(KillCursorsCommandRequest::parse(ctxt, bsonObj), AssertionException, 40414);
}
TEST(KillCursorsRequestTest, parseCursorsFieldMissing) {
@@ -81,7 +81,7 @@ TEST(KillCursorsRequestTest, parseCursorsFieldMissing) {
<< "coll"
<< "$db"
<< "db");
- ASSERT_THROWS_CODE(KillCursorsRequest::parse(ctxt, bsonObj), AssertionException, 40414);
+ ASSERT_THROWS_CODE(KillCursorsCommandRequest::parse(ctxt, bsonObj), AssertionException, 40414);
}
TEST(KillCursorsRequestTest, parseCursorFieldNotArray) {
@@ -89,8 +89,9 @@ TEST(KillCursorsRequestTest, parseCursorFieldNotArray) {
<< "coll"
<< "cursors" << CursorId(123) << "$db"
<< "db");
- ASSERT_THROWS_CODE(
- KillCursorsRequest::parse(ctxt, bsonObj), AssertionException, ErrorCodes::TypeMismatch);
+ ASSERT_THROWS_CODE(KillCursorsCommandRequest::parse(ctxt, bsonObj),
+ AssertionException,
+ ErrorCodes::TypeMismatch);
}
TEST(KillCursorsRequestTest, parseCursorFieldArrayWithNonCursorIdValue) {
@@ -98,14 +99,15 @@ TEST(KillCursorsRequestTest, parseCursorFieldArrayWithNonCursorIdValue) {
<< "coll"
<< "cursors" << BSON_ARRAY(CursorId(123) << "String value") << "$db"
<< "db");
- ASSERT_THROWS_CODE(
- KillCursorsRequest::parse(ctxt, bsonObj), AssertionException, ErrorCodes::TypeMismatch);
+ ASSERT_THROWS_CODE(KillCursorsCommandRequest::parse(ctxt, bsonObj),
+ AssertionException,
+ ErrorCodes::TypeMismatch);
}
TEST(KillCursorsRequestTest, toBSON) {
const NamespaceString nss("db.coll");
std::vector<CursorId> cursorIds = {CursorId(123)};
- KillCursorsRequest request(nss, cursorIds);
+ KillCursorsCommandRequest request(nss, cursorIds);
BSONObj requestObj = request.toBSON(BSONObj{});
BSONObj expectedObj = BSON("killCursors"
<< "coll"
diff --git a/src/mongo/db/query/parsed_distinct.cpp b/src/mongo/db/query/parsed_distinct.cpp
index e797f9650c2..59c15f39f7b 100644
--- a/src/mongo/db/query/parsed_distinct.cpp
+++ b/src/mongo/db/query/parsed_distinct.cpp
@@ -171,7 +171,7 @@ StatusWith<BSONObj> ParsedDistinct::asAggregationCommand() const {
BSONObjBuilder aggregationBuilder;
invariant(_query);
- const FindCommand& findCommand = _query->getFindCommand();
+ const FindCommandRequest& findCommand = _query->getFindCommandRequest();
aggregationBuilder.append(
"aggregate", findCommand.getNamespaceOrUUID().nss().value_or(NamespaceString()).coll());
@@ -257,14 +257,14 @@ StatusWith<ParsedDistinct> ParsedDistinct::parse(OperationContext* opCtx,
const CollatorInterface* defaultCollator) {
IDLParserErrorContext ctx("distinct");
- DistinctCommand parsedDistinct(nss);
+ DistinctCommandRequest parsedDistinct(nss);
try {
- parsedDistinct = DistinctCommand::parse(ctx, cmdObj);
+ parsedDistinct = DistinctCommandRequest::parse(ctx, cmdObj);
} catch (...) {
return exceptionToStatus();
}
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
if (parsedDistinct.getKey().find('\0') != std::string::npos) {
return Status(ErrorCodes::Error(31032), "Key field cannot contain an embedded null byte");
@@ -325,7 +325,7 @@ StatusWith<ParsedDistinct> ParsedDistinct::parse(OperationContext* opCtx,
return cq.getStatus();
}
- if (cq.getValue()->getFindCommand().getCollation().isEmpty() && defaultCollator) {
+ if (cq.getValue()->getFindCommandRequest().getCollation().isEmpty() && defaultCollator) {
cq.getValue()->setCollator(defaultCollator->clone());
}
diff --git a/src/mongo/db/query/plan_cache.cpp b/src/mongo/db/query/plan_cache.cpp
index 6a78e017dee..b1bdb1f1ef5 100644
--- a/src/mongo/db/query/plan_cache.cpp
+++ b/src/mongo/db/query/plan_cache.cpp
@@ -121,7 +121,7 @@ StringBuilder& operator<<(StringBuilder& builder, const PlanCacheKey& key) {
//
bool PlanCache::shouldCacheQuery(const CanonicalQuery& query) {
- const FindCommand& findCommand = query.getFindCommand();
+ const FindCommandRequest& findCommand = query.getFindCommandRequest();
const MatchExpression* expr = query.root();
// Collection scan
@@ -157,7 +157,7 @@ bool PlanCache::shouldCacheQuery(const CanonicalQuery& query) {
}
// Tailable cursors won't get cached, just turn into collscans.
- if (query.getFindCommand().getTailable()) {
+ if (query.getFindCommandRequest().getTailable()) {
return false;
}
@@ -204,7 +204,7 @@ std::unique_ptr<PlanCacheEntry> PlanCacheEntry::create(
if (includeDebugInfo) {
// Strip projections on $-prefixed fields, as these are added by internal callers of the
// system and are not considered part of the user projection.
- const FindCommand& findCommand = query.getFindCommand();
+ const FindCommandRequest& findCommand = query.getFindCommandRequest();
BSONObjBuilder projBuilder;
for (auto elem : findCommand.getProjection()) {
if (elem.fieldName()[0] == '$') {
diff --git a/src/mongo/db/query/plan_cache_test.cpp b/src/mongo/db/query/plan_cache_test.cpp
index 6d2bb24bd0a..d719c911d0e 100644
--- a/src/mongo/db/query/plan_cache_test.cpp
+++ b/src/mongo/db/query/plan_cache_test.cpp
@@ -74,7 +74,7 @@ unique_ptr<CanonicalQuery> canonicalize(const BSONObj& queryObj) {
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(queryObj);
const boost::intrusive_ptr<ExpressionContext> expCtx;
auto statusWithCQ =
@@ -100,7 +100,7 @@ unique_ptr<CanonicalQuery> canonicalize(BSONObj query,
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(query);
findCommand->setSort(sort);
findCommand->setProjection(proj);
@@ -136,7 +136,7 @@ unique_ptr<CanonicalQuery> canonicalize(const char* queryStr,
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(fromjson(queryStr));
findCommand->setSort(fromjson(sortStr));
findCommand->setProjection(fromjson(projStr));
@@ -173,7 +173,7 @@ unique_ptr<CanonicalQuery> canonicalize(const char* queryStr,
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(fromjson(queryStr));
findCommand->setSort(fromjson(sortStr));
findCommand->setProjection(fromjson(projStr));
@@ -1017,7 +1017,7 @@ protected:
// Clean up any previous state from a call to runQueryFull or runQueryAsCommand.
solns.clear();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(query);
findCommand->setSort(sort);
findCommand->setProjection(proj);
@@ -1052,7 +1052,7 @@ protected:
solns.clear();
const bool isExplain = false;
- std::unique_ptr<FindCommand> findCommand(
+ std::unique_ptr<FindCommandRequest> findCommand(
query_request_helper::makeFromFindCommandForTests(cmdObj));
const boost::intrusive_ptr<ExpressionContext> expCtx;
@@ -1125,7 +1125,7 @@ protected:
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(query);
findCommand->setSort(sort);
findCommand->setProjection(proj);
diff --git a/src/mongo/db/query/plan_executor_impl.cpp b/src/mongo/db/query/plan_executor_impl.cpp
index 3d89b63a4ce..7c5f5dd4871 100644
--- a/src/mongo/db/query/plan_executor_impl.cpp
+++ b/src/mongo/db/query/plan_executor_impl.cpp
@@ -145,7 +145,8 @@ PlanExecutorImpl::PlanExecutorImpl(OperationContext* opCtx,
_nss = collection->ns();
} else {
invariant(_cq);
- _nss = _cq->getFindCommand().getNamespaceOrUUID().nss().value_or(NamespaceString());
+ _nss =
+ _cq->getFindCommandRequest().getNamespaceOrUUID().nss().value_or(NamespaceString());
}
}
diff --git a/src/mongo/db/query/plan_insert_listener.cpp b/src/mongo/db/query/plan_insert_listener.cpp
index 8591004401f..0d86c76c9e7 100644
--- a/src/mongo/db/query/plan_insert_listener.cpp
+++ b/src/mongo/db/query/plan_insert_listener.cpp
@@ -45,8 +45,9 @@ MONGO_FAIL_POINT_DEFINE(planExecutorHangWhileYieldedInWaitForInserts);
}
bool shouldListenForInserts(OperationContext* opCtx, CanonicalQuery* cq) {
- return cq && cq->getFindCommand().getTailable() && cq->getFindCommand().getAwaitData() &&
- awaitDataState(opCtx).shouldWaitForInserts && opCtx->checkForInterruptNoAssert().isOK() &&
+ return cq && cq->getFindCommandRequest().getTailable() &&
+ cq->getFindCommandRequest().getAwaitData() && awaitDataState(opCtx).shouldWaitForInserts &&
+ opCtx->checkForInterruptNoAssert().isOK() &&
awaitDataState(opCtx).waitForInsertsDeadline >
opCtx->getServiceContext()->getPreciseClockSource()->now();
}
diff --git a/src/mongo/db/query/planner_access.cpp b/src/mongo/db/query/planner_access.cpp
index fb20b0c6939..9e7855a44c7 100644
--- a/src/mongo/db/query/planner_access.cpp
+++ b/src/mongo/db/query/planner_access.cpp
@@ -224,7 +224,7 @@ std::unique_ptr<QuerySolutionNode> QueryPlannerAccess::makeCollectionScan(
params.options & QueryPlannerParams::OPLOG_SCAN_WAIT_FOR_VISIBLE;
// If the hint is {$natural: +-1} this changes the direction of the collection scan.
- const BSONObj& hint = query.getFindCommand().getHint();
+ const BSONObj& hint = query.getFindCommandRequest().getHint();
if (!hint.isEmpty()) {
BSONElement natural = hint[query_request_helper::kNaturalSortField];
if (natural) {
@@ -235,13 +235,13 @@ std::unique_ptr<QuerySolutionNode> QueryPlannerAccess::makeCollectionScan(
// If the client requested a resume token and we are scanning the oplog, prepare
// the collection scan to return timestamp-based tokens. Otherwise, we should
// return generic RecordId-based tokens.
- if (query.getFindCommand().getRequestResumeToken()) {
+ if (query.getFindCommandRequest().getRequestResumeToken()) {
csn->shouldTrackLatestOplogTimestamp = query.nss().isOplog();
csn->requestResumeToken = !query.nss().isOplog();
}
// Extract and assign the RecordId from the 'resumeAfter' token, if present.
- const BSONObj& resumeAfterObj = query.getFindCommand().getResumeAfter();
+ const BSONObj& resumeAfterObj = query.getFindCommandRequest().getResumeAfter();
if (!resumeAfterObj.isEmpty()) {
BSONElement recordIdElem = resumeAfterObj["$recordId"];
switch (recordIdElem.type()) {
@@ -1304,7 +1304,7 @@ std::unique_ptr<QuerySolutionNode> QueryPlannerAccess::buildIndexedAnd(
for (size_t i = 0; i < andResult->children.size(); ++i) {
andResult->children[i]->computeProperties();
if (andResult->children[i]->providedSorts().contains(
- query.getFindCommand().getSort())) {
+ query.getFindCommandRequest().getSort())) {
std::swap(andResult->children[i], andResult->children.back());
break;
}
@@ -1403,7 +1403,7 @@ std::unique_ptr<QuerySolutionNode> QueryPlannerAccess::buildIndexedOr(
// If all ixscanNodes can provide the sort, shouldReverseScan is populated with which
// scans to reverse.
shouldReverseScan =
- canProvideSortWithMergeSort(ixscanNodes, query.getFindCommand().getSort());
+ canProvideSortWithMergeSort(ixscanNodes, query.getFindCommandRequest().getSort());
}
if (!shouldReverseScan.empty()) {
@@ -1417,7 +1417,7 @@ std::unique_ptr<QuerySolutionNode> QueryPlannerAccess::buildIndexedOr(
}
auto msn = std::make_unique<MergeSortNode>();
- msn->sort = query.getFindCommand().getSort();
+ msn->sort = query.getFindCommandRequest().getSort();
msn->addChildren(std::move(ixscanNodes));
orResult = std::move(msn);
} else {
diff --git a/src/mongo/db/query/planner_analysis.cpp b/src/mongo/db/query/planner_analysis.cpp
index a0de5bd01bd..71892e12b51 100644
--- a/src/mongo/db/query/planner_analysis.cpp
+++ b/src/mongo/db/query/planner_analysis.cpp
@@ -372,7 +372,7 @@ std::unique_ptr<QuerySolutionNode> addSortKeyGeneratorStageIfNeeded(
const CanonicalQuery& query, bool hasSortStage, std::unique_ptr<QuerySolutionNode> solnRoot) {
if (!hasSortStage && query.metadataDeps()[DocumentMetadataFields::kSortKey]) {
auto keyGenNode = std::make_unique<SortKeyGeneratorNode>();
- keyGenNode->sortSpec = query.getFindCommand().getSort();
+ keyGenNode->sortSpec = query.getFindCommandRequest().getSort();
keyGenNode->children.push_back(solnRoot.release());
return keyGenNode;
}
@@ -539,8 +539,8 @@ std::unique_ptr<QuerySolutionNode> tryPushdownProjectBeneathSort(
bool canUseSimpleSort(const QuerySolutionNode& solnRoot,
const CanonicalQuery& cq,
const QueryPlannerParams& plannerParams) {
- const bool splitLimitedSortEligible = cq.getFindCommand().getNtoreturn() &&
- !cq.getFindCommand().getSingleBatch() &&
+ const bool splitLimitedSortEligible = cq.getFindCommandRequest().getNtoreturn() &&
+ !cq.getFindCommandRequest().getSingleBatch() &&
plannerParams.options & QueryPlannerParams::SPLIT_LIMITED_SORT;
// The simple sort stage discards any metadata other than sort key metadata. It can only be used
@@ -622,7 +622,7 @@ bool QueryPlannerAnalysis::explodeForSort(const CanonicalQuery& query,
// Find explodable nodes in the subtree rooted at 'toReplace'.
getExplodableNodes(toReplace, &explodableNodes);
- const BSONObj& desiredSort = query.getFindCommand().getSort();
+ const BSONObj& desiredSort = query.getFindCommandRequest().getSort();
// How many scan leaves will result from our expansion?
size_t totalNumScans = 0;
@@ -764,7 +764,7 @@ QuerySolutionNode* QueryPlannerAnalysis::analyzeSort(const CanonicalQuery& query
bool* blockingSortOut) {
*blockingSortOut = false;
- const FindCommand& findCommand = query.getFindCommand();
+ const FindCommandRequest& findCommand = query.getFindCommandRequest();
const BSONObj& sortObj = findCommand.getSort();
if (sortObj.isEmpty()) {
@@ -974,7 +974,7 @@ std::unique_ptr<QuerySolution> QueryPlannerAnalysis::analyzeDataAccess(
bool hasAndHashStage = solnRoot->hasNode(STAGE_AND_HASH);
soln->hasBlockingStage = hasSortStage || hasAndHashStage;
- const FindCommand& findCommand = query.getFindCommand();
+ const FindCommandRequest& findCommand = query.getFindCommandRequest();
if (findCommand.getSkip()) {
auto skip = std::make_unique<SkipNode>();
diff --git a/src/mongo/db/query/query_planner.cpp b/src/mongo/db/query/query_planner.cpp
index fb902758eb5..ab803e03254 100644
--- a/src/mongo/db/query/query_planner.cpp
+++ b/src/mongo/db/query/query_planner.cpp
@@ -341,7 +341,8 @@ std::unique_ptr<QuerySolution> buildWholeIXSoln(const IndexEntry& index,
}
bool providesSort(const CanonicalQuery& query, const BSONObj& kp) {
- return query.getFindCommand().getSort().isPrefixOf(kp, SimpleBSONElementComparator::kInstance);
+ return query.getFindCommandRequest().getSort().isPrefixOf(
+ kp, SimpleBSONElementComparator::kInstance);
}
StatusWith<std::unique_ptr<PlanCacheIndexTree>> QueryPlanner::cacheDataFromTaggedTree(
@@ -609,7 +610,7 @@ StatusWith<std::vector<std::unique_ptr<QuerySolution>>> QueryPlanner::plan(
}
const bool canTableScan = !(params.options & QueryPlannerParams::NO_TABLE_SCAN);
- const bool isTailable = query.getFindCommand().getTailable();
+ const bool isTailable = query.getFindCommandRequest().getTailable();
// If the query requests a tailable cursor, the only solution is a collscan + filter with
// tailable set on the collscan.
@@ -632,16 +633,16 @@ StatusWith<std::vector<std::unique_ptr<QuerySolution>>> QueryPlanner::plan(
// The hint can be {$natural: +/-1}. If this happens, output a collscan. We expect any $natural
// sort to have been normalized to a $natural hint upstream.
- if (!query.getFindCommand().getHint().isEmpty()) {
- const BSONObj& hintObj = query.getFindCommand().getHint();
+ if (!query.getFindCommandRequest().getHint().isEmpty()) {
+ const BSONObj& hintObj = query.getFindCommandRequest().getHint();
if (hintObj[query_request_helper::kNaturalSortField]) {
LOGV2_DEBUG(20969, 5, "Forcing a table scan due to hinted $natural");
if (!canTableScan) {
return Status(ErrorCodes::NoQueryExecutionPlans,
"hint $natural is not allowed, because 'notablescan' is enabled");
}
- if (!query.getFindCommand().getMin().isEmpty() ||
- !query.getFindCommand().getMax().isEmpty()) {
+ if (!query.getFindCommandRequest().getMin().isEmpty() ||
+ !query.getFindCommandRequest().getMax().isEmpty()) {
return Status(ErrorCodes::NoQueryExecutionPlans,
"min and max are incompatible with $natural");
}
@@ -661,7 +662,7 @@ StatusWith<std::vector<std::unique_ptr<QuerySolution>>> QueryPlanner::plan(
// requested in the query.
BSONObj hintedIndex;
if (!params.indexFiltersApplied) {
- hintedIndex = query.getFindCommand().getHint();
+ hintedIndex = query.getFindCommandRequest().getHint();
}
// Either the list of indices passed in by the caller, or the list of indices filtered according
@@ -717,15 +718,16 @@ StatusWith<std::vector<std::unique_ptr<QuerySolution>>> QueryPlanner::plan(
// Deal with the .min() and .max() query options. If either exist we can only use an index
// that matches the object inside.
- if (!query.getFindCommand().getMin().isEmpty() || !query.getFindCommand().getMax().isEmpty()) {
+ if (!query.getFindCommandRequest().getMin().isEmpty() ||
+ !query.getFindCommandRequest().getMax().isEmpty()) {
if (!hintedIndexEntry) {
return Status(ErrorCodes::Error(51173),
"When using min()/max() a hint of which index to use must be provided");
}
- BSONObj minObj = query.getFindCommand().getMin();
- BSONObj maxObj = query.getFindCommand().getMax();
+ BSONObj minObj = query.getFindCommandRequest().getMin();
+ BSONObj maxObj = query.getFindCommandRequest().getMax();
if ((!minObj.isEmpty() &&
!indexCompatibleMaxMin(minObj, query.getCollator(), *hintedIndexEntry)) ||
@@ -787,7 +789,7 @@ StatusWith<std::vector<std::unique_ptr<QuerySolution>>> QueryPlanner::plan(
//
// TEXT and GEO_NEAR are special because they require the use of a text/geo index in order
// to be evaluated correctly. Stripping these "mandatory assignments" is therefore invalid.
- if (query.getFindCommand().getProjection().isEmpty() &&
+ if (query.getFindCommandRequest().getProjection().isEmpty() &&
!QueryPlannerCommon::hasNode(query.root(), MatchExpression::GEO_NEAR) &&
!QueryPlannerCommon::hasNode(query.root(), MatchExpression::TEXT)) {
QueryPlannerIXSelect::stripUnneededAssignments(query.root(), relevantIndices);
diff --git a/src/mongo/db/query/query_planner_options_test.cpp b/src/mongo/db/query/query_planner_options_test.cpp
index 3ff3392fcae..c83f920ada9 100644
--- a/src/mongo/db/query/query_planner_options_test.cpp
+++ b/src/mongo/db/query/query_planner_options_test.cpp
@@ -828,7 +828,7 @@ TEST_F(QueryPlannerTest, CacheDataFromTaggedTreeFailsOnBadInput) {
// No relevant index matching the index tag.
relevantIndices.push_back(buildSimpleIndexEntry(BSON("a" << 1), "a_1"));
- auto findCommand = std::make_unique<FindCommand>(NamespaceString("test.collection"));
+ auto findCommand = std::make_unique<FindCommandRequest>(NamespaceString("test.collection"));
findCommand->setFilter(BSON("a" << 3));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx.get(), std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
@@ -842,7 +842,7 @@ TEST_F(QueryPlannerTest, CacheDataFromTaggedTreeFailsOnBadInput) {
TEST_F(QueryPlannerTest, TagAccordingToCacheFailsOnBadInput) {
const NamespaceString nss("test.collection");
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("a" << 3));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx.get(), std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
@@ -871,7 +871,7 @@ TEST_F(QueryPlannerTest, TagAccordingToCacheFailsOnBadInput) {
ASSERT_OK(s);
// Regenerate canonical query in order to clear tags.
- auto newQR = std::make_unique<FindCommand>(nss);
+ auto newQR = std::make_unique<FindCommandRequest>(nss);
newQR->setFilter(BSON("a" << 3));
statusWithCQ = CanonicalQuery::canonicalize(opCtx.get(), std::move(newQR));
ASSERT_OK(statusWithCQ.getStatus());
diff --git a/src/mongo/db/query/query_planner_test_fixture.cpp b/src/mongo/db/query/query_planner_test_fixture.cpp
index 4abe9524abf..b9e25876ad6 100644
--- a/src/mongo/db/query/query_planner_test_fixture.cpp
+++ b/src/mongo/db/query/query_planner_test_fixture.cpp
@@ -326,7 +326,7 @@ void QueryPlannerTest::runQueryFull(const BSONObj& query,
const BSONObj& maxObj) {
clearState();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(query);
findCommand->setSort(sort);
findCommand->setProjection(proj);
@@ -407,7 +407,7 @@ void QueryPlannerTest::runInvalidQueryFull(const BSONObj& query,
const BSONObj& maxObj) {
clearState();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(query);
findCommand->setSort(sort);
findCommand->setProjection(proj);
@@ -450,7 +450,7 @@ void QueryPlannerTest::runQueryAsCommand(const BSONObj& cmdObj) {
// If there is no '$db', append it.
auto cmd = OpMsgRequest::fromDBAndBody(nss.db(), cmdObj).body;
- std::unique_ptr<FindCommand> findCommand(
+ std::unique_ptr<FindCommandRequest> findCommand(
query_request_helper::makeFromFindCommandForTests(cmd, nss));
auto statusWithCQ =
@@ -477,7 +477,7 @@ void QueryPlannerTest::runInvalidQueryAsCommand(const BSONObj& cmdObj) {
// If there is no '$db', append it.
auto cmd = OpMsgRequest::fromDBAndBody(nss.db(), cmdObj).body;
- std::unique_ptr<FindCommand> findCommand(
+ std::unique_ptr<FindCommandRequest> findCommand(
query_request_helper::makeFromFindCommandForTests(cmd, nss));
auto statusWithCQ =
diff --git a/src/mongo/db/query/query_request_helper.cpp b/src/mongo/db/query/query_request_helper.cpp
index 90b98665c75..a7637728603 100644
--- a/src/mongo/db/query/query_request_helper.cpp
+++ b/src/mongo/db/query/query_request_helper.cpp
@@ -49,7 +49,7 @@ namespace {
*
* This contains flags such as tailable, exhaust, and noCursorTimeout.
*/
-void initFromInt(int options, FindCommand* findCommand) {
+void initFromInt(int options, FindCommandRequest* findCommand) {
bool tailable = (options & QueryOption_CursorTailable) != 0;
bool awaitData = (options & QueryOption_AwaitData) != 0;
if (awaitData) {
@@ -70,7 +70,7 @@ void initFromInt(int options, FindCommand* findCommand) {
/**
* Updates the projection object with a $meta projection for the showRecordId option.
*/
-void addShowRecordIdMetaProj(FindCommand* findCommand) {
+void addShowRecordIdMetaProj(FindCommandRequest* findCommand) {
if (findCommand->getProjection()["$recordId"]) {
// There's already some projection on $recordId. Don't overwrite it.
return;
@@ -86,13 +86,13 @@ void addShowRecordIdMetaProj(FindCommand* findCommand) {
/**
* Add the meta projection to this object if needed.
*/
-void addMetaProjection(FindCommand* findCommand) {
+void addMetaProjection(FindCommandRequest* findCommand) {
if (findCommand->getShowRecordId()) {
addShowRecordIdMetaProj(findCommand);
}
}
-Status initFullQuery(const BSONObj& top, FindCommand* findCommand, bool* explain) {
+Status initFullQuery(const BSONObj& top, FindCommandRequest* findCommand, bool* explain) {
BSONObjIterator i(top);
while (i.more()) {
@@ -185,14 +185,14 @@ Status initFullQuery(const BSONObj& top, FindCommand* findCommand, bool* explain
return Status::OK();
}
-Status initFindCommand(int ntoskip,
- int ntoreturn,
- int queryOptions,
- const BSONObj& queryObj,
- const BSONObj& proj,
- bool fromQueryMessage,
- FindCommand* findCommand,
- bool* explain) {
+Status initFindCommandRequest(int ntoskip,
+ int ntoreturn,
+ int queryOptions,
+ const BSONObj& queryObj,
+ const BSONObj& proj,
+ bool fromQueryMessage,
+ FindCommandRequest* findCommand,
+ bool* explain) {
if (!proj.isEmpty()) {
findCommand->setProjection(proj.getOwned());
}
@@ -244,7 +244,7 @@ Status initFindCommand(int ntoskip,
findCommand->setFilter(queryObj.getOwned());
}
- return validateFindCommand(*findCommand);
+ return validateFindCommandRequest(*findCommand);
}
} // namespace
@@ -265,7 +265,7 @@ Status validateGetMoreCollectionName(StringData collectionName) {
return Status::OK();
}
-Status validateFindCommand(const FindCommand& findCommand) {
+Status validateFindCommandRequest(const FindCommandRequest& findCommand) {
// Min and Max objects must have the same fields.
if (!findCommand.getMin().isEmpty() && !findCommand.getMax().isEmpty()) {
if (!findCommand.getMin().isFieldNamePrefixOf(findCommand.getMax()) ||
@@ -327,7 +327,7 @@ Status validateFindCommand(const FindCommand& findCommand) {
return Status::OK();
}
-void refreshNSS(const NamespaceString& nss, FindCommand* findCommand) {
+void refreshNSS(const NamespaceString& nss, FindCommandRequest* findCommand) {
if (findCommand->getNamespaceOrUUID().uuid()) {
auto& nssOrUUID = findCommand->getNamespaceOrUUID();
nssOrUUID.setNss(nss);
@@ -335,12 +335,12 @@ void refreshNSS(const NamespaceString& nss, FindCommand* findCommand) {
invariant(findCommand->getNamespaceOrUUID().nss());
}
-std::unique_ptr<FindCommand> makeFromFindCommand(const BSONObj& cmdObj,
- boost::optional<NamespaceString> nss,
- bool apiStrict) {
+std::unique_ptr<FindCommandRequest> makeFromFindCommand(const BSONObj& cmdObj,
+ boost::optional<NamespaceString> nss,
+ bool apiStrict) {
- auto findCommand = std::make_unique<FindCommand>(
- FindCommand::parse(IDLParserErrorContext("FindCommand", apiStrict), cmdObj));
+ auto findCommand = std::make_unique<FindCommandRequest>(
+ FindCommandRequest::parse(IDLParserErrorContext("FindCommandRequest", apiStrict), cmdObj));
// If there is an explicit namespace specified overwite it.
if (nss) {
@@ -356,14 +356,13 @@ std::unique_ptr<FindCommand> makeFromFindCommand(const BSONObj& cmdObj,
if (findCommand->getLimit() && *findCommand->getLimit() == 0) {
findCommand->setLimit(boost::none);
}
- uassertStatusOK(validateFindCommand(*findCommand));
+ uassertStatusOK(validateFindCommandRequest(*findCommand));
return findCommand;
}
-std::unique_ptr<FindCommand> makeFromFindCommandForTests(const BSONObj& cmdObj,
- boost::optional<NamespaceString> nss,
- bool apiStrict) {
+std::unique_ptr<FindCommandRequest> makeFromFindCommandForTests(
+ const BSONObj& cmdObj, boost::optional<NamespaceString> nss, bool apiStrict) {
return makeFromFindCommand(cmdObj, nss, apiStrict);
}
@@ -395,7 +394,7 @@ bool isTextScoreMeta(BSONElement elt) {
return true;
}
-void setTailableMode(TailableModeEnum tailableMode, FindCommand* findCommand) {
+void setTailableMode(TailableModeEnum tailableMode, FindCommandRequest* findCommand) {
if (tailableMode == TailableModeEnum::kTailableAndAwaitData) {
findCommand->setAwaitData(true);
findCommand->setTailable(true);
@@ -404,7 +403,7 @@ void setTailableMode(TailableModeEnum tailableMode, FindCommand* findCommand) {
}
}
-TailableModeEnum getTailableMode(const FindCommand& findCommand) {
+TailableModeEnum getTailableMode(const FindCommandRequest& findCommand) {
return uassertStatusOK(
tailableModeFromBools(findCommand.getTailable(), findCommand.getAwaitData()));
}
@@ -419,18 +418,18 @@ void validateCursorResponse(const BSONObj& outputAsBson) {
// Old QueryRequest parsing code: SOON TO BE DEPRECATED.
//
-StatusWith<std::unique_ptr<FindCommand>> fromLegacyQueryMessage(const QueryMessage& qm,
- bool* explain) {
- auto findCommand = std::make_unique<FindCommand>(NamespaceString(qm.ns));
-
- Status status = initFindCommand(qm.ntoskip,
- qm.ntoreturn,
- qm.queryOptions,
- qm.query,
- qm.fields,
- true,
- findCommand.get(),
- explain);
+StatusWith<std::unique_ptr<FindCommandRequest>> fromLegacyQueryMessage(const QueryMessage& qm,
+ bool* explain) {
+ auto findCommand = std::make_unique<FindCommandRequest>(NamespaceString(qm.ns));
+
+ Status status = initFindCommandRequest(qm.ntoskip,
+ qm.ntoreturn,
+ qm.queryOptions,
+ qm.query,
+ qm.fields,
+ true,
+ findCommand.get(),
+ explain);
if (!status.isOK()) {
return status;
}
@@ -438,16 +437,16 @@ StatusWith<std::unique_ptr<FindCommand>> fromLegacyQueryMessage(const QueryMessa
return std::move(findCommand);
}
-StatusWith<std::unique_ptr<FindCommand>> fromLegacyQuery(NamespaceStringOrUUID nssOrUuid,
- const BSONObj& queryObj,
- const BSONObj& proj,
- int ntoskip,
- int ntoreturn,
- int queryOptions,
- bool* explain) {
- auto findCommand = std::make_unique<FindCommand>(std::move(nssOrUuid));
+StatusWith<std::unique_ptr<FindCommandRequest>> fromLegacyQuery(NamespaceStringOrUUID nssOrUuid,
+ const BSONObj& queryObj,
+ const BSONObj& proj,
+ int ntoskip,
+ int ntoreturn,
+ int queryOptions,
+ bool* explain) {
+ auto findCommand = std::make_unique<FindCommandRequest>(std::move(nssOrUuid));
- Status status = initFindCommand(
+ Status status = initFindCommandRequest(
ntoskip, ntoreturn, queryOptions, queryObj, proj, true, findCommand.get(), explain);
if (!status.isOK()) {
return status;
@@ -456,28 +455,28 @@ StatusWith<std::unique_ptr<FindCommand>> fromLegacyQuery(NamespaceStringOrUUID n
return std::move(findCommand);
}
-StatusWith<BSONObj> asAggregationCommand(const FindCommand& findCommand) {
+StatusWith<BSONObj> asAggregationCommand(const FindCommandRequest& findCommand) {
BSONObjBuilder aggregationBuilder;
// First, check if this query has options that are not supported in aggregation.
if (!findCommand.getMin().isEmpty()) {
return {ErrorCodes::InvalidPipelineOperator,
- str::stream() << "Option " << FindCommand::kMinFieldName
+ str::stream() << "Option " << FindCommandRequest::kMinFieldName
<< " not supported in aggregation."};
}
if (!findCommand.getMax().isEmpty()) {
return {ErrorCodes::InvalidPipelineOperator,
- str::stream() << "Option " << FindCommand::kMaxFieldName
+ str::stream() << "Option " << FindCommandRequest::kMaxFieldName
<< " not supported in aggregation."};
}
if (findCommand.getReturnKey()) {
return {ErrorCodes::InvalidPipelineOperator,
- str::stream() << "Option " << FindCommand::kReturnKeyFieldName
+ str::stream() << "Option " << FindCommandRequest::kReturnKeyFieldName
<< " not supported in aggregation."};
}
if (findCommand.getShowRecordId()) {
return {ErrorCodes::InvalidPipelineOperator,
- str::stream() << "Option " << FindCommand::kShowRecordIdFieldName
+ str::stream() << "Option " << FindCommandRequest::kShowRecordIdFieldName
<< " not supported in aggregation."};
}
if (findCommand.getTailable()) {
@@ -486,12 +485,12 @@ StatusWith<BSONObj> asAggregationCommand(const FindCommand& findCommand) {
}
if (findCommand.getNoCursorTimeout()) {
return {ErrorCodes::InvalidPipelineOperator,
- str::stream() << "Option " << FindCommand::kNoCursorTimeoutFieldName
+ str::stream() << "Option " << FindCommandRequest::kNoCursorTimeoutFieldName
<< " not supported in aggregation."};
}
if (findCommand.getAllowPartialResults()) {
return {ErrorCodes::InvalidPipelineOperator,
- str::stream() << "Option " << FindCommand::kAllowPartialResultsFieldName
+ str::stream() << "Option " << FindCommandRequest::kAllowPartialResultsFieldName
<< " not supported in aggregation."};
}
if (findCommand.getNtoreturn()) {
@@ -507,30 +506,31 @@ StatusWith<BSONObj> asAggregationCommand(const FindCommand& findCommand) {
// special exception if 'limit' is set to 1.
if (findCommand.getSingleBatch() && findCommand.getLimit().value_or(0) != 1LL) {
return {ErrorCodes::InvalidPipelineOperator,
- str::stream() << "Option " << FindCommand::kSingleBatchFieldName
+ str::stream() << "Option " << FindCommandRequest::kSingleBatchFieldName
<< " not supported in aggregation."};
}
if (findCommand.getReadOnce()) {
return {ErrorCodes::InvalidPipelineOperator,
- str::stream() << "Option " << FindCommand::kReadOnceFieldName
+ str::stream() << "Option " << FindCommandRequest::kReadOnceFieldName
<< " not supported in aggregation."};
}
if (findCommand.getAllowSpeculativeMajorityRead()) {
return {ErrorCodes::InvalidPipelineOperator,
- str::stream() << "Option " << FindCommand::kAllowSpeculativeMajorityReadFieldName
+ str::stream() << "Option "
+ << FindCommandRequest::kAllowSpeculativeMajorityReadFieldName
<< " not supported in aggregation."};
}
if (findCommand.getRequestResumeToken()) {
return {ErrorCodes::InvalidPipelineOperator,
- str::stream() << "Option " << FindCommand::kRequestResumeTokenFieldName
+ str::stream() << "Option " << FindCommandRequest::kRequestResumeTokenFieldName
<< " not supported in aggregation."};
}
if (!findCommand.getResumeAfter().isEmpty()) {
return {ErrorCodes::InvalidPipelineOperator,
- str::stream() << "Option " << FindCommand::kResumeAfterFieldName
+ str::stream() << "Option " << FindCommandRequest::kResumeAfterFieldName
<< " not supported in aggregation."};
}
@@ -572,7 +572,8 @@ StatusWith<BSONObj> asAggregationCommand(const FindCommand& findCommand) {
// The aggregation 'cursor' option is always set, regardless of the presence of batchSize.
BSONObjBuilder batchSizeBuilder(aggregationBuilder.subobjStart("cursor"));
if (findCommand.getBatchSize()) {
- batchSizeBuilder.append(FindCommand::kBatchSizeFieldName, *findCommand.getBatchSize());
+ batchSizeBuilder.append(FindCommandRequest::kBatchSizeFieldName,
+ *findCommand.getBatchSize());
}
batchSizeBuilder.doneFast();
@@ -583,27 +584,27 @@ StatusWith<BSONObj> asAggregationCommand(const FindCommand& findCommand) {
aggregationBuilder.append(cmdOptionMaxTimeMS, maxTimeMS);
}
if (!findCommand.getHint().isEmpty()) {
- aggregationBuilder.append(FindCommand::kHintFieldName, findCommand.getHint());
+ aggregationBuilder.append(FindCommandRequest::kHintFieldName, findCommand.getHint());
}
if (findCommand.getReadConcern()) {
aggregationBuilder.append("readConcern", *findCommand.getReadConcern());
}
if (!findCommand.getUnwrappedReadPref().isEmpty()) {
- aggregationBuilder.append(FindCommand::kUnwrappedReadPrefFieldName,
+ aggregationBuilder.append(FindCommandRequest::kUnwrappedReadPrefFieldName,
findCommand.getUnwrappedReadPref());
}
if (findCommand.getAllowDiskUse()) {
- aggregationBuilder.append(FindCommand::kAllowDiskUseFieldName,
+ aggregationBuilder.append(FindCommandRequest::kAllowDiskUseFieldName,
static_cast<bool>(findCommand.getAllowDiskUse()));
}
if (findCommand.getLegacyRuntimeConstants()) {
BSONObjBuilder rtcBuilder(
- aggregationBuilder.subobjStart(FindCommand::kLegacyRuntimeConstantsFieldName));
+ aggregationBuilder.subobjStart(FindCommandRequest::kLegacyRuntimeConstantsFieldName));
findCommand.getLegacyRuntimeConstants()->serialize(&rtcBuilder);
rtcBuilder.doneFast();
}
if (findCommand.getLet()) {
- aggregationBuilder.append(FindCommand::kLetFieldName, *findCommand.getLet());
+ aggregationBuilder.append(FindCommandRequest::kLetFieldName, *findCommand.getLet());
}
return StatusWith<BSONObj>(aggregationBuilder.obj());
}
diff --git a/src/mongo/db/query/query_request_helper.h b/src/mongo/db/query/query_request_helper.h
index 974269d16c5..2617c9231d4 100644
--- a/src/mongo/db/query/query_request_helper.h
+++ b/src/mongo/db/query/query_request_helper.h
@@ -68,36 +68,36 @@ Status validateGetMoreCollectionName(StringData collectionName);
* value) or if there is a bad combination of options (e.g. awaitData is illegal without
* tailable).
*/
-Status validateFindCommand(const FindCommand& findCommand);
+Status validateFindCommandRequest(const FindCommandRequest& findCommand);
/**
* Parses a find command object, 'cmdObj'. Caller must indicate whether or not this lite
* parsed query is an explained query or not via 'isExplain'. Accepts a NSS with which
- * to initialize the FindCommand if there is no UUID in cmdObj.
+ * to initialize the FindCommandRequest if there is no UUID in cmdObj.
*
- * Returns a heap allocated FindCommand on success or an error if 'cmdObj' is not well
+ * Returns a heap allocated FindCommandRequest on success or an error if 'cmdObj' is not well
* formed.
*/
-std::unique_ptr<FindCommand> makeFromFindCommand(const BSONObj& cmdObj,
- boost::optional<NamespaceString> nss,
- bool apiStrict);
+std::unique_ptr<FindCommandRequest> makeFromFindCommand(const BSONObj& cmdObj,
+ boost::optional<NamespaceString> nss,
+ bool apiStrict);
-std::unique_ptr<FindCommand> makeFromFindCommandForTests(
+std::unique_ptr<FindCommandRequest> makeFromFindCommandForTests(
const BSONObj& cmdObj,
boost::optional<NamespaceString> nss = boost::none,
bool apiStrict = false);
/**
- * If _uuid exists for this FindCommand, update the value of _nss.
+ * If _uuid exists for this FindCommandRequest, update the value of _nss.
*/
-void refreshNSS(const NamespaceString& nss, FindCommand* findCommand);
+void refreshNSS(const NamespaceString& nss, FindCommandRequest* findCommand);
/**
- * Converts this FindCommand into an aggregation using $match. If this FindCommand has options
- * that cannot be satisfied by aggregation, a non-OK status is returned and 'cmdBuilder' is not
- * modified.
+ * Converts this FindCommandRequest into an aggregation using $match. If this FindCommandRequest has
+ * options that cannot be satisfied by aggregation, a non-OK status is returned and 'cmdBuilder' is
+ * not modified.
*/
-StatusWith<BSONObj> asAggregationCommand(const FindCommand& findCommand);
+StatusWith<BSONObj> asAggregationCommand(const FindCommandRequest& findCommand);
/**
* Helper function to identify text search sort key
@@ -134,9 +134,9 @@ static constexpr auto kMaxTimeMSOpOnlyMaxPadding = 100LL;
static constexpr auto kDefaultBatchSize = 101ll;
-void setTailableMode(TailableModeEnum tailableMode, FindCommand* findCommand);
+void setTailableMode(TailableModeEnum tailableMode, FindCommandRequest* findCommand);
-TailableModeEnum getTailableMode(const FindCommand& findCommand);
+TailableModeEnum getTailableMode(const FindCommandRequest& findCommand);
/**
* Asserts whether the cursor response adhere to the format defined in IDL.
@@ -148,29 +148,22 @@ void validateCursorResponse(const BSONObj& outputAsBson);
//
/**
- * Parse the provided QueryMessage and return a heap constructed FindCommand, which
+ * Parse the provided QueryMessage and return a heap constructed FindCommandRequest, which
* represents it or an error.
*/
-StatusWith<std::unique_ptr<FindCommand>> fromLegacyQueryMessage(const QueryMessage& qm,
- bool* explain);
+StatusWith<std::unique_ptr<FindCommandRequest>> fromLegacyQueryMessage(const QueryMessage& qm,
+ bool* explain);
/**
- * Parse the provided legacy query object and parameters to construct a FindCommand.
+ * Parse the provided legacy query object and parameters to construct a FindCommandRequest.
*/
-StatusWith<std::unique_ptr<FindCommand>> fromLegacyQuery(NamespaceStringOrUUID nsOrUuid,
- const BSONObj& queryObj,
- const BSONObj& proj,
- int ntoskip,
- int ntoreturn,
- int queryOptions,
- bool* explain);
-
-StatusWith<std::unique_ptr<FindCommand>> fromLegacyQueryFindCommand(NamespaceStringOrUUID nsOrUuid,
- const BSONObj& queryObj,
- const BSONObj& proj,
- int ntoskip,
- int ntoreturn,
- int queryOptions);
+StatusWith<std::unique_ptr<FindCommandRequest>> fromLegacyQuery(NamespaceStringOrUUID nsOrUuid,
+ const BSONObj& queryObj,
+ const BSONObj& proj,
+ int ntoskip,
+ int ntoreturn,
+ int queryOptions,
+ bool* explain);
} // namespace query_request_helper
} // namespace mongo
diff --git a/src/mongo/db/query/query_request_test.cpp b/src/mongo/db/query/query_request_test.cpp
index 4b40ed4bbf3..e60a04ff79e 100644
--- a/src/mongo/db/query/query_request_test.cpp
+++ b/src/mongo/db/query/query_request_test.cpp
@@ -53,137 +53,137 @@ using unittest::assertGet;
static const NamespaceString testns("testdb.testcoll");
TEST(QueryRequestTest, LimitWithNToReturn) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setLimit(1);
findCommand.setNtoreturn(0);
- ASSERT_NOT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_NOT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, BatchSizeWithNToReturn) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setBatchSize(0);
findCommand.setNtoreturn(0);
- ASSERT_NOT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_NOT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, NegativeSkip) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
ASSERT_THROWS_CODE(findCommand.setSkip(-1), DBException, 51024);
}
TEST(QueryRequestTest, ZeroSkip) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setSkip(0);
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, PositiveSkip) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setSkip(1);
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, NegativeLimit) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
ASSERT_THROWS_CODE(findCommand.setLimit(-1), DBException, 51024);
}
TEST(QueryRequestTest, ZeroLimit) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setLimit(0);
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, PositiveLimit) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setLimit(1);
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, NegativeBatchSize) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
ASSERT_THROWS_CODE(findCommand.setBatchSize(-1), DBException, 51024);
}
TEST(QueryRequestTest, ZeroBatchSize) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setBatchSize(0);
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, PositiveBatchSize) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setBatchSize(1);
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, NegativeNToReturn) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
ASSERT_THROWS_CODE(findCommand.setNtoreturn(-1), DBException, 51024);
}
TEST(QueryRequestTest, ZeroNToReturn) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setNtoreturn(0);
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, PositiveNToReturn) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setNtoreturn(1);
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, NegativeMaxTimeMS) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
ASSERT_THROWS_CODE(findCommand.setMaxTimeMS(-1), DBException, 51024);
}
TEST(QueryRequestTest, ZeroMaxTimeMS) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setMaxTimeMS(0);
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, PositiveMaxTimeMS) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setMaxTimeMS(1);
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, ValidSortOrder) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setSort(fromjson("{a: 1}"));
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, DoesNotErrorOnInvalidSortPattern) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setSort(fromjson("{a: \"\"}"));
- // FindCommand isn't responsible for validating the sort pattern, so it is considered valid
- // even though the sort pattern {a: ""} is not well-formed.
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ // FindCommandRequest isn't responsible for validating the sort pattern, so it is considered
+ // valid even though the sort pattern {a: ""} is not well-formed.
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, MinFieldsNotPrefixOfMax) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setMin(fromjson("{a: 1}"));
findCommand.setMax(fromjson("{b: 1}"));
- ASSERT_NOT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_NOT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, MinFieldsMoreThanMax) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setMin(fromjson("{a: 1, b: 1}"));
findCommand.setMax(fromjson("{a: 1}"));
- ASSERT_NOT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_NOT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, MinFieldsLessThanMax) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setMin(fromjson("{a: 1}"));
findCommand.setMax(fromjson("{a: 1, b: 1}"));
- ASSERT_NOT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_NOT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, ForbidTailableWithNonNaturalSort) {
@@ -224,122 +224,122 @@ TEST(QueryRequestTest, AllowTailableWithNaturalSort) {
//
TEST(QueryRequestTest, ValidSortProj) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setProjection(fromjson("{a: 1}"));
findCommand.setSort(fromjson("{a: 1}"));
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
- FindCommand metaFC(testns);
+ FindCommandRequest metaFC(testns);
metaFC.setProjection(fromjson("{a: {$meta: \"textScore\"}}"));
metaFC.setSort(fromjson("{a: {$meta: \"textScore\"}}"));
- ASSERT_OK(query_request_helper::validateFindCommand(metaFC));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(metaFC));
}
TEST(QueryRequestTest, TextScoreMetaSortOnFieldDoesNotRequireMetaProjection) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setProjection(fromjson("{b: 1}"));
findCommand.setSort(fromjson("{a: {$meta: 'textScore'}}"));
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, TextScoreMetaProjectionDoesNotRequireTextScoreMetaSort) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setProjection(fromjson("{a: {$meta: \"textScore\"}}"));
findCommand.setSort(fromjson("{b: 1}"));
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, RequestResumeTokenWithHint) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setRequestResumeToken(true);
- ASSERT_NOT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_NOT_OK(query_request_helper::validateFindCommandRequest(findCommand));
findCommand.setHint(fromjson("{a: 1}"));
- ASSERT_NOT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_NOT_OK(query_request_helper::validateFindCommandRequest(findCommand));
findCommand.setHint(fromjson("{$natural: 1}"));
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, RequestResumeTokenWithSort) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setRequestResumeToken(true);
// Hint must be explicitly set for the query request to validate.
findCommand.setHint(fromjson("{$natural: 1}"));
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
findCommand.setSort(fromjson("{a: 1}"));
- ASSERT_NOT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_NOT_OK(query_request_helper::validateFindCommandRequest(findCommand));
findCommand.setSort(fromjson("{$natural: 1}"));
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, InvalidResumeAfterWrongRecordIdType) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
BSONObj resumeAfter = BSON("$recordId" << 1);
findCommand.setResumeAfter(resumeAfter);
findCommand.setRequestResumeToken(true);
// Hint must be explicitly set for the query request to validate.
findCommand.setHint(fromjson("{$natural: 1}"));
- ASSERT_NOT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_NOT_OK(query_request_helper::validateFindCommandRequest(findCommand));
resumeAfter = BSON("$recordId" << 1LL);
findCommand.setResumeAfter(resumeAfter);
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, InvalidResumeAfterExtraField) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
BSONObj resumeAfter = BSON("$recordId" << 1LL << "$extra" << 1);
findCommand.setResumeAfter(resumeAfter);
findCommand.setRequestResumeToken(true);
// Hint must be explicitly set for the query request to validate.
findCommand.setHint(fromjson("{$natural: 1}"));
- ASSERT_NOT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_NOT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, ResumeAfterWithHint) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
BSONObj resumeAfter = BSON("$recordId" << 1LL);
findCommand.setResumeAfter(resumeAfter);
findCommand.setRequestResumeToken(true);
- ASSERT_NOT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_NOT_OK(query_request_helper::validateFindCommandRequest(findCommand));
findCommand.setHint(fromjson("{a: 1}"));
- ASSERT_NOT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_NOT_OK(query_request_helper::validateFindCommandRequest(findCommand));
findCommand.setHint(fromjson("{$natural: 1}"));
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, ResumeAfterWithSort) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
BSONObj resumeAfter = BSON("$recordId" << 1LL);
findCommand.setResumeAfter(resumeAfter);
findCommand.setRequestResumeToken(true);
// Hint must be explicitly set for the query request to validate.
findCommand.setHint(fromjson("{$natural: 1}"));
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
findCommand.setSort(fromjson("{a: 1}"));
- ASSERT_NOT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_NOT_OK(query_request_helper::validateFindCommandRequest(findCommand));
findCommand.setSort(fromjson("{$natural: 1}"));
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, ResumeNoSpecifiedRequestResumeToken) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
BSONObj resumeAfter = BSON("$recordId" << 1LL);
findCommand.setResumeAfter(resumeAfter);
// Hint must be explicitly set for the query request to validate.
findCommand.setHint(fromjson("{$natural: 1}"));
- ASSERT_NOT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_NOT_OK(query_request_helper::validateFindCommandRequest(findCommand));
findCommand.setRequestResumeToken(true);
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
TEST(QueryRequestTest, ExplicitEmptyResumeAfter) {
- FindCommand findCommand(NamespaceString::kRsOplogNamespace);
+ FindCommandRequest findCommand(NamespaceString::kRsOplogNamespace);
BSONObj resumeAfter = fromjson("{}");
// Hint must be explicitly set for the query request to validate.
findCommand.setHint(fromjson("{$natural: 1}"));
findCommand.setResumeAfter(resumeAfter);
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
findCommand.setRequestResumeToken(true);
- ASSERT_OK(query_request_helper::validateFindCommand(findCommand));
+ ASSERT_OK(query_request_helper::validateFindCommandRequest(findCommand));
}
//
@@ -387,7 +387,8 @@ TEST(QueryRequestTest, ParseFromCommandWithOptions) {
"projection: {_id: 0, a: 1},"
"showRecordId: true, '$db': 'test'}");
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
// Make sure the values from the command BSON are reflected in the QR.
ASSERT(findCommand->getShowRecordId());
@@ -399,7 +400,8 @@ TEST(QueryRequestTest, ParseFromCommandHintAsString) {
"filter: {a: 1},"
"hint: 'foo_1', '$db': 'test'}");
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
BSONObj hintObj = findCommand->getHint();
ASSERT_BSONOBJ_EQ(BSON("$hint"
@@ -435,7 +437,8 @@ TEST(QueryRequestTest, ParseFromCommandAllFlagsTrue) {
"readOnce: true,"
"allowSpeculativeMajorityRead: true, '$db': 'test'}");
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
// Test that all the flags got set to true.
ASSERT(findCommand->getTailable());
@@ -465,7 +468,8 @@ TEST(QueryRequestTest, OplogReplayFlagIsAllowedButIgnored) {
TEST(QueryRequestTest, ParseFromCommandReadOnceDefaultsToFalse) {
BSONObj cmdObj = fromjson("{find: 'testns', '$db': 'test'}");
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
ASSERT(!findCommand->getReadOnce());
}
@@ -476,7 +480,8 @@ TEST(QueryRequestTest, ParseFromCommandValidMinMax) {
"min: {a: 1},"
"max: {a: 2}, '$db': 'test'}");
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
BSONObj expectedMin = BSON("a" << 1);
ASSERT_EQUALS(0, expectedMin.woCompare(findCommand->getMin()));
BSONObj expectedMax = BSON("a" << 2);
@@ -501,7 +506,8 @@ TEST(QueryRequestTest, ParseFromCommandAllNonOptionFields) {
"singleBatch: false, '$db': 'test'}")
.addField(rtcObj["runtimeConstants"]);
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
// Check the values inside the QR.
BSONObj expectedQuery = BSON("a" << 1);
ASSERT_EQUALS(0, expectedQuery.woCompare(findCommand->getFilter()));
@@ -534,7 +540,8 @@ TEST(QueryRequestTest, ParseFromCommandLargeLimit) {
"filter: {a: 1},"
"limit: 8000000000, '$db': 'test'}"); // 8 * 1000 * 1000 * 1000
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
ASSERT_EQUALS(8LL * 1000 * 1000 * 1000, *findCommand->getLimit());
}
@@ -545,7 +552,8 @@ TEST(QueryRequestTest, ParseFromCommandLargeBatchSize) {
"filter: {a: 1},"
"batchSize: 8000000000, '$db': 'test'}"); // 8 * 1000 * 1000 * 1000
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
ASSERT_EQUALS(8LL * 1000 * 1000 * 1000, *findCommand->getBatchSize());
}
@@ -556,7 +564,8 @@ TEST(QueryRequestTest, ParseFromCommandLargeSkip) {
"filter: {a: 1},"
"skip: 8000000000, '$db': 'test'}"); // 8 * 1000 * 1000 * 1000
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
ASSERT_EQUALS(8LL * 1000 * 1000 * 1000, *findCommand->getSkip());
}
@@ -863,7 +872,8 @@ TEST(QueryRequestTest, ParseFromCommandSkipIsZero) {
"{find: 'testns',"
"skip: 0,"
"filter: {a: 3}, '$db': 'test'}");
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
ASSERT_BSONOBJ_EQ(BSON("a" << 3), findCommand->getFilter());
ASSERT_FALSE(findCommand->getSkip());
}
@@ -882,7 +892,8 @@ TEST(QueryRequestTest, ParseFromCommandLimitIsZero) {
"{find: 'testns',"
"limit: 0,"
"filter: {a: 3}, '$db': 'test'}");
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
ASSERT_BSONOBJ_EQ(BSON("a" << 3), findCommand->getFilter());
ASSERT_FALSE(findCommand->getLimit());
}
@@ -898,7 +909,8 @@ TEST(QueryRequestTest, ParseFromCommandNegativeBatchSizeError) {
TEST(QueryRequestTest, ParseFromCommandBatchSizeZero) {
BSONObj cmdObj = fromjson("{find: 'testns', batchSize: 0, '$db': 'test'}");
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
ASSERT(findCommand->getBatchSize());
ASSERT_EQ(0, *findCommand->getBatchSize());
@@ -907,7 +919,8 @@ TEST(QueryRequestTest, ParseFromCommandBatchSizeZero) {
TEST(QueryRequestTest, ParseFromCommandDefaultBatchSize) {
BSONObj cmdObj = fromjson("{find: 'testns', '$db': 'test'}");
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
ASSERT(!findCommand->getBatchSize());
ASSERT(!findCommand->getLimit());
@@ -920,7 +933,8 @@ TEST(QueryRequestTest, ParseFromCommandRequestResumeToken) {
<< "$_requestResumeToken" << true << "$db"
<< "test");
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
ASSERT(findCommand->getRequestResumeToken());
}
@@ -932,7 +946,8 @@ TEST(QueryRequestTest, ParseFromCommandResumeToken) {
<< BSON("$recordId" << 1LL) << "$db"
<< "test");
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
ASSERT(!findCommand->getResumeAfter().isEmpty());
ASSERT(findCommand->getRequestResumeToken());
}
@@ -946,16 +961,17 @@ TEST(QueryRequestTest, ParseFromCommandEmptyResumeToken) {
<< "$_requestResumeToken" << true << "$_resumeAfter" << resumeAfter << "$db"
<< "test");
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
ASSERT(findCommand->getRequestResumeToken());
ASSERT(findCommand->getResumeAfter().isEmpty());
}
//
-// Test FindCommand object ns and uuid variants.
+// Test FindCommandRequest object ns and uuid variants.
//
-TEST(QueryRequestTest, AsFindCommandAllNonOptionFields) {
+TEST(QueryRequestTest, AsFindCommandRequestAllNonOptionFields) {
BSONObj storage = BSON("runtimeConstants"
<< (LegacyRuntimeConstants{Date_t::now(), Timestamp(1, 1)}.toBSON()));
BSONObj cmdObj = fromjson(
@@ -972,11 +988,12 @@ TEST(QueryRequestTest, AsFindCommandAllNonOptionFields) {
"readConcern: {e: 1}, '$db': 'test'}")
.addField(storage["runtimeConstants"]);
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
ASSERT_BSONOBJ_EQ(cmdObj.removeField("$db"), findCommand->toBSON(BSONObj()));
}
-TEST(QueryRequestTest, AsFindCommandWithUuidAllNonOptionFields) {
+TEST(QueryRequestTest, AsFindCommandRequestWithUuidAllNonOptionFields) {
BSONObj storage = BSON("runtimeConstants"
<< (LegacyRuntimeConstants{Date_t::now(), Timestamp(1, 1)}.toBSON()));
BSONObj cmdObj =
@@ -995,19 +1012,20 @@ TEST(QueryRequestTest, AsFindCommandWithUuidAllNonOptionFields) {
"readConcern: {e: 1}, '$db': 'test'}")
.addField(storage["runtimeConstants"]);
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
ASSERT_BSONOBJ_EQ(cmdObj.removeField("$db"), findCommand->toBSON(BSONObj()));
}
-TEST(QueryRequestTest, AsFindCommandWithUuidNoAvailableNamespace) {
+TEST(QueryRequestTest, AsFindCommandRequestWithUuidNoAvailableNamespace) {
BSONObj cmdObj =
fromjson("{find: { \"$binary\" : \"ASNFZ4mrze/ty6mHZUMhAQ==\", \"$type\" : \"04\" }}");
- FindCommand findCommand(NamespaceStringOrUUID(
+ FindCommandRequest findCommand(NamespaceStringOrUUID(
"test", UUID::parse("01234567-89ab-cdef-edcb-a98765432101").getValue()));
ASSERT_BSONOBJ_EQ(cmdObj.removeField("$db"), findCommand.toBSON(BSONObj()));
}
-TEST(QueryRequestTest, AsFindCommandWithResumeToken) {
+TEST(QueryRequestTest, AsFindCommandRequestWithResumeToken) {
BSONObj cmdObj = BSON("find"
<< "testns"
<< "sort" << BSON("$natural" << 1) << "hint" << BSON("$natural" << 1)
@@ -1015,11 +1033,12 @@ TEST(QueryRequestTest, AsFindCommandWithResumeToken) {
<< BSON("$recordId" << 1LL) << "$db"
<< "test");
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
ASSERT_BSONOBJ_EQ(cmdObj.removeField("$db"), findCommand->toBSON(BSONObj()));
}
-TEST(QueryRequestTest, AsFindCommandWithEmptyResumeToken) {
+TEST(QueryRequestTest, AsFindCommandRequestWithEmptyResumeToken) {
BSONObj resumeAfter = fromjson("{}");
BSONObj cmdObj =
BSON("find"
@@ -1027,13 +1046,14 @@ TEST(QueryRequestTest, AsFindCommandWithEmptyResumeToken) {
<< "hint" << BSON("$natural" << 1) << "sort" << BSON("$natural" << 1)
<< "$_requestResumeToken" << true << "$_resumeAfter" << resumeAfter << "$db"
<< "test");
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
ASSERT(findCommand->toBSON(BSONObj()).getField("$_resumeAftr").eoo());
}
//
//
-// Errors checked in query_request_helper::validateFindCommand().
+// Errors checked in query_request_helper::validateFindCommandRequest().
//
TEST(QueryRequestTest, ParseFromCommandMinMaxDifferentFieldsError) {
@@ -1087,7 +1107,8 @@ TEST(QueryRequestTest, ParseCommandForbidExhaust) {
TEST(QueryRequestTest, ParseCommandIsFromFindCommand) {
BSONObj cmdObj = fromjson("{find: 'testns', '$db': 'test'}");
- unique_ptr<FindCommand> findCommand(query_request_helper::makeFromFindCommandForTests(cmdObj));
+ unique_ptr<FindCommandRequest> findCommand(
+ query_request_helper::makeFromFindCommandForTests(cmdObj));
ASSERT_FALSE(findCommand->getNtoreturn());
}
@@ -1114,7 +1135,7 @@ TEST(QueryRequestTest, ParseCommandIgnoreShardVersionField) {
TEST(QueryRequestTest, DefaultQueryParametersCorrect) {
BSONObj cmdObj = fromjson("{find: 'testns', '$db': 'test'}");
- std::unique_ptr<FindCommand> findCommand(
+ std::unique_ptr<FindCommandRequest> findCommand(
query_request_helper::makeFromFindCommandForTests(cmdObj));
ASSERT_FALSE(findCommand->getSkip());
@@ -1206,7 +1227,7 @@ TEST(QueryRequestTest, ParseMaxTimeMSPositiveInRangeSucceeds) {
}
TEST(QueryRequestTest, ConvertToAggregationSucceeds) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
auto agg = query_request_helper::asAggregationCommand(findCommand);
ASSERT_OK(agg);
@@ -1223,7 +1244,7 @@ TEST(QueryRequestTest, ConvertToAggregationSucceeds) {
}
TEST(QueryRequestTest, ConvertToAggregationOmitsExplain) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
auto agg = query_request_helper::asAggregationCommand(findCommand);
ASSERT_OK(agg);
@@ -1237,7 +1258,7 @@ TEST(QueryRequestTest, ConvertToAggregationOmitsExplain) {
}
TEST(QueryRequestTest, ConvertToAggregationWithHintSucceeds) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setHint(fromjson("{a_1: -1}"));
const auto agg = query_request_helper::asAggregationCommand(findCommand);
ASSERT_OK(agg);
@@ -1249,94 +1270,94 @@ TEST(QueryRequestTest, ConvertToAggregationWithHintSucceeds) {
}
TEST(QueryRequestTest, ConvertToAggregationWithMinFails) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setMin(fromjson("{a: 1}"));
ASSERT_NOT_OK(query_request_helper::asAggregationCommand(findCommand));
}
TEST(QueryRequestTest, ConvertToAggregationWithMaxFails) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setMax(fromjson("{a: 1}"));
ASSERT_NOT_OK(query_request_helper::asAggregationCommand(findCommand));
}
TEST(QueryRequestTest, ConvertToAggregationWithSingleBatchFieldFails) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setSingleBatch(true);
ASSERT_NOT_OK(query_request_helper::asAggregationCommand(findCommand));
}
TEST(QueryRequestTest, ConvertToAggregationWithSingleBatchFieldAndLimitFails) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setSingleBatch(true);
findCommand.setLimit(7);
ASSERT_NOT_OK(query_request_helper::asAggregationCommand(findCommand));
}
TEST(QueryRequestTest, ConvertToAggregationWithSingleBatchFieldLimitOneSucceeds) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setSingleBatch(true);
findCommand.setLimit(1);
ASSERT_OK(query_request_helper::asAggregationCommand(findCommand));
}
TEST(QueryRequestTest, ConvertToAggregationWithReturnKeyFails) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setReturnKey(true);
ASSERT_NOT_OK(query_request_helper::asAggregationCommand(findCommand));
}
TEST(QueryRequestTest, ConvertToAggregationWithShowRecordIdFails) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setShowRecordId(true);
ASSERT_NOT_OK(query_request_helper::asAggregationCommand(findCommand));
}
TEST(QueryRequestTest, ConvertToAggregationWithTailableFails) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
query_request_helper::setTailableMode(TailableModeEnum::kTailable, &findCommand);
ASSERT_NOT_OK(query_request_helper::asAggregationCommand(findCommand));
}
TEST(QueryRequestTest, ConvertToAggregationWithNoCursorTimeoutFails) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setNoCursorTimeout(true);
ASSERT_NOT_OK(query_request_helper::asAggregationCommand(findCommand));
}
TEST(QueryRequestTest, ConvertToAggregationWithAwaitDataFails) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
query_request_helper::setTailableMode(TailableModeEnum::kTailableAndAwaitData, &findCommand);
ASSERT_NOT_OK(query_request_helper::asAggregationCommand(findCommand));
}
TEST(QueryRequestTest, ConvertToAggregationWithAllowPartialResultsFails) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setAllowPartialResults(true);
ASSERT_NOT_OK(query_request_helper::asAggregationCommand(findCommand));
}
TEST(QueryRequestTest, ConvertToAggregationWithNToReturnFails) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setNtoreturn(7);
ASSERT_NOT_OK(query_request_helper::asAggregationCommand(findCommand));
}
TEST(QueryRequestTest, ConvertToAggregationWithRequestResumeTokenFails) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setRequestResumeToken(true);
ASSERT_NOT_OK(query_request_helper::asAggregationCommand(findCommand));
}
TEST(QueryRequestTest, ConvertToAggregationWithResumeAfterFails) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
BSONObj resumeAfter = BSON("$recordId" << 1LL);
findCommand.setResumeAfter(resumeAfter);
ASSERT_NOT_OK(query_request_helper::asAggregationCommand(findCommand));
}
TEST(QueryRequestTest, ConvertToAggregationWithPipeline) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setFilter(BSON("x" << 1));
findCommand.setSort(BSON("y" << -1));
findCommand.setLimit(3);
@@ -1368,7 +1389,7 @@ TEST(QueryRequestTest, ConvertToAggregationWithPipeline) {
}
TEST(QueryRequestTest, ConvertToAggregationWithBatchSize) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setBatchSize(4);
auto agg = query_request_helper::asAggregationCommand(findCommand);
@@ -1386,7 +1407,7 @@ TEST(QueryRequestTest, ConvertToAggregationWithBatchSize) {
}
TEST(QueryRequestTest, ConvertToAggregationWithMaxTimeMS) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setMaxTimeMS(9);
auto agg = query_request_helper::asAggregationCommand(findCommand);
@@ -1407,7 +1428,7 @@ TEST(QueryRequestTest, ConvertToAggregationWithMaxTimeMS) {
}
TEST(QueryRequestTest, ConvertToAggregationWithCollationSucceeds) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setCollation(BSON("f" << 1));
auto agg = query_request_helper::asAggregationCommand(findCommand);
ASSERT_OK(agg);
@@ -1425,14 +1446,14 @@ TEST(QueryRequestTest, ConvertToAggregationWithCollationSucceeds) {
}
TEST(QueryRequestTest, ConvertToAggregationWithReadOnceFails) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setReadOnce(true);
const auto aggCmd = query_request_helper::asAggregationCommand(findCommand);
ASSERT_EQ(ErrorCodes::InvalidPipelineOperator, aggCmd.getStatus().code());
}
TEST(QueryRequestTest, ConvertToAggregationWithAllowSpeculativeMajorityReadFails) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setAllowSpeculativeMajorityRead(true);
const auto aggCmd = query_request_helper::asAggregationCommand(findCommand);
ASSERT_EQ(ErrorCodes::InvalidPipelineOperator, aggCmd.getStatus().code());
@@ -1440,7 +1461,7 @@ TEST(QueryRequestTest, ConvertToAggregationWithAllowSpeculativeMajorityReadFails
TEST(QueryRequestTest, ConvertToAggregationWithLegacyRuntimeConstantsSucceeds) {
LegacyRuntimeConstants rtc{Date_t::now(), Timestamp(1, 1)};
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setLegacyRuntimeConstants(rtc);
auto agg = query_request_helper::asAggregationCommand(findCommand);
ASSERT_OK(agg);
@@ -1454,7 +1475,7 @@ TEST(QueryRequestTest, ConvertToAggregationWithLegacyRuntimeConstantsSucceeds) {
}
TEST(QueryRequestTest, ConvertToAggregationWithAllowDiskUseTrueSucceeds) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setAllowDiskUse(true);
const auto agg = query_request_helper::asAggregationCommand(findCommand);
ASSERT_OK(agg.getStatus());
@@ -1466,7 +1487,7 @@ TEST(QueryRequestTest, ConvertToAggregationWithAllowDiskUseTrueSucceeds) {
}
TEST(QueryRequestTest, ConvertToAggregationWithAllowDiskUseFalseSucceeds) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setAllowDiskUse(false);
const auto agg = query_request_helper::asAggregationCommand(findCommand);
ASSERT_OK(agg.getStatus());
@@ -1478,21 +1499,21 @@ TEST(QueryRequestTest, ConvertToAggregationWithAllowDiskUseFalseSucceeds) {
}
TEST(QueryRequestTest, ConvertToFindWithAllowDiskUseTrueSucceeds) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setAllowDiskUse(true);
const auto findCmd = findCommand.toBSON(BSONObj());
- BSONElement elem = findCmd[FindCommand::kAllowDiskUseFieldName];
+ BSONElement elem = findCmd[FindCommandRequest::kAllowDiskUseFieldName];
ASSERT_EQ(true, elem.isBoolean());
ASSERT_EQ(true, elem.Bool());
}
TEST(QueryRequestTest, ConvertToFindWithAllowDiskUseFalseSucceeds) {
- FindCommand findCommand(testns);
+ FindCommandRequest findCommand(testns);
findCommand.setAllowDiskUse(false);
const auto findCmd = findCommand.toBSON(BSONObj());
- ASSERT_FALSE(findCmd[FindCommand::kAllowDiskUseFieldName].booleanSafe());
+ ASSERT_FALSE(findCmd[FindCommandRequest::kAllowDiskUseFieldName].booleanSafe());
}
TEST(QueryRequestTest, ParseFromLegacyQuery) {
@@ -1509,7 +1530,7 @@ TEST(QueryRequestTest, ParseFromLegacyQuery) {
})");
bool explain = false;
- unique_ptr<FindCommand> findCommand(assertGet(query_request_helper::fromLegacyQuery(
+ unique_ptr<FindCommandRequest> findCommand(assertGet(query_request_helper::fromLegacyQuery(
nss, queryObj, BSON("proj" << 1), kSkip, kNToReturn, QueryOption_Exhaust, &explain)));
ASSERT_EQ(*findCommand->getNamespaceOrUUID().nss(), nss);
@@ -1539,7 +1560,7 @@ TEST(QueryRequestTest, ParseFromLegacyQueryOplogReplayFlagAllowed) {
// flag may be set by old clients.
auto options = QueryOption_OplogReplay_DEPRECATED;
bool explain = false;
- unique_ptr<FindCommand> findCommand(assertGet(query_request_helper::fromLegacyQuery(
+ unique_ptr<FindCommandRequest> findCommand(assertGet(query_request_helper::fromLegacyQuery(
nss, queryObj, projectionObj, nToSkip, nToReturn, options, &explain)));
// Verify that if we reserialize the find command, the 'oplogReplay' field
@@ -1561,7 +1582,7 @@ TEST(QueryRequestTest, ParseFromLegacyQueryUnwrapped) {
})");
const NamespaceString nss("test.testns");
bool explain = false;
- unique_ptr<FindCommand> findCommand(assertGet(query_request_helper::fromLegacyQuery(
+ unique_ptr<FindCommandRequest> findCommand(assertGet(query_request_helper::fromLegacyQuery(
nss, queryObj, BSONObj(), 0, 0, QueryOption_Exhaust, &explain)));
ASSERT_EQ(*findCommand->getNamespaceOrUUID().nss(), nss);
@@ -1606,7 +1627,7 @@ TEST_F(QueryRequestTest, ParseFromUUID) {
NamespaceStringOrUUID nssOrUUID("test", uuid);
- FindCommand findCommand(nssOrUUID);
+ FindCommandRequest findCommand(nssOrUUID);
const NamespaceString nss("test.testns");
// Ensure a call to refreshNSS succeeds.
query_request_helper::refreshNSS(nss, &findCommand);
diff --git a/src/mongo/db/query/query_settings.cpp b/src/mongo/db/query/query_settings.cpp
index d3552edd3c0..d0d9e1a9f1a 100644
--- a/src/mongo/db/query/query_settings.cpp
+++ b/src/mongo/db/query/query_settings.cpp
@@ -101,7 +101,7 @@ std::vector<AllowedIndexEntry> QuerySettings::getAllAllowedIndices() const {
void QuerySettings::setAllowedIndices(const CanonicalQuery& canonicalQuery,
const BSONObjSet& indexKeyPatterns,
const stdx::unordered_set<std::string>& indexNames) {
- const FindCommand& findCommand = canonicalQuery.getFindCommand();
+ const FindCommandRequest& findCommand = canonicalQuery.getFindCommandRequest();
const BSONObj& query = findCommand.getFilter();
const BSONObj& sort = findCommand.getSort();
const BSONObj& projection = findCommand.getProjection();
diff --git a/src/mongo/db/query/sbe_stage_builder.cpp b/src/mongo/db/query/sbe_stage_builder.cpp
index 032510007da..d65a2120f11 100644
--- a/src/mongo/db/query/sbe_stage_builder.cpp
+++ b/src/mongo/db/query/sbe_stage_builder.cpp
@@ -1854,7 +1854,7 @@ std::pair<std::unique_ptr<sbe::PlanStage>, PlanStageSlots> SlotBasedStageBuilder
case STAGE_COLLSCAN:
case STAGE_LIMIT:
case STAGE_SKIP:
- if (_cq.getFindCommand().getTailable() &&
+ if (_cq.getFindCommandRequest().getTailable() &&
!reqs.getIsBuildingUnionForTailableCollScan()) {
auto childReqs = reqs;
childReqs.setIsBuildingUnionForTailableCollScan(true);
diff --git a/src/mongo/db/query/sbe_stage_builder_test_fixture.cpp b/src/mongo/db/query/sbe_stage_builder_test_fixture.cpp
index fad3a4cd63a..36fb19ed215 100644
--- a/src/mongo/db/query/sbe_stage_builder_test_fixture.cpp
+++ b/src/mongo/db/query/sbe_stage_builder_test_fixture.cpp
@@ -49,7 +49,7 @@ SbeStageBuilderTestFixture::buildPlanStage(
std::unique_ptr<QuerySolution> querySolution,
bool hasRecordId,
std::unique_ptr<ShardFiltererFactoryInterface> shardFiltererInterface) {
- auto findCommand = std::make_unique<FindCommand>(_nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(_nss);
const boost::intrusive_ptr<ExpressionContext> expCtx(new ExpressionContextForTest(_nss));
auto statusWithCQ =
CanonicalQuery::canonicalize(opCtx(), std::move(findCommand), false, expCtx);
diff --git a/src/mongo/db/repl/oplog_buffer_collection.cpp b/src/mongo/db/repl/oplog_buffer_collection.cpp
index caa7cbd3803..799bf539ca7 100644
--- a/src/mongo/db/repl/oplog_buffer_collection.cpp
+++ b/src/mongo/db/repl/oplog_buffer_collection.cpp
@@ -208,10 +208,10 @@ void OplogBufferCollection::_push(WithLock,
DocumentValidationSettings::kDisableSchemaValidation |
DocumentValidationSettings::kDisableInternalValidation);
- write_ops::Insert insertOp(_nss);
+ write_ops::InsertCommandRequest insertOp(_nss);
insertOp.setDocuments(std::move(docsToInsert));
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase wcb;
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(true);
return wcb;
}());
diff --git a/src/mongo/db/repl/tenant_collection_cloner.cpp b/src/mongo/db/repl/tenant_collection_cloner.cpp
index d63cc3fe63b..087e0da1261 100644
--- a/src/mongo/db/repl/tenant_collection_cloner.cpp
+++ b/src/mongo/db/repl/tenant_collection_cloner.cpp
@@ -539,10 +539,10 @@ void TenantCollectionCloner::insertDocumentsCallback(
DocumentValidationSettings::kDisableSchemaValidation |
DocumentValidationSettings::kDisableInternalValidation);
- write_ops::Insert insertOp(_existingNss.value_or(_sourceNss));
+ write_ops::InsertCommandRequest insertOp(_existingNss.value_or(_sourceNss));
insertOp.setDocuments(std::move(docs));
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase wcb;
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(true);
return wcb;
}());
diff --git a/src/mongo/db/repl/tenant_migration_donor_service.cpp b/src/mongo/db/repl/tenant_migration_donor_service.cpp
index 24d1114e98b..c75d034f49c 100644
--- a/src/mongo/db/repl/tenant_migration_donor_service.cpp
+++ b/src/mongo/db/repl/tenant_migration_donor_service.cpp
@@ -884,7 +884,7 @@ TenantMigrationDonorService::Instance::_fetchAndStoreRecipientClusterTimeKeyDocs
const auto nss = NamespaceString::kKeysCollectionNamespace;
const auto cmdObj = [&] {
- FindCommand request(NamespaceStringOrUUID{nss});
+ FindCommandRequest request(NamespaceStringOrUUID{nss});
request.setReadConcern(
repl::ReadConcernArgs(repl::ReadConcernLevel::kMajorityReadConcern)
.toBSONInner());
diff --git a/src/mongo/db/repl/tenant_migration_recipient_service.cpp b/src/mongo/db/repl/tenant_migration_recipient_service.cpp
index 0118613271f..d5d3df7f823 100644
--- a/src/mongo/db/repl/tenant_migration_recipient_service.cpp
+++ b/src/mongo/db/repl/tenant_migration_recipient_service.cpp
@@ -870,8 +870,8 @@ void TenantMigrationRecipientService::Instance::_getStartOpTimesFromDonor(WithLo
_stateDoc.setStartFetchingDonorOpTime(startFetchingDonorOpTime);
}
-AggregateCommand TenantMigrationRecipientService::Instance::_makeCommittedTransactionsAggregation()
- const {
+AggregateCommandRequest
+TenantMigrationRecipientService::Instance::_makeCommittedTransactionsAggregation() const {
auto opCtx = cc().makeOperationContext();
auto expCtx = makeExpressionContext(opCtx.get());
@@ -888,8 +888,8 @@ AggregateCommand TenantMigrationRecipientService::Instance::_makeCommittedTransa
expCtx, startFetchingTimestamp, getTenantId())
->serializeToBson();
- AggregateCommand aggRequest(NamespaceString::kSessionTransactionsTableNamespace,
- std::move(serializedPipeline));
+ AggregateCommandRequest aggRequest(NamespaceString::kSessionTransactionsTableNamespace,
+ std::move(serializedPipeline));
auto readConcern = repl::ReadConcernArgs(
boost::optional<LogicalTime>(startFetchingTimestamp),
@@ -1126,8 +1126,8 @@ TenantMigrationRecipientService::Instance::_fetchRetryableWritesOplogBeforeStart
expCtx, startFetchingTimestamp, getTenantId())
->serializeToBson();
- AggregateCommand aggRequest(NamespaceString::kSessionTransactionsTableNamespace,
- std::move(serializedPipeline));
+ AggregateCommandRequest aggRequest(NamespaceString::kSessionTransactionsTableNamespace,
+ std::move(serializedPipeline));
auto readConcernArgs = repl::ReadConcernArgs(
boost::optional<repl::ReadConcernLevel>(repl::ReadConcernLevel::kMajorityReadConcern));
diff --git a/src/mongo/db/repl/tenant_migration_recipient_service.h b/src/mongo/db/repl/tenant_migration_recipient_service.h
index 58e65811412..09bda6cbe39 100644
--- a/src/mongo/db/repl/tenant_migration_recipient_service.h
+++ b/src/mongo/db/repl/tenant_migration_recipient_service.h
@@ -378,7 +378,7 @@ public:
* Creates an aggregation pipeline to fetch transaction entries with 'lastWriteOpTime' <
* 'startFetchingDonorOpTime' and 'state: committed'.
*/
- AggregateCommand _makeCommittedTransactionsAggregation() const;
+ AggregateCommandRequest _makeCommittedTransactionsAggregation() const;
/**
* Processes a committed transaction entry from the donor. Updates the recipient's
diff --git a/src/mongo/db/rs_local_client.cpp b/src/mongo/db/rs_local_client.cpp
index 975be198be0..738edc3becd 100644
--- a/src/mongo/db/rs_local_client.cpp
+++ b/src/mongo/db/rs_local_client.cpp
@@ -158,7 +158,7 @@ StatusWith<Shard::QueryResponse> RSLocalClient::queryOnce(
Status RSLocalClient::runAggregation(
OperationContext* opCtx,
- const AggregateCommand& aggRequest,
+ const AggregateCommandRequest& aggRequest,
std::function<bool(const std::vector<BSONObj>& batch)> callback) {
DBDirectClient client(opCtx);
auto cursor = uassertStatusOKWithContext(
diff --git a/src/mongo/db/rs_local_client.h b/src/mongo/db/rs_local_client.h
index 640e0c7710d..8fb1dd544ca 100644
--- a/src/mongo/db/rs_local_client.h
+++ b/src/mongo/db/rs_local_client.h
@@ -71,7 +71,7 @@ public:
const boost::optional<BSONObj>& hint = boost::none);
Status runAggregation(OperationContext* opCtx,
- const AggregateCommand& aggRequest,
+ const AggregateCommandRequest& aggRequest,
std::function<bool(const std::vector<BSONObj>& batch)> callback);
private:
diff --git a/src/mongo/db/s/add_shard_util.cpp b/src/mongo/db/s/add_shard_util.cpp
index d1b9b6da219..0036ba7f29e 100644
--- a/src/mongo/db/s/add_shard_util.cpp
+++ b/src/mongo/db/s/add_shard_util.cpp
@@ -61,7 +61,7 @@ AddShard createAddShardCmd(OperationContext* opCtx, const ShardId& shardName) {
BSONObj createShardIdentityUpsertForAddShard(const AddShard& addShardCmd) {
BatchedCommandRequest request([&] {
- write_ops::Update updateOp(NamespaceString::kServerConfigurationNamespace);
+ write_ops::UpdateCommandRequest updateOp(NamespaceString::kServerConfigurationNamespace);
updateOp.setUpdates({[&] {
write_ops::UpdateOpEntry entry;
entry.setQ(BSON("_id" << kShardIdentityDocumentId));
diff --git a/src/mongo/db/s/config/config_server_test_fixture.cpp b/src/mongo/db/s/config/config_server_test_fixture.cpp
index 4ea409b1d0f..2497a538152 100644
--- a/src/mongo/db/s/config/config_server_test_fixture.cpp
+++ b/src/mongo/db/s/config/config_server_test_fixture.cpp
@@ -193,16 +193,17 @@ std::shared_ptr<Shard> ConfigServerTestFixture::getConfigShard() const {
Status ConfigServerTestFixture::insertToConfigCollection(OperationContext* opCtx,
const NamespaceString& ns,
const BSONObj& doc) {
- auto insertResponse = getConfigShard()->runCommand(opCtx,
- kReadPref,
- ns.db().toString(),
- [&]() {
- write_ops::Insert insertOp(ns);
- insertOp.setDocuments({doc});
- return insertOp.toBSON({});
- }(),
- Shard::kDefaultConfigCommandTimeout,
- Shard::RetryPolicy::kNoRetry);
+ auto insertResponse =
+ getConfigShard()->runCommand(opCtx,
+ kReadPref,
+ ns.db().toString(),
+ [&]() {
+ write_ops::InsertCommandRequest insertOp(ns);
+ insertOp.setDocuments({doc});
+ return insertOp.toBSON({});
+ }(),
+ Shard::kDefaultConfigCommandTimeout,
+ Shard::RetryPolicy::kNoRetry);
BatchedCommandResponse batchResponse;
auto status = Shard::CommandResponse::processBatchWriteResponse(insertResponse, &batchResponse);
@@ -219,7 +220,7 @@ Status ConfigServerTestFixture::updateToConfigCollection(OperationContext* opCtx
kReadPref,
ns.db().toString(),
[&]() {
- write_ops::Update updateOp(ns);
+ write_ops::UpdateCommandRequest updateOp(ns);
updateOp.setUpdates({[&] {
write_ops::UpdateOpEntry entry;
entry.setQ(query);
@@ -242,21 +243,22 @@ Status ConfigServerTestFixture::deleteToConfigCollection(OperationContext* opCtx
const NamespaceString& ns,
const BSONObj& doc,
const bool multi) {
- auto deleteResponse = getConfigShard()->runCommand(opCtx,
- kReadPref,
- ns.db().toString(),
- [&]() {
- write_ops::Delete deleteOp(ns);
- deleteOp.setDeletes({[&] {
- write_ops::DeleteOpEntry entry;
- entry.setQ(doc);
- entry.setMulti(multi);
- return entry;
- }()});
- return deleteOp.toBSON({});
- }(),
- Shard::kDefaultConfigCommandTimeout,
- Shard::RetryPolicy::kNoRetry);
+ auto deleteResponse =
+ getConfigShard()->runCommand(opCtx,
+ kReadPref,
+ ns.db().toString(),
+ [&]() {
+ write_ops::DeleteCommandRequest deleteOp(ns);
+ deleteOp.setDeletes({[&] {
+ write_ops::DeleteOpEntry entry;
+ entry.setQ(doc);
+ entry.setMulti(multi);
+ return entry;
+ }()});
+ return deleteOp.toBSON({});
+ }(),
+ Shard::kDefaultConfigCommandTimeout,
+ Shard::RetryPolicy::kNoRetry);
BatchedCommandResponse batchResponse;
diff --git a/src/mongo/db/s/config/sharding_catalog_manager.cpp b/src/mongo/db/s/config/sharding_catalog_manager.cpp
index db9d72c9af8..ded5ef739b8 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager.cpp
+++ b/src/mongo/db/s/config/sharding_catalog_manager.cpp
@@ -102,7 +102,7 @@ OpMsg runCommandInLocalTxn(OperationContext* opCtx,
void startTransactionWithNoopFind(OperationContext* opCtx,
const NamespaceString& nss,
TxnNumber txnNumber) {
- FindCommand findCommand(nss);
+ FindCommandRequest findCommand(nss);
findCommand.setBatchSize(0);
findCommand.setSingleBatch(true);
@@ -188,7 +188,7 @@ void updateConfigDocumentDBDirect(OperationContext* opCtx,
DBDirectClient client(opCtx);
- write_ops::Update updateOp(nss, [&] {
+ write_ops::UpdateCommandRequest updateOp(nss, [&] {
write_ops::UpdateOpEntry u;
u.setQ(query);
u.setU(write_ops::UpdateModification::parseFromClassicUpdate(update));
@@ -196,8 +196,8 @@ void updateConfigDocumentDBDirect(OperationContext* opCtx,
u.setUpsert(upsert);
return std::vector{u};
}());
- updateOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase base;
+ updateOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase base;
base.setOrdered(false);
return base;
}());
@@ -1014,7 +1014,7 @@ void ShardingCatalogManager::insertConfigDocumentsInTxn(OperationContext* opCtx,
auto doBatchInsert = [&]() {
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
+ write_ops::InsertCommandRequest insertOp(nss);
insertOp.setDocuments(workingBatch);
return insertOp;
}());
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp b/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
index 772d0621d76..1b4a8a26994 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
+++ b/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
@@ -190,7 +190,7 @@ protected:
*/
void expectUpdatesReturnSuccess(const HostAndPort& expectedHost,
const NamespaceString& expectedNss,
- const write_ops::Update& expectedUpdateOp) {
+ const write_ops::UpdateCommandRequest& expectedUpdateOp) {
onCommandForAddShard([&](const RemoteCommandRequest& request) {
ASSERT_EQUALS(expectedHost, request.target);
@@ -243,7 +243,7 @@ protected:
*/
void expectUpdatesReturnFailure(const HostAndPort& expectedHost,
const NamespaceString& expectedNss,
- const write_ops::Update& expectedUpdateOp,
+ const write_ops::UpdateCommandRequest& expectedUpdateOp,
const Status& statusToReturn) {
onCommandForAddShard([&](const RemoteCommandRequest& request) {
ASSERT_EQUALS(expectedHost, request.target);
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp
index c0397a95c24..bdd3582bce1 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp
+++ b/src/mongo/db/s/config/sharding_catalog_manager_chunk_operations.cpp
@@ -494,7 +494,7 @@ std::vector<ShardId> getShardsOwningChunksForCollection(OperationContext* opCtx,
const CollectionType coll(findCollResponse.docs[0]);
const auto nsOrUUID = getNsOrUUIDForChunkTargeting(coll);
- DistinctCommand distinctCmd(ChunkType::ConfigNS, ChunkType::shard.name());
+ DistinctCommandRequest distinctCmd(ChunkType::ConfigNS, ChunkType::shard.name());
if (nsOrUUID.uuid()) {
distinctCmd.setQuery(BSON(ChunkType::collectionUUID << *(nsOrUUID.uuid())));
} else {
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp
index 67c8c0103f5..1ca8f52d4a1 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp
+++ b/src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp
@@ -118,7 +118,7 @@ DatabaseType ShardingCatalogManager::createDatabase(OperationContext* opCtx,
// expensive createDatabase flow.
while (true) {
auto response = client.findAndModify([&] {
- write_ops::FindAndModifyCommand findAndModify(DatabaseType::ConfigNS);
+ write_ops::FindAndModifyCommandRequest findAndModify(DatabaseType::ConfigNS);
findAndModify.setQuery([&] {
BSONObjBuilder queryFilterBuilder;
queryFilterBuilder.append(DatabaseType::name.name(), dbName);
diff --git a/src/mongo/db/s/create_collection_coordinator.cpp b/src/mongo/db/s/create_collection_coordinator.cpp
index 30c984c68c7..92f78b56f19 100644
--- a/src/mongo/db/s/create_collection_coordinator.cpp
+++ b/src/mongo/db/s/create_collection_coordinator.cpp
@@ -267,9 +267,9 @@ void retryWriteOnStepdown(OperationContext* opCtx, const BatchedCommandRequest&
void removeChunks(OperationContext* opCtx, const UUID& uuid) {
BatchedCommandRequest deleteRequest([&]() {
- write_ops::Delete deleteOp(ChunkType::ConfigNS);
- deleteOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::DeleteCommandRequest deleteOp(ChunkType::ConfigNS);
+ deleteOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -285,7 +285,7 @@ void removeChunks(OperationContext* opCtx, const UUID& uuid) {
void upsertChunks(OperationContext* opCtx, std::vector<ChunkType>& chunks) {
BatchedCommandRequest updateRequest([&]() {
- write_ops::Update updateOp(ChunkType::ConfigNS);
+ write_ops::UpdateCommandRequest updateOp(ChunkType::ConfigNS);
std::vector<write_ops::UpdateOpEntry> entries;
entries.reserve(chunks.size());
for (const auto& chunk : chunks) {
@@ -311,7 +311,7 @@ void updateCatalogEntry(OperationContext* opCtx, const NamespaceString& nss, Col
BatchWriteExecStats stats;
BatchedCommandResponse response;
BatchedCommandRequest updateRequest([&]() {
- write_ops::Update updateOp(CollectionType::ConfigNS);
+ write_ops::UpdateCommandRequest updateOp(CollectionType::ConfigNS);
updateOp.setUpdates({[&] {
write_ops::UpdateOpEntry entry;
entry.setQ(BSON(CollectionType::kNssFieldName << nss.ns()));
diff --git a/src/mongo/db/s/dist_lock_catalog_replset.cpp b/src/mongo/db/s/dist_lock_catalog_replset.cpp
index 6336f997b44..746b28dd248 100644
--- a/src/mongo/db/s/dist_lock_catalog_replset.cpp
+++ b/src/mongo/db/s/dist_lock_catalog_replset.cpp
@@ -138,9 +138,9 @@ StatusWith<OID> extractElectionId(const BSONObj& responseObj) {
return electionId;
}
-write_ops::FindAndModifyCommand makeFindAndModifyRequest(
+write_ops::FindAndModifyCommandRequest makeFindAndModifyRequest(
NamespaceString fullNs, BSONObj query, boost::optional<write_ops::UpdateModification> update) {
- auto request = write_ops::FindAndModifyCommand(fullNs);
+ auto request = write_ops::FindAndModifyCommandRequest(fullNs);
request.setQuery(query);
if (update) {
request.setUpdate(std::move(update));
@@ -201,7 +201,7 @@ StatusWith<LockpingsType> DistLockCatalogImpl::getPing(OperationContext* opCtx,
}
Status DistLockCatalogImpl::ping(OperationContext* opCtx, StringData processID, Date_t ping) {
- auto request = write_ops::FindAndModifyCommand(_lockPingNS);
+ auto request = write_ops::FindAndModifyCommandRequest(_lockPingNS);
request.setQuery(BSON(LockpingsType::process() << processID));
request.setUpdate(write_ops::UpdateModification::parseFromClassicUpdate(
BSON("$set" << BSON(LockpingsType::ping(ping)))));
@@ -355,7 +355,7 @@ Status DistLockCatalogImpl::unlock(OperationContext* opCtx,
Status DistLockCatalogImpl::unlockAll(OperationContext* opCtx, const std::string& processID) {
BatchedCommandRequest request([&] {
- write_ops::Update updateOp(_locksNS);
+ write_ops::UpdateCommandRequest updateOp(_locksNS);
updateOp.setUpdates({[&] {
write_ops::UpdateOpEntry entry;
entry.setQ(BSON(LocksType::process(processID)));
diff --git a/src/mongo/db/s/migration_destination_manager.cpp b/src/mongo/db/s/migration_destination_manager.cpp
index 63bc8d36d6a..7e5a9fbe72f 100644
--- a/src/mongo/db/s/migration_destination_manager.cpp
+++ b/src/mongo/db/s/migration_destination_manager.cpp
@@ -1056,8 +1056,8 @@ void MigrationDestinationManager::_migrateDriver(OperationContext* outerOpCtx) {
assertNotAborted(opCtx);
- write_ops::Insert insertOp(_nss);
- insertOp.getWriteCommandBase().setOrdered(true);
+ write_ops::InsertCommandRequest insertOp(_nss);
+ insertOp.getWriteCommandRequestBase().setOrdered(true);
insertOp.setDocuments([&] {
std::vector<BSONObj> toInsert;
while (it != arr.end() &&
diff --git a/src/mongo/db/s/migration_util.cpp b/src/mongo/db/s/migration_util.cpp
index 26d1abcbb48..f08ac1ef8be 100644
--- a/src/mongo/db/s/migration_util.cpp
+++ b/src/mongo/db/s/migration_util.cpp
@@ -625,7 +625,7 @@ void persistAbortDecision(OperationContext* opCtx,
void deleteRangeDeletionTaskOnRecipient(OperationContext* opCtx,
const ShardId& recipientId,
const UUID& migrationId) {
- write_ops::Delete deleteOp(NamespaceString::kRangeDeletionNamespace);
+ write_ops::DeleteCommandRequest deleteOp(NamespaceString::kRangeDeletionNamespace);
write_ops::DeleteOpEntry query(BSON(RangeDeletionTask::kIdFieldName << migrationId),
false /*multi*/);
deleteOp.setDeletes({query});
@@ -661,7 +661,7 @@ void deleteRangeDeletionTaskLocally(OperationContext* opCtx,
void markAsReadyRangeDeletionTaskOnRecipient(OperationContext* opCtx,
const ShardId& recipientId,
const UUID& migrationId) {
- write_ops::Update updateOp(NamespaceString::kRangeDeletionNamespace);
+ write_ops::UpdateCommandRequest updateOp(NamespaceString::kRangeDeletionNamespace);
auto queryFilter = BSON(RangeDeletionTask::kIdFieldName << migrationId);
auto updateModification =
write_ops::UpdateModification(write_ops::UpdateModification::parseFromClassicUpdate(
@@ -703,7 +703,7 @@ void advanceTransactionOnRecipient(OperationContext* opCtx,
const ShardId& recipientId,
const LogicalSessionId& lsid,
TxnNumber currentTxnNumber) {
- write_ops::Update updateOp(NamespaceString::kServerConfigurationNamespace);
+ write_ops::UpdateCommandRequest updateOp(NamespaceString::kServerConfigurationNamespace);
auto queryFilter = BSON("_id"
<< "migrationCoordinatorStats");
auto updateModification = write_ops::UpdateModification(
diff --git a/src/mongo/db/s/resharding/resharding_collection_cloner.cpp b/src/mongo/db/s/resharding/resharding_collection_cloner.cpp
index de3bc10a59c..1d4aaa1ea23 100644
--- a/src/mongo/db/s/resharding/resharding_collection_cloner.cpp
+++ b/src/mongo/db/s/resharding/resharding_collection_cloner.cpp
@@ -216,7 +216,7 @@ std::unique_ptr<Pipeline, PipelineDeleter> ReshardingCollectionCloner::makePipel
std::unique_ptr<Pipeline, PipelineDeleter> ReshardingCollectionCloner::_targetAggregationRequest(
OperationContext* opCtx, const Pipeline& pipeline) {
- AggregateCommand request(_sourceNss, pipeline.serializeToBson());
+ AggregateCommandRequest request(_sourceNss, pipeline.serializeToBson());
request.setCollectionUUID(_sourceUUID);
auto hint = collectionHasSimpleCollation(opCtx, _sourceNss)
diff --git a/src/mongo/db/s/resharding/resharding_data_copy_util.cpp b/src/mongo/db/s/resharding/resharding_data_copy_util.cpp
index 7cb9b4561d9..547be377b48 100644
--- a/src/mongo/db/s/resharding/resharding_data_copy_util.cpp
+++ b/src/mongo/db/s/resharding/resharding_data_copy_util.cpp
@@ -88,7 +88,7 @@ void ensureCollectionDropped(OperationContext* opCtx,
}
Value findHighestInsertedId(OperationContext* opCtx, const CollectionPtr& collection) {
- auto findCommand = std::make_unique<FindCommand>(collection->ns());
+ auto findCommand = std::make_unique<FindCommandRequest>(collection->ns());
findCommand->setLimit(1);
findCommand->setSort(BSON("_id" << -1));
diff --git a/src/mongo/db/s/resharding/resharding_oplog_fetcher.cpp b/src/mongo/db/s/resharding/resharding_oplog_fetcher.cpp
index c10452b4524..bd3e9b4bf5e 100644
--- a/src/mongo/db/s/resharding/resharding_oplog_fetcher.cpp
+++ b/src/mongo/db/s/resharding/resharding_oplog_fetcher.cpp
@@ -228,7 +228,7 @@ void ReshardingOplogFetcher::_ensureCollection(Client* client, const NamespaceSt
});
}
-AggregateCommand ReshardingOplogFetcher::_makeAggregateCommand(Client* client) {
+AggregateCommandRequest ReshardingOplogFetcher::_makeAggregateCommandRequest(Client* client) {
auto opCtxRaii = client->makeOperationContext();
auto opCtx = opCtxRaii.get();
auto expCtx = _makeExpressionContext(opCtx);
@@ -237,7 +237,8 @@ AggregateCommand ReshardingOplogFetcher::_makeAggregateCommand(Client* client) {
createOplogFetchingPipelineForResharding(expCtx, _startAt, _collUUID, _recipientShard)
->serializeToBson();
- AggregateCommand aggRequest(NamespaceString::kRsOplogNamespace, std::move(serializedPipeline));
+ AggregateCommandRequest aggRequest(NamespaceString::kRsOplogNamespace,
+ std::move(serializedPipeline));
if (_useReadConcern) {
auto readConcernArgs = repl::ReadConcernArgs(
boost::optional<LogicalTime>(_startAt.getTs()),
@@ -265,7 +266,7 @@ AggregateCommand ReshardingOplogFetcher::_makeAggregateCommand(Client* client) {
bool ReshardingOplogFetcher::consume(Client* client, Shard* shard) {
_ensureCollection(client, _toWriteInto);
- auto aggRequest = _makeAggregateCommand(client);
+ auto aggRequest = _makeAggregateCommandRequest(client);
auto opCtxRaii = client->makeOperationContext();
int batchesProcessed = 0;
diff --git a/src/mongo/db/s/resharding/resharding_oplog_fetcher.h b/src/mongo/db/s/resharding/resharding_oplog_fetcher.h
index d9ea9d56434..69f1676c16e 100644
--- a/src/mongo/db/s/resharding/resharding_oplog_fetcher.h
+++ b/src/mongo/db/s/resharding/resharding_oplog_fetcher.h
@@ -136,7 +136,7 @@ private:
* Returns true if there's more work to do and the task should be rescheduled.
*/
void _ensureCollection(Client* client, const NamespaceString nss);
- AggregateCommand _makeAggregateCommand(Client* client);
+ AggregateCommandRequest _makeAggregateCommandRequest(Client* client);
ExecutorFuture<void> _reschedule(std::shared_ptr<executor::TaskExecutor> executor,
const CancellationToken& cancelToken);
diff --git a/src/mongo/db/s/resharding/resharding_txn_cloner.cpp b/src/mongo/db/s/resharding/resharding_txn_cloner.cpp
index 3453d2a4b40..7de6f50a3a9 100644
--- a/src/mongo/db/s/resharding/resharding_txn_cloner.cpp
+++ b/src/mongo/db/s/resharding/resharding_txn_cloner.cpp
@@ -122,8 +122,8 @@ boost::optional<LogicalSessionId> ReshardingTxnCloner::_fetchProgressLsid(Operat
std::unique_ptr<Pipeline, PipelineDeleter> ReshardingTxnCloner::_targetAggregationRequest(
OperationContext* opCtx, const Pipeline& pipeline) {
- AggregateCommand request(NamespaceString::kSessionTransactionsTableNamespace,
- pipeline.serializeToBson());
+ AggregateCommandRequest request(NamespaceString::kSessionTransactionsTableNamespace,
+ pipeline.serializeToBson());
request.setReadConcern(BSON(repl::ReadConcernArgs::kLevelFieldName
<< repl::readConcernLevels::kSnapshotName
diff --git a/src/mongo/db/s/resharding_collection_test.cpp b/src/mongo/db/s/resharding_collection_test.cpp
index 964e8ca8bb9..ba3c5d59df0 100644
--- a/src/mongo/db/s/resharding_collection_test.cpp
+++ b/src/mongo/db/s/resharding_collection_test.cpp
@@ -50,7 +50,7 @@ public:
Status insert(const NamespaceString& nss, const BSONObj& doc) {
const auto commandResponse = _client.runCommand([&] {
- write_ops::Insert insertOp(nss);
+ write_ops::InsertCommandRequest insertOp(nss);
insertOp.setDocuments({doc});
return insertOp.serialize({});
}());
diff --git a/src/mongo/db/s/session_catalog_migration_destination_test.cpp b/src/mongo/db/s/session_catalog_migration_destination_test.cpp
index 70116c968d9..1f7e684cfa4 100644
--- a/src/mongo/db/s/session_catalog_migration_destination_test.cpp
+++ b/src/mongo/db/s/session_catalog_migration_destination_test.cpp
@@ -226,16 +226,16 @@ public:
StmtId stmtId) {
// Do write on a separate thread in order not to pollute this thread's opCtx.
stdx::thread insertThread([sessionInfo, ns, doc, stmtId] {
- write_ops::WriteCommandBase cmdBase;
+ write_ops::WriteCommandRequestBase cmdBase;
std::vector<StmtId> stmtIds;
stmtIds.push_back(stmtId);
cmdBase.setStmtIds(stmtIds);
- write_ops::Insert insertRequest(ns);
+ write_ops::InsertCommandRequest insertRequest(ns);
std::vector<BSONObj> documents;
documents.push_back(doc);
insertRequest.setDocuments(documents);
- insertRequest.setWriteCommandBase(cmdBase);
+ insertRequest.setWriteCommandRequestBase(cmdBase);
BSONObjBuilder insertBuilder;
insertRequest.serialize({}, &insertBuilder);
diff --git a/src/mongo/db/s/shard_local.cpp b/src/mongo/db/s/shard_local.cpp
index 0682de41695..21014c5dce2 100644
--- a/src/mongo/db/s/shard_local.cpp
+++ b/src/mongo/db/s/shard_local.cpp
@@ -214,7 +214,7 @@ void ShardLocal::runFireAndForgetCommand(OperationContext* opCtx,
}
Status ShardLocal::runAggregation(OperationContext* opCtx,
- const AggregateCommand& aggRequest,
+ const AggregateCommandRequest& aggRequest,
std::function<bool(const std::vector<BSONObj>& batch)> callback) {
return _rsLocalClient.runAggregation(opCtx, aggRequest, callback);
}
diff --git a/src/mongo/db/s/shard_local.h b/src/mongo/db/s/shard_local.h
index 3991e0999a0..a9ec0d82a22 100644
--- a/src/mongo/db/s/shard_local.h
+++ b/src/mongo/db/s/shard_local.h
@@ -71,7 +71,7 @@ public:
const BSONObj& cmdObj) override;
Status runAggregation(OperationContext* opCtx,
- const AggregateCommand& aggRequest,
+ const AggregateCommandRequest& aggRequest,
std::function<bool(const std::vector<BSONObj>& batch)> callback);
private:
diff --git a/src/mongo/db/s/shard_local_test.cpp b/src/mongo/db/s/shard_local_test.cpp
index 9111b0c0cf9..9cbed53e039 100644
--- a/src/mongo/db/s/shard_local_test.cpp
+++ b/src/mongo/db/s/shard_local_test.cpp
@@ -101,7 +101,7 @@ void ShardLocalTest::tearDown() {
StatusWith<Shard::CommandResponse> ShardLocalTest::runFindAndModifyRunCommand(NamespaceString nss,
BSONObj find,
BSONObj set) {
- auto findAndModifyRequest = write_ops::FindAndModifyCommand(nss);
+ auto findAndModifyRequest = write_ops::FindAndModifyCommandRequest(nss);
findAndModifyRequest.setQuery(find);
findAndModifyRequest.setUpdate(write_ops::UpdateModification::parseFromClassicUpdate(set));
findAndModifyRequest.setUpsert(true);
diff --git a/src/mongo/db/s/shard_metadata_util.cpp b/src/mongo/db/s/shard_metadata_util.cpp
index 5fb64d1af5c..a0fb83169ef 100644
--- a/src/mongo/db/s/shard_metadata_util.cpp
+++ b/src/mongo/db/s/shard_metadata_util.cpp
@@ -226,7 +226,8 @@ Status updateShardCollectionsEntry(OperationContext* opCtx,
}
auto commandResponse = client.runCommand([&] {
- write_ops::Update updateOp(NamespaceString::kShardConfigCollectionsNamespace);
+ write_ops::UpdateCommandRequest updateOp(
+ NamespaceString::kShardConfigCollectionsNamespace);
updateOp.setUpdates({[&] {
write_ops::UpdateOpEntry entry;
entry.setQ(query);
@@ -269,7 +270,8 @@ Status updateShardDatabasesEntry(OperationContext* opCtx,
}
auto commandResponse = client.runCommand([&] {
- write_ops::Update updateOp(NamespaceString::kShardConfigDatabasesNamespace);
+ write_ops::UpdateCommandRequest updateOp(
+ NamespaceString::kShardConfigDatabasesNamespace);
updateOp.setUpdates({[&] {
write_ops::UpdateOpEntry entry;
entry.setQ(query);
@@ -372,7 +374,7 @@ Status updateShardChunks(OperationContext* opCtx,
//
// query: { "_id" : {"$gte": chunk.min, "$lt": chunk.max}}
auto deleteCommandResponse = client.runCommand([&] {
- write_ops::Delete deleteOp(chunkMetadataNss);
+ write_ops::DeleteCommandRequest deleteOp(chunkMetadataNss);
deleteOp.setDeletes({[&] {
write_ops::DeleteOpEntry entry;
entry.setQ(BSON(ChunkType::minShardID
@@ -387,7 +389,7 @@ Status updateShardChunks(OperationContext* opCtx,
// Now the document can be expected to cleanly insert without overlap
auto insertCommandResponse = client.runCommand([&] {
- write_ops::Insert insertOp(chunkMetadataNss);
+ write_ops::InsertCommandRequest insertOp(chunkMetadataNss);
insertOp.setDocuments({chunk.toShardBSON()});
return insertOp.serialize({});
}());
@@ -404,15 +406,16 @@ Status updateShardChunks(OperationContext* opCtx,
void updateTimestampOnShardCollections(OperationContext* opCtx,
const NamespaceString& nss,
const boost::optional<Timestamp>& timestamp) {
- write_ops::Update clearFields(NamespaceString::kShardConfigCollectionsNamespace, [&] {
- write_ops::UpdateOpEntry u;
- u.setQ(BSON(ShardCollectionType::kNssFieldName << nss.ns()));
- BSONObj updateOp = (timestamp)
- ? BSON("$set" << BSON(CollectionType::kTimestampFieldName << *timestamp))
- : BSON("$unset" << BSON(CollectionType::kTimestampFieldName << ""));
- u.setU(write_ops::UpdateModification::parseFromClassicUpdate(updateOp));
- return std::vector{u};
- }());
+ write_ops::UpdateCommandRequest clearFields(
+ NamespaceString::kShardConfigCollectionsNamespace, [&] {
+ write_ops::UpdateOpEntry u;
+ u.setQ(BSON(ShardCollectionType::kNssFieldName << nss.ns()));
+ BSONObj updateOp = (timestamp)
+ ? BSON("$set" << BSON(CollectionType::kTimestampFieldName << *timestamp))
+ : BSON("$unset" << BSON(CollectionType::kTimestampFieldName << ""));
+ u.setU(write_ops::UpdateModification::parseFromClassicUpdate(updateOp));
+ return std::vector{u};
+ }());
DBDirectClient client(opCtx);
const auto commandResult = client.runCommand(clearFields.serialize({}));
@@ -425,7 +428,8 @@ Status dropChunksAndDeleteCollectionsEntry(OperationContext* opCtx, const Namesp
DBDirectClient client(opCtx);
auto deleteCommandResponse = client.runCommand([&] {
- write_ops::Delete deleteOp(NamespaceString::kShardConfigCollectionsNamespace);
+ write_ops::DeleteCommandRequest deleteOp(
+ NamespaceString::kShardConfigCollectionsNamespace);
deleteOp.setDeletes({[&] {
write_ops::DeleteOpEntry entry;
entry.setQ(BSON(ShardCollectionType::kNssFieldName << nss.ns()));
@@ -483,7 +487,8 @@ Status deleteDatabasesEntry(OperationContext* opCtx, StringData dbName) {
DBDirectClient client(opCtx);
auto deleteCommandResponse = client.runCommand([&] {
- write_ops::Delete deleteOp(NamespaceString::kShardConfigDatabasesNamespace);
+ write_ops::DeleteCommandRequest deleteOp(
+ NamespaceString::kShardConfigDatabasesNamespace);
deleteOp.setDeletes({[&] {
write_ops::DeleteOpEntry entry;
entry.setQ(BSON(ShardDatabaseType::name << dbName.toString()));
diff --git a/src/mongo/db/s/sharding_ddl_util.cpp b/src/mongo/db/s/sharding_ddl_util.cpp
index 448ddeaef58..f46f696b282 100644
--- a/src/mongo/db/s/sharding_ddl_util.cpp
+++ b/src/mongo/db/s/sharding_ddl_util.cpp
@@ -309,7 +309,8 @@ void acquireRecoverableCriticalSectionBlockWrites(OperationContext* opCtx,
newDoc.setAdditionalInfo(additionalInfo);
const auto commandResponse = dbClient.runCommand([&] {
- write_ops::Insert insertOp(NamespaceString::kCollectionCriticalSectionsNamespace);
+ write_ops::InsertCommandRequest insertOp(
+ NamespaceString::kCollectionCriticalSectionsNamespace);
insertOp.setDocuments({newDoc.toBSON()});
return insertOp.serialize({});
}());
@@ -371,7 +372,8 @@ void acquireRecoverableCriticalSectionBlockReads(OperationContext* opCtx,
const auto update =
BSON("$set" << BSON(CollectionCriticalSectionDocument::kBlockReadsFieldName << true));
- write_ops::Update updateOp(NamespaceString::kCollectionCriticalSectionsNamespace);
+ write_ops::UpdateCommandRequest updateOp(
+ NamespaceString::kCollectionCriticalSectionsNamespace);
auto updateModification = write_ops::UpdateModification::parseFromClassicUpdate(update);
write_ops::UpdateOpEntry updateEntry(query, updateModification);
updateOp.setUpdates({updateEntry});
@@ -428,7 +430,8 @@ void releaseRecoverableCriticalSection(OperationContext* opCtx,
// in-mem)
auto commandResponse = dbClient.runCommand([&] {
- write_ops::Delete deleteOp(NamespaceString::kCollectionCriticalSectionsNamespace);
+ write_ops::DeleteCommandRequest deleteOp(
+ NamespaceString::kCollectionCriticalSectionsNamespace);
deleteOp.setDeletes({[&] {
write_ops::DeleteOpEntry entry;
diff --git a/src/mongo/db/s/transaction_coordinator_util.cpp b/src/mongo/db/s/transaction_coordinator_util.cpp
index 1d530f39215..9e0e6465ca4 100644
--- a/src/mongo/db/s/transaction_coordinator_util.cpp
+++ b/src/mongo/db/s/transaction_coordinator_util.cpp
@@ -126,7 +126,8 @@ repl::OpTime persistParticipantListBlocking(OperationContext* opCtx,
// Throws if serializing the request or deserializing the response fails.
const auto commandResponse = client.runCommand([&] {
- write_ops::Update updateOp(NamespaceString::kTransactionCoordinatorsNamespace);
+ write_ops::UpdateCommandRequest updateOp(
+ NamespaceString::kTransactionCoordinatorsNamespace);
updateOp.setUpdates({[&] {
write_ops::UpdateOpEntry entry;
@@ -328,7 +329,8 @@ repl::OpTime persistDecisionBlocking(OperationContext* opCtx,
// Throws if serializing the request or deserializing the response fails.
const auto commandResponse = client.runCommand([&] {
- write_ops::Update updateOp(NamespaceString::kTransactionCoordinatorsNamespace);
+ write_ops::UpdateCommandRequest updateOp(
+ NamespaceString::kTransactionCoordinatorsNamespace);
updateOp.setUpdates({[&] {
write_ops::UpdateOpEntry entry;
@@ -499,7 +501,8 @@ void deleteCoordinatorDocBlocking(OperationContext* opCtx,
// Throws if serializing the request or deserializing the response fails.
auto commandResponse = client.runCommand([&] {
- write_ops::Delete deleteOp(NamespaceString::kTransactionCoordinatorsNamespace);
+ write_ops::DeleteCommandRequest deleteOp(
+ NamespaceString::kTransactionCoordinatorsNamespace);
deleteOp.setDeletes({[&] {
write_ops::DeleteOpEntry entry;
diff --git a/src/mongo/db/session_catalog_mongod.cpp b/src/mongo/db/session_catalog_mongod.cpp
index 46ea3c29f05..86e771cc393 100644
--- a/src/mongo/db/session_catalog_mongod.cpp
+++ b/src/mongo/db/session_catalog_mongod.cpp
@@ -141,9 +141,9 @@ int removeSessionsTransactionRecords(OperationContext* opCtx,
return 0;
// Remove the session ids from the on-disk catalog
- write_ops::Delete deleteOp(NamespaceString::kSessionTransactionsTableNamespace);
- deleteOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase base;
+ write_ops::DeleteCommandRequest deleteOp(NamespaceString::kSessionTransactionsTableNamespace);
+ deleteOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase base;
base.setOrdered(false);
return base;
}());
diff --git a/src/mongo/db/transaction_history_iterator.cpp b/src/mongo/db/transaction_history_iterator.cpp
index 02ade00bf10..b8d43a3fd1b 100644
--- a/src/mongo/db/transaction_history_iterator.cpp
+++ b/src/mongo/db/transaction_history_iterator.cpp
@@ -55,7 +55,7 @@ BSONObj findOneOplogEntry(OperationContext* opCtx,
BSONObj oplogBSON;
invariant(!opTime.isNull());
- auto findCommand = std::make_unique<FindCommand>(NamespaceString::kRsOplogNamespace);
+ auto findCommand = std::make_unique<FindCommandRequest>(NamespaceString::kRsOplogNamespace);
findCommand->setFilter(opTime.asQuery());
if (prevOpOnly) {
diff --git a/src/mongo/db/ttl.cpp b/src/mongo/db/ttl.cpp
index 437a15265c9..547caa92b5a 100644
--- a/src/mongo/db/ttl.cpp
+++ b/src/mongo/db/ttl.cpp
@@ -395,7 +395,7 @@ private:
const char* keyFieldName = key.firstElement().fieldName();
BSONObj query =
BSON(keyFieldName << BSON("$gte" << kDawnOfTime << "$lte" << expirationDate));
- auto findCommand = std::make_unique<FindCommand>(collection->ns());
+ auto findCommand = std::make_unique<FindCommandRequest>(collection->ns());
findCommand->setFilter(query);
auto canonicalQuery = CanonicalQuery::canonicalize(opCtx, std::move(findCommand));
invariant(canonicalQuery.getStatus());
diff --git a/src/mongo/db/update/update_driver.cpp b/src/mongo/db/update/update_driver.cpp
index 156830388a8..eecd380ebe2 100644
--- a/src/mongo/db/update/update_driver.cpp
+++ b/src/mongo/db/update/update_driver.cpp
@@ -195,7 +195,7 @@ Status UpdateDriver::populateDocumentWithQueryFields(OperationContext* opCtx,
// We canonicalize the query to collapse $and/$or, and the namespace is not needed. Also,
// because this is for the upsert case, where we insert a new document if one was not found, the
// $where/$text clauses do not make sense, hence empty ExtensionsCallback.
- auto findCommand = std::make_unique<FindCommand>(NamespaceString(""));
+ auto findCommand = std::make_unique<FindCommandRequest>(NamespaceString(""));
findCommand->setFilter(query);
const boost::intrusive_ptr<ExpressionContext> expCtx;
// $expr is not allowed in the query for an upsert, since it is not clear what the equality
diff --git a/src/mongo/db/views/resolved_view.cpp b/src/mongo/db/views/resolved_view.cpp
index d53d8adc850..dbf86251025 100644
--- a/src/mongo/db/views/resolved_view.cpp
+++ b/src/mongo/db/views/resolved_view.cpp
@@ -90,7 +90,8 @@ std::shared_ptr<const ErrorExtraInfo> ResolvedView::parse(const BSONObj& cmdRepl
return std::make_shared<ResolvedView>(fromBSON(cmdReply));
}
-AggregateCommand ResolvedView::asExpandedViewAggregation(const AggregateCommand& request) const {
+AggregateCommandRequest ResolvedView::asExpandedViewAggregation(
+ const AggregateCommandRequest& request) const {
// Perform the aggregation on the resolved namespace. The new pipeline consists of two parts:
// first, 'pipeline' in this ResolvedView; then, the pipeline in 'request'.
std::vector<BSONObj> resolvedPipeline;
@@ -125,7 +126,7 @@ AggregateCommand ResolvedView::asExpandedViewAggregation(const AggregateCommand&
BSON(DocumentSourceInternalConvertBucketIndexStats::kStageName << builder.obj());
}
- AggregateCommand expandedRequest{_namespace, resolvedPipeline};
+ AggregateCommandRequest expandedRequest{_namespace, resolvedPipeline};
if (request.getExplain()) {
expandedRequest.setExplain(request.getExplain());
diff --git a/src/mongo/db/views/resolved_view.h b/src/mongo/db/views/resolved_view.h
index aa931189c2a..19cfefe82f9 100644
--- a/src/mongo/db/views/resolved_view.h
+++ b/src/mongo/db/views/resolved_view.h
@@ -57,7 +57,8 @@ public:
* Convert an aggregation command on a view to the equivalent command against the view's
* underlying collection.
*/
- AggregateCommand asExpandedViewAggregation(const AggregateCommand& aggRequest) const;
+ AggregateCommandRequest asExpandedViewAggregation(
+ const AggregateCommandRequest& aggRequest) const;
const NamespaceString& getNamespace() const {
return _namespace;
diff --git a/src/mongo/db/views/resolved_view_test.cpp b/src/mongo/db/views/resolved_view_test.cpp
index 95797376f28..82b0098b69d 100644
--- a/src/mongo/db/views/resolved_view_test.cpp
+++ b/src/mongo/db/views/resolved_view_test.cpp
@@ -54,7 +54,7 @@ const BSONObj kSimpleCollation;
TEST(ResolvedViewTest, ExpandingAggRequestWithEmptyPipelineOnNoOpViewYieldsEmptyPipeline) {
const ResolvedView resolvedView{backingNss, emptyPipeline, kSimpleCollation};
- AggregateCommand requestOnView{viewNss, emptyPipeline};
+ AggregateCommandRequest requestOnView{viewNss, emptyPipeline};
auto result = resolvedView.asExpandedViewAggregation(requestOnView);
BSONObj expected =
@@ -66,7 +66,7 @@ TEST(ResolvedViewTest, ExpandingAggRequestWithEmptyPipelineOnNoOpViewYieldsEmpty
TEST(ResolvedViewTest, ExpandingAggRequestWithNonemptyPipelineAppendsToViewPipeline) {
std::vector<BSONObj> viewPipeline{BSON("skip" << 7)};
const ResolvedView resolvedView{backingNss, viewPipeline, kSimpleCollation};
- AggregateCommand requestOnView{viewNss, std::vector<BSONObj>{BSON("limit" << 3)}};
+ AggregateCommandRequest requestOnView{viewNss, std::vector<BSONObj>{BSON("limit" << 3)}};
auto result = resolvedView.asExpandedViewAggregation(requestOnView);
@@ -79,7 +79,7 @@ TEST(ResolvedViewTest, ExpandingAggRequestWithNonemptyPipelineAppendsToViewPipel
TEST(ResolvedViewTest, ExpandingAggRequestPreservesExplain) {
const ResolvedView resolvedView{backingNss, emptyPipeline, kSimpleCollation};
- AggregateCommand aggRequest{viewNss, {}};
+ AggregateCommandRequest aggRequest{viewNss, {}};
aggRequest.setExplain(ExplainOptions::Verbosity::kExecStats);
auto result = resolvedView.asExpandedViewAggregation(aggRequest);
@@ -89,7 +89,7 @@ TEST(ResolvedViewTest, ExpandingAggRequestPreservesExplain) {
TEST(ResolvedViewTest, ExpandingAggRequestWithCursorAndExplainOnlyPreservesExplain) {
const ResolvedView resolvedView{backingNss, emptyPipeline, kSimpleCollation};
- AggregateCommand aggRequest{viewNss, {}};
+ AggregateCommandRequest aggRequest{viewNss, {}};
SimpleCursorOptions cursor;
cursor.setBatchSize(10);
aggRequest.setCursor(cursor);
@@ -105,7 +105,7 @@ TEST(ResolvedViewTest, ExpandingAggRequestWithCursorAndExplainOnlyPreservesExpla
TEST(ResolvedViewTest, ExpandingAggRequestPreservesBypassDocumentValidation) {
const ResolvedView resolvedView{backingNss, emptyPipeline, kSimpleCollation};
- AggregateCommand aggRequest(viewNss, {});
+ AggregateCommandRequest aggRequest(viewNss, {});
aggRequest.setBypassDocumentValidation(true);
auto result = resolvedView.asExpandedViewAggregation(aggRequest);
@@ -114,7 +114,7 @@ TEST(ResolvedViewTest, ExpandingAggRequestPreservesBypassDocumentValidation) {
TEST(ResolvedViewTest, ExpandingAggRequestPreservesAllowDiskUse) {
const ResolvedView resolvedView{backingNss, emptyPipeline, kSimpleCollation};
- AggregateCommand aggRequest(viewNss, {});
+ AggregateCommandRequest aggRequest(viewNss, {});
aggRequest.setAllowDiskUse(true);
auto result = resolvedView.asExpandedViewAggregation(aggRequest);
@@ -123,7 +123,7 @@ TEST(ResolvedViewTest, ExpandingAggRequestPreservesAllowDiskUse) {
TEST(ResolvedViewTest, ExpandingAggRequestPreservesHint) {
const ResolvedView resolvedView{backingNss, emptyPipeline, kSimpleCollation};
- AggregateCommand aggRequest(viewNss, {});
+ AggregateCommandRequest aggRequest(viewNss, {});
aggRequest.setHint(BSON("a" << 1));
auto result = resolvedView.asExpandedViewAggregation(aggRequest);
@@ -132,7 +132,7 @@ TEST(ResolvedViewTest, ExpandingAggRequestPreservesHint) {
TEST(ResolvedViewTest, ExpandingAggRequestPreservesReadPreference) {
const ResolvedView resolvedView{backingNss, emptyPipeline, kSimpleCollation};
- AggregateCommand aggRequest(viewNss, {});
+ AggregateCommandRequest aggRequest(viewNss, {});
aggRequest.setUnwrappedReadPref(BSON("$readPreference"
<< "nearest"));
@@ -144,7 +144,7 @@ TEST(ResolvedViewTest, ExpandingAggRequestPreservesReadPreference) {
TEST(ResolvedViewTest, ExpandingAggRequestPreservesReadConcern) {
const ResolvedView resolvedView{backingNss, emptyPipeline, kSimpleCollation};
- AggregateCommand aggRequest(viewNss, {});
+ AggregateCommandRequest aggRequest(viewNss, {});
aggRequest.setReadConcern(BSON("level"
<< "linearizable"));
@@ -156,7 +156,7 @@ TEST(ResolvedViewTest, ExpandingAggRequestPreservesReadConcern) {
TEST(ResolvedViewTest, ExpandingAggRequestPreservesMaxTimeMS) {
const ResolvedView resolvedView{backingNss, emptyPipeline, kSimpleCollation};
- AggregateCommand aggRequest(viewNss, {});
+ AggregateCommandRequest aggRequest(viewNss, {});
aggRequest.setMaxTimeMS(100u);
auto result = resolvedView.asExpandedViewAggregation(aggRequest);
@@ -171,7 +171,7 @@ TEST(ResolvedViewTest, ExpandingAggRequestPreservesDefaultCollationOfView) {
ASSERT_BSONOBJ_EQ(resolvedView.getDefaultCollation(),
BSON("locale"
<< "fr_CA"));
- AggregateCommand aggRequest(viewNss, {});
+ AggregateCommandRequest aggRequest(viewNss, {});
auto result = resolvedView.asExpandedViewAggregation(aggRequest);
ASSERT_BSONOBJ_EQ(result.getCollation().value_or(BSONObj()),
diff --git a/src/mongo/db/views/view_catalog.cpp b/src/mongo/db/views/view_catalog.cpp
index 6f3706c6aab..170c64a0f02 100644
--- a/src/mongo/db/views/view_catalog.cpp
+++ b/src/mongo/db/views/view_catalog.cpp
@@ -408,7 +408,7 @@ StatusWith<stdx::unordered_set<NamespaceString>> ViewCatalog::validatePipeline(
}
boost::intrusive_ptr<ExpressionContext> expCtx =
new ExpressionContext(opCtx,
- AggregateCommand(viewDef.viewOn(), viewDef.pipeline()),
+ AggregateCommandRequest(viewDef.viewOn(), viewDef.pipeline()),
CollatorInterface::cloneCollator(viewDef.defaultCollator()),
// We can use a stub MongoProcessInterface because we are only parsing
// the Pipeline for validation here. We won't do anything with the
diff --git a/src/mongo/dbtests/documentsourcetests.cpp b/src/mongo/dbtests/documentsourcetests.cpp
index 811e8bf6882..79d1d3f8472 100644
--- a/src/mongo/dbtests/documentsourcetests.cpp
+++ b/src/mongo/dbtests/documentsourcetests.cpp
@@ -77,7 +77,7 @@ class DocumentSourceCursorTest : public unittest::Test {
public:
DocumentSourceCursorTest()
: client(_opCtx.get()),
- _ctx(new ExpressionContextForTest(_opCtx.get(), AggregateCommand(nss, {}))) {
+ _ctx(new ExpressionContextForTest(_opCtx.get(), AggregateCommandRequest(nss, {}))) {
_ctx->tempDir = storageGlobalParams.dbpath + "/_tmp";
}
@@ -93,7 +93,7 @@ protected:
dbtests::WriteContextForTests ctx(opCtx(), nss.ns());
_coll = ctx.getCollection();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
if (hint) {
findCommand->setHint(*hint);
}
@@ -312,7 +312,7 @@ TEST_F(DocumentSourceCursorTest, TailableAwaitDataCursorShouldErrorAfterTimeout)
collScanParams,
workingSet.get(),
matchExpression.get());
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(filter);
query_request_helper::setTailableMode(TailableModeEnum::kTailableAndAwaitData,
findCommand.get());
@@ -356,7 +356,7 @@ TEST_F(DocumentSourceCursorTest, NonAwaitDataCursorShouldErrorAfterTimeout) {
collScanParams,
workingSet.get(),
matchExpression.get());
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(filter);
auto canonicalQuery = unittest::assertGet(
CanonicalQuery::canonicalize(opCtx(), std::move(findCommand), false, nullptr));
@@ -408,7 +408,7 @@ TEST_F(DocumentSourceCursorTest, TailableAwaitDataCursorShouldErrorAfterBeingKil
collScanParams,
workingSet.get(),
matchExpression.get());
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(filter);
query_request_helper::setTailableMode(TailableModeEnum::kTailableAndAwaitData,
findCommand.get());
@@ -451,7 +451,7 @@ TEST_F(DocumentSourceCursorTest, NormalCursorShouldErrorAfterBeingKilled) {
collScanParams,
workingSet.get(),
matchExpression.get());
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(filter);
auto canonicalQuery = unittest::assertGet(
CanonicalQuery::canonicalize(opCtx(), std::move(findCommand), false, nullptr));
diff --git a/src/mongo/dbtests/plan_executor_invalidation_test.cpp b/src/mongo/dbtests/plan_executor_invalidation_test.cpp
index e77c5d59c1a..db2845569d4 100644
--- a/src/mongo/dbtests/plan_executor_invalidation_test.cpp
+++ b/src/mongo/dbtests/plan_executor_invalidation_test.cpp
@@ -81,7 +81,7 @@ public:
new CollectionScan(_expCtx.get(), collection(), params, ws.get(), nullptr));
// Create a plan executor to hold it
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
auto statusWithCQ = CanonicalQuery::canonicalize(&_opCtx, std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
std::unique_ptr<CanonicalQuery> cq = std::move(statusWithCQ.getValue());
diff --git a/src/mongo/dbtests/plan_ranking.cpp b/src/mongo/dbtests/plan_ranking.cpp
index 49bab818c7c..f13eb4280e2 100644
--- a/src/mongo/dbtests/plan_ranking.cpp
+++ b/src/mongo/dbtests/plan_ranking.cpp
@@ -231,7 +231,7 @@ public:
addIndex(BSON("d" << 1));
// Query: find({a: 1}).sort({d: 1})
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("a" << 1));
findCommand->setSort(BSON("d" << 1));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
@@ -288,7 +288,7 @@ public:
// Run the query {a:4, b:1}.
{
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("a" << 100 << "b" << 1));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
verify(statusWithCQ.isOK());
@@ -307,7 +307,7 @@ public:
// And run the same query again.
{
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("a" << 100 << "b" << 1));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
verify(statusWithCQ.isOK());
@@ -342,7 +342,7 @@ public:
addIndex(BSON("b" << 1));
// Run the query {a:1, b:{$gt:1}.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("a" << 1 << "b" << BSON("$gt" << 1)));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
verify(statusWithCQ.isOK());
@@ -382,7 +382,7 @@ public:
addIndex(BSON("a" << 1 << "b" << 1));
// Query for a==27 with projection that wants 'a' and 'b'.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("a" << 27));
findCommand->setProjection(BSON("_id" << 0 << "a" << 1 << "b" << 1));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
@@ -417,7 +417,7 @@ public:
addIndex(BSON("b" << 1));
// There is no data that matches this query but we don't know that until EOF.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("a" << 1 << "b" << 1 << "c" << 99));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
@@ -454,7 +454,7 @@ public:
// There is no data that matches this query ({a:2}). Both scans will hit EOF before
// returning any data.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("a" << 2));
findCommand->setProjection(BSON("_id" << 0 << "a" << 1 << "b" << 1));
@@ -489,7 +489,7 @@ public:
addIndex(BSON("b" << 1));
// Run the query {a:N+1, b:1}. (No such document.)
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("a" << N + 1 << "b" << 1));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
verify(statusWithCQ.isOK());
@@ -525,7 +525,7 @@ public:
addIndex(BSON("b" << 1));
// Run the query {a:N+1, b:1}. (No such document.)
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("a" << BSON("$gte" << N + 1) << "b" << 1));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
verify(statusWithCQ.isOK());
@@ -554,7 +554,7 @@ public:
// Run a query with a sort. The blocking sort won't produce any data during the
// evaluation period.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("_id" << BSON("$gte" << 20 << "$lte" << 200)));
findCommand->setSort(BSON("c" << 1));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
@@ -584,7 +584,7 @@ public:
}
// Look for A Space Odyssey.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("foo" << 2001));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
verify(statusWithCQ.isOK());
@@ -617,7 +617,7 @@ public:
addIndex(BSON("d" << 1 << "e" << 1));
// Query: find({a: 1}).sort({d: 1})
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("a" << 1));
findCommand->setSort(BSON("d" << 1));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
@@ -655,7 +655,7 @@ public:
// Solutions using either 'a' or 'b' will take a long time to start producing
// results. However, an index scan on 'b' will start producing results sooner
// than an index scan on 'a'.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(fromjson("{a: 1, b: 1, c: {$gte: 5000}}"));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
@@ -687,7 +687,7 @@ public:
addIndex(BSON("b" << 1 << "c" << 1));
addIndex(BSON("a" << 1));
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(fromjson("{a: 9, b: {$ne: 10}, c: 9}"));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
diff --git a/src/mongo/dbtests/query_plan_executor.cpp b/src/mongo/dbtests/query_plan_executor.cpp
index 16fb33ca586..3a71e0be8e2 100644
--- a/src/mongo/dbtests/query_plan_executor.cpp
+++ b/src/mongo/dbtests/query_plan_executor.cpp
@@ -106,7 +106,7 @@ public:
unique_ptr<WorkingSet> ws(new WorkingSet());
// Canonicalize the query.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(filterObj);
query_request_helper::setTailableMode(tailableMode, findCommand.get());
auto statusWithCQ = CanonicalQuery::canonicalize(&_opCtx, std::move(findCommand));
@@ -155,7 +155,7 @@ public:
unique_ptr<PlanStage> root =
std::make_unique<FetchStage>(_expCtx.get(), ws.get(), std::move(ixscan), nullptr, coll);
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
auto statusWithCQ = CanonicalQuery::canonicalize(&_opCtx, std::move(findCommand));
verify(statusWithCQ.isOK());
unique_ptr<CanonicalQuery> cq = std::move(statusWithCQ.getValue());
diff --git a/src/mongo/dbtests/query_stage_cached_plan.cpp b/src/mongo/dbtests/query_stage_cached_plan.cpp
index f79bcb15763..abfcddb97d9 100644
--- a/src/mongo/dbtests/query_stage_cached_plan.cpp
+++ b/src/mongo/dbtests/query_stage_cached_plan.cpp
@@ -60,7 +60,7 @@ namespace {
std::unique_ptr<CanonicalQuery> canonicalQueryFromFilterObj(OperationContext* opCtx,
const NamespaceString& nss,
BSONObj filter) {
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(filter);
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx, std::move(findCommand));
uassertStatusOK(statusWithCQ.getStatus());
@@ -187,7 +187,7 @@ TEST_F(QueryStageCachedPlan, QueryStageCachedPlanFailureMemoryLimitExceeded) {
ASSERT(collection);
// Query can be answered by either index on "a" or index on "b".
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(fromjson("{a: {$gte: 8}, b: 1}"));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
@@ -237,7 +237,7 @@ TEST_F(QueryStageCachedPlan, QueryStageCachedPlanHitMaxWorks) {
ASSERT(collection);
// Query can be answered by either index on "a" or index on "b".
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(fromjson("{a: {$gte: 8}, b: 1}"));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
@@ -448,7 +448,7 @@ TEST_F(QueryStageCachedPlan, ThrowsOnYieldRecoveryWhenIndexIsDroppedBeforePlanSe
ASSERT(collection);
// Query can be answered by either index on "a" or index on "b".
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
const std::unique_ptr<CanonicalQuery> cq = std::move(statusWithCQ.getValue());
@@ -492,7 +492,7 @@ TEST_F(QueryStageCachedPlan, DoesNotThrowOnYieldRecoveryWhenIndexIsDroppedAferPl
ASSERT(collection);
// Query can be answered by either index on "a" or index on "b".
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
const std::unique_ptr<CanonicalQuery> cq = std::move(statusWithCQ.getValue());
diff --git a/src/mongo/dbtests/query_stage_count.cpp b/src/mongo/dbtests/query_stage_count.cpp
index 008d7fbff8f..1456bb2c231 100644
--- a/src/mongo/dbtests/query_stage_count.cpp
+++ b/src/mongo/dbtests/query_stage_count.cpp
@@ -143,7 +143,9 @@ public:
// - asserts count is not trivial
// - asserts nCounted is equal to expected_n
// - asserts nSkipped is correct
- void testCount(const CountCommand& request, int expected_n = kDocuments, bool indexed = false) {
+ void testCount(const CountCommandRequest& request,
+ int expected_n = kDocuments,
+ bool indexed = false) {
setup();
getRecordIds();
@@ -244,7 +246,7 @@ protected:
class QueryStageCountNoChangeDuringYield : public CountStageTest {
public:
void run() {
- CountCommand request((NamespaceString(ns())));
+ CountCommandRequest request((NamespaceString(ns())));
request.setQuery(BSON("x" << LT << kDocuments / 2));
testCount(request, kDocuments / 2);
@@ -255,7 +257,7 @@ public:
class QueryStageCountYieldWithSkip : public CountStageTest {
public:
void run() {
- CountCommand request((NamespaceString(ns())));
+ CountCommandRequest request((NamespaceString(ns())));
request.setQuery(BSON("x" << GTE << 0));
request.setSkip(2);
@@ -267,7 +269,7 @@ public:
class QueryStageCountYieldWithLimit : public CountStageTest {
public:
void run() {
- CountCommand request((NamespaceString(ns())));
+ CountCommandRequest request((NamespaceString(ns())));
request.setQuery(BSON("x" << GTE << 0));
request.setSkip(0);
request.setLimit(2);
@@ -281,7 +283,7 @@ public:
class QueryStageCountInsertDuringYield : public CountStageTest {
public:
void run() {
- CountCommand request((NamespaceString(ns())));
+ CountCommandRequest request((NamespaceString(ns())));
request.setQuery(BSON("x" << 1));
testCount(request, kInterjections + 1);
@@ -299,7 +301,7 @@ public:
void run() {
// expected count would be 99 but we delete the second record
// after doing the first unit of work
- CountCommand request((NamespaceString(ns())));
+ CountCommandRequest request((NamespaceString(ns())));
request.setQuery(BSON("x" << GTE << 1));
testCount(request, kDocuments - 2);
@@ -325,7 +327,7 @@ public:
void run() {
// expected count would be kDocuments-2 but we update the first and second records
// after doing the first unit of work so they wind up getting counted later on
- CountCommand request((NamespaceString(ns())));
+ CountCommandRequest request((NamespaceString(ns())));
request.setQuery(BSON("x" << GTE << 2));
testCount(request, kDocuments);
@@ -347,7 +349,7 @@ public:
class QueryStageCountMultiKeyDuringYield : public CountStageTest {
public:
void run() {
- CountCommand request((NamespaceString(ns())));
+ CountCommandRequest request((NamespaceString(ns())));
request.setQuery(BSON("x" << 1));
testCount(request, kDocuments + 1, true); // only applies to indexed case
}
diff --git a/src/mongo/dbtests/query_stage_delete.cpp b/src/mongo/dbtests/query_stage_delete.cpp
index 93fbd082916..cfb98922972 100644
--- a/src/mongo/dbtests/query_stage_delete.cpp
+++ b/src/mongo/dbtests/query_stage_delete.cpp
@@ -104,7 +104,7 @@ public:
}
unique_ptr<CanonicalQuery> canonicalize(const BSONObj& query) {
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(query);
auto statusWithCQ = CanonicalQuery::canonicalize(&_opCtx, std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
diff --git a/src/mongo/dbtests/query_stage_multiplan.cpp b/src/mongo/dbtests/query_stage_multiplan.cpp
index 2f4ca2e6c1f..d91586485bb 100644
--- a/src/mongo/dbtests/query_stage_multiplan.cpp
+++ b/src/mongo/dbtests/query_stage_multiplan.cpp
@@ -128,7 +128,7 @@ protected:
std::unique_ptr<CanonicalQuery> makeCanonicalQuery(OperationContext* opCtx,
NamespaceString nss,
BSONObj filter) {
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(filter);
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx, std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
@@ -378,7 +378,7 @@ TEST_F(QueryStageMultiPlanTest, MPSBackupPlan) {
AutoGetCollectionForReadCommand collection(_opCtx.get(), nss);
// Query for both 'a' and 'b' and sort on 'b'.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("a" << 1 << "b" << 1));
findCommand->setSort(BSON("b" << 1));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
@@ -490,7 +490,7 @@ TEST_F(QueryStageMultiPlanTest, MPSExplainAllPlans) {
AutoGetCollectionForReadCommand ctx(_opCtx.get(), nss);
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("x" << 1));
auto cq = uassertStatusOK(CanonicalQuery::canonicalize(opCtx(), std::move(findCommand)));
unique_ptr<MultiPlanStage> mps =
@@ -562,7 +562,7 @@ TEST_F(QueryStageMultiPlanTest, MPSSummaryStats) {
const CollectionPtr& coll = ctx.getCollection();
// Create the executor (Matching all documents).
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("foo" << BSON("$gte" << 0)));
auto cq = uassertStatusOK(CanonicalQuery::canonicalize(opCtx(), std::move(findCommand)));
auto exec = uassertStatusOK(
@@ -615,7 +615,7 @@ TEST_F(QueryStageMultiPlanTest, ShouldReportErrorIfExceedsTimeLimitDuringPlannin
getCollScanPlan(_expCtx.get(), coll.getCollection(), sharedWs.get(), filter.get());
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(filterObj);
auto canonicalQuery =
uassertStatusOK(CanonicalQuery::canonicalize(opCtx(), std::move(findCommand)));
@@ -655,7 +655,7 @@ TEST_F(QueryStageMultiPlanTest, ShouldReportErrorIfKilledDuringPlanning) {
unique_ptr<PlanStage> collScanRoot =
getCollScanPlan(_expCtx.get(), coll.getCollection(), sharedWs.get(), filter.get());
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("foo" << BSON("$gte" << 0)));
auto canonicalQuery =
uassertStatusOK(CanonicalQuery::canonicalize(opCtx(), std::move(findCommand)));
@@ -698,7 +698,7 @@ TEST_F(QueryStageMultiPlanTest, AddsContextDuringException) {
insert(BSON("foo" << 10));
AutoGetCollectionForReadCommand ctx(_opCtx.get(), nss);
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("fake"
<< "query"));
auto canonicalQuery =
diff --git a/src/mongo/dbtests/query_stage_subplan.cpp b/src/mongo/dbtests/query_stage_subplan.cpp
index 1a63e655cf9..5f8807bfc4d 100644
--- a/src/mongo/dbtests/query_stage_subplan.cpp
+++ b/src/mongo/dbtests/query_stage_subplan.cpp
@@ -137,7 +137,7 @@ TEST_F(QueryStageSubplanTest, QueryStageSubplanGeo2dOr) {
"{$or: [{a: {$geoWithin: {$centerSphere: [[0,0],10]}}},"
"{a: {$geoWithin: {$centerSphere: [[1,1],10]}}}]}");
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(query);
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
@@ -174,7 +174,7 @@ void assertSubplanFromCache(QueryStageSubplanTest* test, const dbtests::WriteCon
CollectionPtr collection = ctx.getCollection();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(query);
auto statusWithCQ = CanonicalQuery::canonicalize(test->opCtx(), std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
@@ -258,7 +258,7 @@ TEST_F(QueryStageSubplanTest, QueryStageSubplanDontCacheZeroResults) {
CollectionPtr collection = ctx.getCollection();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(query);
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
@@ -314,7 +314,7 @@ TEST_F(QueryStageSubplanTest, QueryStageSubplanDontCacheTies) {
CollectionPtr collection = ctx.getCollection();
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(query);
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
@@ -486,7 +486,7 @@ TEST_F(QueryStageSubplanTest, QueryStageSubplanPlanRootedOrNE) {
insert(BSON("_id" << 3 << "a" << 3));
insert(BSON("_id" << 4));
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(fromjson("{$or: [{a: 1}, {a: {$ne:1}}]}"));
findCommand->setSort(BSON("d" << 1));
auto cq = unittest::assertGet(CanonicalQuery::canonicalize(opCtx(), std::move(findCommand)));
@@ -519,7 +519,7 @@ TEST_F(QueryStageSubplanTest, QueryStageSubplanPlanRootedOrNE) {
TEST_F(QueryStageSubplanTest, ShouldReportErrorIfExceedsTimeLimitDuringPlanning) {
dbtests::WriteContextForTests ctx(opCtx(), nss.ns());
// Build a query with a rooted $or.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("$or" << BSON_ARRAY(BSON("p1" << 1) << BSON("p2" << 2))));
auto canonicalQuery =
uassertStatusOK(CanonicalQuery::canonicalize(opCtx(), std::move(findCommand)));
@@ -552,7 +552,7 @@ TEST_F(QueryStageSubplanTest, ShouldReportErrorIfExceedsTimeLimitDuringPlanning)
TEST_F(QueryStageSubplanTest, ShouldReportErrorIfKilledDuringPlanning) {
dbtests::WriteContextForTests ctx(opCtx(), nss.ns());
// Build a query with a rooted $or.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("$or" << BSON_ARRAY(BSON("p1" << 1) << BSON("p2" << 2))));
auto canonicalQuery =
uassertStatusOK(CanonicalQuery::canonicalize(opCtx(), std::move(findCommand)));
@@ -589,7 +589,7 @@ TEST_F(QueryStageSubplanTest, ShouldThrowOnRestoreIfIndexDroppedBeforePlanSelect
}
// Build a query with a rooted $or.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("$or" << BSON_ARRAY(BSON("p1" << 1) << BSON("p2" << 2))));
auto canonicalQuery =
uassertStatusOK(CanonicalQuery::canonicalize(opCtx(), std::move(findCommand)));
@@ -635,7 +635,7 @@ TEST_F(QueryStageSubplanTest, ShouldNotThrowOnRestoreIfIndexDroppedAfterPlanSele
}
// Build a query with a rooted $or.
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(BSON("$or" << BSON_ARRAY(BSON("p1" << 1) << BSON("p2" << 2))));
auto canonicalQuery =
uassertStatusOK(CanonicalQuery::canonicalize(opCtx(), std::move(findCommand)));
diff --git a/src/mongo/dbtests/query_stage_update.cpp b/src/mongo/dbtests/query_stage_update.cpp
index 4ef593dfa76..64db23ea494 100644
--- a/src/mongo/dbtests/query_stage_update.cpp
+++ b/src/mongo/dbtests/query_stage_update.cpp
@@ -99,7 +99,7 @@ public:
}
unique_ptr<CanonicalQuery> canonicalize(const BSONObj& query) {
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(query);
auto statusWithCQ = CanonicalQuery::canonicalize(&_opCtx, std::move(findCommand));
ASSERT_OK(statusWithCQ.getStatus());
diff --git a/src/mongo/executor/task_executor_cursor.cpp b/src/mongo/executor/task_executor_cursor.cpp
index 8af39f80a09..58a7317dc49 100644
--- a/src/mongo/executor/task_executor_cursor.cpp
+++ b/src/mongo/executor/task_executor_cursor.cpp
@@ -69,7 +69,8 @@ TaskExecutorCursor::~TaskExecutorCursor() {
// timeout if an lsid is used.
_executor
->scheduleRemoteCommand(
- _createRequest(nullptr, KillCursorsRequest(_ns, {_cursorId}).toBSON(BSONObj{})),
+ _createRequest(nullptr,
+ KillCursorsCommandRequest(_ns, {_cursorId}).toBSON(BSONObj{})),
[](const auto&) {})
.isOK();
}
diff --git a/src/mongo/s/catalog/sharding_catalog_client_impl.cpp b/src/mongo/s/catalog/sharding_catalog_client_impl.cpp
index d2ce143b13c..c93a9c5d473 100644
--- a/src/mongo/s/catalog/sharding_catalog_client_impl.cpp
+++ b/src/mongo/s/catalog/sharding_catalog_client_impl.cpp
@@ -111,7 +111,7 @@ void sendRetryableWriteBatchRequestToConfig(OperationContext* opCtx,
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
+ write_ops::InsertCommandRequest insertOp(nss);
insertOp.setDocuments(docs);
return insertOp;
}());
@@ -135,9 +135,9 @@ void sendRetryableWriteBatchRequestToConfig(OperationContext* opCtx,
uassertStatusOK(writeStatus);
}
-AggregateCommand makeCollectionAndChunksAggregation(OperationContext* opCtx,
- const NamespaceString& nss,
- const ChunkVersion& sinceVersion) {
+AggregateCommandRequest makeCollectionAndChunksAggregation(OperationContext* opCtx,
+ const NamespaceString& nss,
+ const ChunkVersion& sinceVersion) {
auto expCtx = make_intrusive<ExpressionContext>(opCtx, nullptr, nss);
StringMap<ExpressionContext::ResolvedNamespace> resolvedNamespaces;
resolvedNamespaces[CollectionType::ConfigNS.coll()] = {CollectionType::ConfigNS,
@@ -408,7 +408,7 @@ AggregateCommand makeCollectionAndChunksAggregation(OperationContext* opCtx,
auto pipeline = Pipeline::create(std::move(stages), expCtx);
auto serializedPipeline = pipeline->serializeToBson();
- return AggregateCommand(CollectionType::ConfigNS, std::move(serializedPipeline));
+ return AggregateCommandRequest(CollectionType::ConfigNS, std::move(serializedPipeline));
}
} // namespace
@@ -1043,7 +1043,7 @@ Status ShardingCatalogClientImpl::insertConfigDocument(OperationContext* opCtx,
const BSONElement idField = doc.getField("_id");
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
+ write_ops::InsertCommandRequest insertOp(nss);
insertOp.setDocuments({doc});
return insertOp;
}());
@@ -1170,7 +1170,7 @@ StatusWith<bool> ShardingCatalogClientImpl::_updateConfigDocument(
invariant(nss.db() == NamespaceString::kConfigDb);
BatchedCommandRequest request([&] {
- write_ops::Update updateOp(nss);
+ write_ops::UpdateCommandRequest updateOp(nss);
updateOp.setUpdates({[&] {
write_ops::UpdateOpEntry entry;
entry.setQ(query);
@@ -1204,7 +1204,7 @@ Status ShardingCatalogClientImpl::removeConfigDocuments(OperationContext* opCtx,
invariant(nss.db() == NamespaceString::kConfigDb);
BatchedCommandRequest request([&] {
- write_ops::Delete deleteOp(nss);
+ write_ops::DeleteCommandRequest deleteOp(nss);
deleteOp.setDeletes({[&] {
write_ops::DeleteOpEntry entry;
entry.setQ(query);
diff --git a/src/mongo/s/chunk_manager.cpp b/src/mongo/s/chunk_manager.cpp
index 1ddbccfe938..1bb16efcf2e 100644
--- a/src/mongo/s/chunk_manager.cpp
+++ b/src/mongo/s/chunk_manager.cpp
@@ -384,7 +384,7 @@ void ChunkManager::getShardIdsForQuery(boost::intrusive_ptr<ExpressionContext> e
const BSONObj& query,
const BSONObj& collation,
std::set<ShardId>* shardIds) const {
- auto findCommand = std::make_unique<FindCommand>(_rt->optRt->nss());
+ auto findCommand = std::make_unique<FindCommandRequest>(_rt->optRt->nss());
findCommand->setFilter(query.getOwned());
if (auto uuid = getUUID())
diff --git a/src/mongo/s/chunk_manager_index_bounds_test.cpp b/src/mongo/s/chunk_manager_index_bounds_test.cpp
index 611c50fe13f..d8a5710fa22 100644
--- a/src/mongo/s/chunk_manager_index_bounds_test.cpp
+++ b/src/mongo/s/chunk_manager_index_bounds_test.cpp
@@ -56,7 +56,7 @@ protected:
std::unique_ptr<CanonicalQuery> canonicalize(const char* queryStr) {
BSONObj queryObj = fromjson(queryStr);
const NamespaceString nss("test.foo");
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(queryObj);
boost::intrusive_ptr<ExpressionContextForTest> expCtx(
new ExpressionContextForTest(operationContext()));
diff --git a/src/mongo/s/chunk_manager_targeter.cpp b/src/mongo/s/chunk_manager_targeter.cpp
index ef9c3d9616c..8eae8760112 100644
--- a/src/mongo/s/chunk_manager_targeter.cpp
+++ b/src/mongo/s/chunk_manager_targeter.cpp
@@ -182,7 +182,7 @@ bool isExactIdQuery(OperationContext* opCtx, const CanonicalQuery& query, const
}
if (CollationIndexKey::isCollatableType(idElt.type()) && cm.isSharded() &&
- !query.getFindCommand().getCollation().isEmpty() &&
+ !query.getFindCommandRequest().getCollation().isEmpty() &&
!CollatorInterface::collatorsMatch(query.getCollator(), cm.getDefaultCollator())) {
// The collation applies to the _id field, but the user specified a collation which doesn't
@@ -198,7 +198,7 @@ bool isExactIdQuery(OperationContext* opCtx,
const BSONObj query,
const BSONObj collation,
const ChunkManager& cm) {
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(query);
if (!collation.isEmpty()) {
findCommand->setCollation(collation);
@@ -509,7 +509,7 @@ std::vector<ShardEndpoint> ChunkManagerTargeter::targetDelete(OperationContext*
// We failed to target a single shard.
// Parse delete query.
- auto findCommand = std::make_unique<FindCommand>(_nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(_nss);
findCommand->setFilter(deleteOp.getQ());
if (!collation.isEmpty()) {
findCommand->setCollation(collation);
diff --git a/src/mongo/s/chunk_manager_targeter_test.cpp b/src/mongo/s/chunk_manager_targeter_test.cpp
index 2ef0a29cbfb..52e4bf1cecf 100644
--- a/src/mongo/s/chunk_manager_targeter_test.cpp
+++ b/src/mongo/s/chunk_manager_targeter_test.cpp
@@ -47,7 +47,7 @@ using unittest::assertGet;
const NamespaceString kNss("TestDB", "TestColl");
auto buildUpdate(const NamespaceString& nss, BSONObj query, BSONObj update, bool upsert) {
- write_ops::Update updateOp(nss);
+ write_ops::UpdateCommandRequest updateOp(nss);
write_ops::UpdateOpEntry entry;
entry.setQ(query);
entry.setU(write_ops::UpdateModification::parseFromClassicUpdate(update));
@@ -57,7 +57,7 @@ auto buildUpdate(const NamespaceString& nss, BSONObj query, BSONObj update, bool
}
auto buildDelete(const NamespaceString& nss, BSONObj query) {
- write_ops::Delete deleteOp(nss);
+ write_ops::DeleteCommandRequest deleteOp(nss);
write_ops::DeleteOpEntry entry;
entry.setQ(query);
entry.setMulti(false);
diff --git a/src/mongo/s/client/shard.h b/src/mongo/s/client/shard.h
index 6e707423414..be61ec54877 100644
--- a/src/mongo/s/client/shard.h
+++ b/src/mongo/s/client/shard.h
@@ -217,7 +217,7 @@ public:
*/
virtual Status runAggregation(
OperationContext* opCtx,
- const AggregateCommand& aggRequest,
+ const AggregateCommandRequest& aggRequest,
std::function<bool(const std::vector<BSONObj>& batch)> callback) = 0;
/**
diff --git a/src/mongo/s/client/shard_remote.cpp b/src/mongo/s/client/shard_remote.cpp
index 77250817f40..9087cb5d244 100644
--- a/src/mongo/s/client/shard_remote.cpp
+++ b/src/mongo/s/client/shard_remote.cpp
@@ -376,7 +376,7 @@ StatusWith<Shard::QueryResponse> ShardRemote::_exhaustiveFindOnConfig(
BSONObjBuilder findCmdBuilder;
{
- FindCommand findCommand(nss);
+ FindCommandRequest findCommand(nss);
findCommand.setFilter(query.getOwned());
findCommand.setSort(sort.getOwned());
findCommand.setReadConcern(readConcernObj.getOwned());
@@ -423,7 +423,7 @@ void ShardRemote::runFireAndForgetCommand(OperationContext* opCtx,
Status ShardRemote::runAggregation(
OperationContext* opCtx,
- const AggregateCommand& aggRequest,
+ const AggregateCommandRequest& aggRequest,
std::function<bool(const std::vector<BSONObj>& batch)> callback) {
BSONObj readPrefMetadata;
diff --git a/src/mongo/s/client/shard_remote.h b/src/mongo/s/client/shard_remote.h
index 7cf83cb5a39..69a7c2233bf 100644
--- a/src/mongo/s/client/shard_remote.h
+++ b/src/mongo/s/client/shard_remote.h
@@ -86,7 +86,7 @@ public:
const BSONObj& cmdObj) final;
Status runAggregation(OperationContext* opCtx,
- const AggregateCommand& aggRequest,
+ const AggregateCommandRequest& aggRequest,
std::function<bool(const std::vector<BSONObj>& batch)> callback);
private:
diff --git a/src/mongo/s/commands/cluster_count_cmd.cpp b/src/mongo/s/commands/cluster_count_cmd.cpp
index cf8f22a44fd..3d6e8672211 100644
--- a/src/mongo/s/commands/cluster_count_cmd.cpp
+++ b/src/mongo/s/commands/cluster_count_cmd.cpp
@@ -94,7 +94,7 @@ public:
std::vector<AsyncRequestsSender::Response> shardResponses;
try {
- auto countRequest = CountCommand::parse(IDLParserErrorContext("count"), cmdObj);
+ auto countRequest = CountCommandRequest::parse(IDLParserErrorContext("count"), cmdObj);
// We only need to factor in the skip value when sending to the shards if we
// have a value for limit, otherwise, we apply it only once we have collected all
@@ -125,7 +125,7 @@ public:
collation);
} catch (const ExceptionFor<ErrorCodes::CommandOnShardedViewNotSupportedOnMongod>& ex) {
// Rewrite the count command as an aggregation.
- auto countRequest = CountCommand::parse(IDLParserErrorContext("count"), cmdObj);
+ auto countRequest = CountCommandRequest::parse(IDLParserErrorContext("count"), cmdObj);
auto aggCmdOnView =
uassertStatusOK(countCommandAsAggregationCommand(countRequest, nss));
auto aggCmdOnViewObj = OpMsgRequest::fromDBAndBody(nss.db(), aggCmdOnView).body;
@@ -229,9 +229,9 @@ public:
targetingQuery,
targetingCollation);
} catch (const ExceptionFor<ErrorCodes::CommandOnShardedViewNotSupportedOnMongod>& ex) {
- CountCommand countRequest(NamespaceStringOrUUID(NamespaceString{}));
+ CountCommandRequest countRequest(NamespaceStringOrUUID(NamespaceString{}));
try {
- countRequest = CountCommand::parse(IDLParserErrorContext("count"), cmdObj);
+ countRequest = CountCommandRequest::parse(IDLParserErrorContext("count"), cmdObj);
} catch (...) {
return exceptionToStatus();
}
diff --git a/src/mongo/s/commands/cluster_current_op.cpp b/src/mongo/s/commands/cluster_current_op.cpp
index 71849c56a9f..3c0e73f30d3 100644
--- a/src/mongo/s/commands/cluster_current_op.cpp
+++ b/src/mongo/s/commands/cluster_current_op.cpp
@@ -70,8 +70,8 @@ private:
pipeline->push_back(sortBuilder.obj());
}
- virtual StatusWith<CursorResponse> runAggregation(OperationContext* opCtx,
- const AggregateCommand& request) const final {
+ virtual StatusWith<CursorResponse> runAggregation(
+ OperationContext* opCtx, const AggregateCommandRequest& request) const final {
auto nss = request.getNamespace();
BSONObjBuilder responseBuilder;
diff --git a/src/mongo/s/commands/cluster_explain_cmd.cpp b/src/mongo/s/commands/cluster_explain_cmd.cpp
index 4a69c0360fa..287ec9902d7 100644
--- a/src/mongo/s/commands/cluster_explain_cmd.cpp
+++ b/src/mongo/s/commands/cluster_explain_cmd.cpp
@@ -175,8 +175,8 @@ std::unique_ptr<CommandInvocation> ClusterExplainCmd::parse(OperationContext* op
CommandHelpers::uassertNoDocumentSequences(getName(), request);
// To enforce API versioning
- auto cmdObj = ExplainCmd::parse(
- IDLParserErrorContext(ExplainCmd::kCommandName,
+ auto cmdObj = ExplainCommandRequest::parse(
+ IDLParserErrorContext(ExplainCommandRequest::kCommandName,
APIParameters::get(opCtx).getAPIStrict().value_or(false)),
request.body);
std::string dbName = cmdObj.getDbName().toString();
diff --git a/src/mongo/s/commands/cluster_find_cmd.cpp b/src/mongo/s/commands/cluster_find_cmd.cpp
index 20508a7fc66..7230f6b2095 100644
--- a/src/mongo/s/commands/cluster_find_cmd.cpp
+++ b/src/mongo/s/commands/cluster_find_cmd.cpp
@@ -56,11 +56,12 @@ using std::vector;
const char kTermField[] = "term";
-// Parses the command object to a FindCommand, validates that no runtime constants were supplied
-// with the command, and sets the constant runtime values that will be forwarded to each shard.
-std::unique_ptr<FindCommand> parseCmdObjectToFindCommand(OperationContext* opCtx,
- NamespaceString nss,
- BSONObj cmdObj) {
+// Parses the command object to a FindCommandRequest, validates that no runtime constants were
+// supplied with the command, and sets the constant runtime values that will be forwarded to each
+// shard.
+std::unique_ptr<FindCommandRequest> parseCmdObjectToFindCommandRequest(OperationContext* opCtx,
+ NamespaceString nss,
+ BSONObj cmdObj) {
auto findCommand = query_request_helper::makeFromFindCommand(
std::move(cmdObj),
std::move(nss),
@@ -151,8 +152,8 @@ public:
void explain(OperationContext* opCtx,
ExplainOptions::Verbosity verbosity,
rpc::ReplyBuilderInterface* result) override {
- // Parse the command BSON to a FindCommand.
- auto findCommand = parseCmdObjectToFindCommand(opCtx, ns(), _request.body);
+ // Parse the command BSON to a FindCommandRequest.
+ auto findCommand = parseCmdObjectToFindCommandRequest(opCtx, ns(), _request.body);
try {
const auto explainCmd =
@@ -225,7 +226,7 @@ public:
opCtx, mongo::LogicalOp::opQuery);
});
- auto findCommand = parseCmdObjectToFindCommand(opCtx, ns(), _request.body);
+ auto findCommand = parseCmdObjectToFindCommandRequest(opCtx, ns(), _request.body);
const boost::intrusive_ptr<ExpressionContext> expCtx;
auto cq = uassertStatusOK(
@@ -261,7 +262,7 @@ public:
result->reset();
auto aggCmdOnView = uassertStatusOK(
- query_request_helper::asAggregationCommand(cq->getFindCommand()));
+ query_request_helper::asAggregationCommand(cq->getFindCommandRequest()));
auto viewAggregationCommand =
OpMsgRequest::fromDBAndBody(_dbName, aggCmdOnView).body;
diff --git a/src/mongo/s/commands/cluster_getmore_cmd.cpp b/src/mongo/s/commands/cluster_getmore_cmd.cpp
index 25bec22c1e4..feba6c3d855 100644
--- a/src/mongo/s/commands/cluster_getmore_cmd.cpp
+++ b/src/mongo/s/commands/cluster_getmore_cmd.cpp
@@ -74,7 +74,8 @@ public:
class Invocation final : public CommandInvocation {
public:
Invocation(Command* cmd, const OpMsgRequest& request)
- : CommandInvocation(cmd), _cmd(GetMoreCommand::parse({"getMore"}, request.body)) {
+ : CommandInvocation(cmd),
+ _cmd(GetMoreCommandRequest::parse({"getMore"}, request.body)) {
APIParameters::uassertNoApiParameters(request.body);
}
@@ -114,7 +115,7 @@ public:
CursorGetMoreReply::parse({"CursorGetMoreReply"}, replyObj.removeField("ok"));
}
- const GetMoreCommand _cmd;
+ const GetMoreCommandRequest _cmd;
};
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
diff --git a/src/mongo/s/commands/cluster_map_reduce_agg.cpp b/src/mongo/s/commands/cluster_map_reduce_agg.cpp
index c06045be2be..9d16d22513f 100644
--- a/src/mongo/s/commands/cluster_map_reduce_agg.cpp
+++ b/src/mongo/s/commands/cluster_map_reduce_agg.cpp
@@ -57,7 +57,7 @@ namespace mongo {
namespace {
auto makeExpressionContext(OperationContext* opCtx,
- const MapReduce& parsedMr,
+ const MapReduceCommandRequest& parsedMr,
const ChunkManager& cm,
boost::optional<ExplainOptions::Verbosity> verbosity) {
// Populate the collection UUID and the appropriate collation to use.
@@ -109,26 +109,28 @@ auto makeExpressionContext(OperationContext* opCtx,
return expCtx;
}
-Document serializeToCommand(BSONObj originalCmd, const MapReduce& parsedMr, Pipeline* pipeline) {
+Document serializeToCommand(BSONObj originalCmd,
+ const MapReduceCommandRequest& parsedMr,
+ Pipeline* pipeline) {
MutableDocument translatedCmd;
translatedCmd["aggregate"] = Value(parsedMr.getNamespace().coll());
- translatedCmd[AggregateCommand::kPipelineFieldName] = Value(pipeline->serialize());
- translatedCmd[AggregateCommand::kCursorFieldName] =
+ translatedCmd[AggregateCommandRequest::kPipelineFieldName] = Value(pipeline->serialize());
+ translatedCmd[AggregateCommandRequest::kCursorFieldName] =
Value(Document{{"batchSize", std::numeric_limits<long long>::max()}});
- translatedCmd[AggregateCommand::kAllowDiskUseFieldName] = Value(true);
- translatedCmd[AggregateCommand::kFromMongosFieldName] = Value(true);
- translatedCmd[AggregateCommand::kLetFieldName] = Value(
+ translatedCmd[AggregateCommandRequest::kAllowDiskUseFieldName] = Value(true);
+ translatedCmd[AggregateCommandRequest::kFromMongosFieldName] = Value(true);
+ translatedCmd[AggregateCommandRequest::kLetFieldName] = Value(
pipeline->getContext()->variablesParseState.serialize(pipeline->getContext()->variables));
- translatedCmd[AggregateCommand::kIsMapReduceCommandFieldName] = Value(true);
+ translatedCmd[AggregateCommandRequest::kIsMapReduceCommandFieldName] = Value(true);
if (shouldBypassDocumentValidationForCommand(originalCmd)) {
translatedCmd[bypassDocumentValidationCommandOption()] = Value(true);
}
- if (originalCmd[AggregateCommand::kCollationFieldName]) {
- translatedCmd[AggregateCommand::kCollationFieldName] =
- Value(originalCmd[AggregateCommand::kCollationFieldName]);
+ if (originalCmd[AggregateCommandRequest::kCollationFieldName]) {
+ translatedCmd[AggregateCommandRequest::kCollationFieldName] =
+ Value(originalCmd[AggregateCommandRequest::kCollationFieldName]);
}
// Append generic command options.
@@ -144,7 +146,7 @@ bool runAggregationMapReduce(OperationContext* opCtx,
const BSONObj& cmd,
BSONObjBuilder& result,
boost::optional<ExplainOptions::Verbosity> verbosity) {
- auto parsedMr = MapReduce::parse(IDLParserErrorContext("MapReduce"), cmd);
+ auto parsedMr = MapReduceCommandRequest::parse(IDLParserErrorContext("mapReduce"), cmd);
stdx::unordered_set<NamespaceString> involvedNamespaces{parsedMr.getNamespace()};
auto hasOutDB = parsedMr.getOutOptions().getDatabaseName();
auto resolvedOutNss = NamespaceString{hasOutDB ? *hasOutDB : parsedMr.getNamespace().db(),
diff --git a/src/mongo/s/commands/cluster_pipeline_cmd.cpp b/src/mongo/s/commands/cluster_pipeline_cmd.cpp
index f48df3af94d..ba0fba16362 100644
--- a/src/mongo/s/commands/cluster_pipeline_cmd.cpp
+++ b/src/mongo/s/commands/cluster_pipeline_cmd.cpp
@@ -94,7 +94,7 @@ public:
public:
Invocation(Command* cmd,
const OpMsgRequest& request,
- const AggregateCommand aggregationRequest,
+ const AggregateCommandRequest aggregationRequest,
PrivilegeVector privileges)
: CommandInvocation(cmd),
_request(request),
@@ -169,7 +169,7 @@ public:
const OpMsgRequest& _request;
const std::string _dbName;
- const AggregateCommand _aggregationRequest;
+ const AggregateCommandRequest _aggregationRequest;
const LiteParsedPipeline _liteParsedPipeline;
const PrivilegeVector _privileges;
};
@@ -188,7 +188,7 @@ public:
}
const AuthorizationContract* getAuthorizationContract() const final {
- return &::mongo::AggregateCommand::kAuthorizationContract;
+ return &::mongo::AggregateCommandRequest::kAuthorizationContract;
}
} clusterPipelineCmd;
diff --git a/src/mongo/s/commands/cluster_validate_db_metadata_cmd.cpp b/src/mongo/s/commands/cluster_validate_db_metadata_cmd.cpp
index afa641b9be3..f625f69bbc8 100644
--- a/src/mongo/s/commands/cluster_validate_db_metadata_cmd.cpp
+++ b/src/mongo/s/commands/cluster_validate_db_metadata_cmd.cpp
@@ -47,8 +47,8 @@ class ValidateDBMetadataCmd : public TypedCommand<ValidateDBMetadataCmd> {
typename TypedCommand<ValidateDBMetadataCmd>::InvocationBase;
public:
- using Request = ValidateDBMetadata;
- using Reply = ValidateDBMetadataReply;
+ using Request = ValidateDBMetadataCommandRequest;
+ using Reply = ValidateDBMetadataCommandReply;
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kAlways;
@@ -94,7 +94,7 @@ public:
uassertStatusOK(getStatusFromCommandResult(shardOutput));
auto apiVersionErrors =
- shardOutput[ValidateDBMetadataReply::kApiVersionErrorsFieldName];
+ shardOutput[ValidateDBMetadataCommandReply::kApiVersionErrorsFieldName];
tassert(5287400,
"The 'apiVersionErrors' field returned from shards should be an array ",
apiVersionErrors && apiVersionErrors.type() == Array);
@@ -115,14 +115,14 @@ public:
apiVersionErrorsToReturn.push_back(std::move(apiVersionError));
}
if (hasMoreErrors ||
- shardOutput.getField(ValidateDBMetadataReply::kHasMoreErrorsFieldName)
+ shardOutput.getField(ValidateDBMetadataCommandReply::kHasMoreErrorsFieldName)
.trueValue()) {
hasMoreErrors = true;
break;
}
}
- ValidateDBMetadataReply reply;
+ ValidateDBMetadataCommandReply reply;
reply.setApiVersionErrors(std::move(apiVersionErrorsToReturn));
if (hasMoreErrors) {
reply.setHasMoreErrors(true);
diff --git a/src/mongo/s/commands/cluster_write_cmd.cpp b/src/mongo/s/commands/cluster_write_cmd.cpp
index 35392f22b95..04d9961217d 100644
--- a/src/mongo/s/commands/cluster_write_cmd.cpp
+++ b/src/mongo/s/commands/cluster_write_cmd.cpp
@@ -483,7 +483,7 @@ private:
if (!response.getOk()) {
numAttempts = 0;
- } else if (batchedRequest.getWriteCommandBase().getOrdered() &&
+ } else if (batchedRequest.getWriteCommandRequestBase().getOrdered() &&
response.isErrDetailsSet()) {
// Add one failed attempt
numAttempts = response.getErrDetailsAt(0)->getIndex() + 1;
@@ -675,7 +675,7 @@ private:
}
const AuthorizationContract* getAuthorizationContract() const final {
- return &::mongo::write_ops::Insert::kAuthorizationContract;
+ return &::mongo::write_ops::InsertCommandRequest::kAuthorizationContract;
}
} clusterInsertCmd;
@@ -719,7 +719,7 @@ private:
}
const AuthorizationContract* getAuthorizationContract() const final {
- return &::mongo::write_ops::Update::kAuthorizationContract;
+ return &::mongo::write_ops::UpdateCommandRequest::kAuthorizationContract;
}
// Update related command execution metrics.
@@ -761,7 +761,7 @@ private:
}
const AuthorizationContract* getAuthorizationContract() const final {
- return &::mongo::write_ops::Delete::kAuthorizationContract;
+ return &::mongo::write_ops::DeleteCommandRequest::kAuthorizationContract;
}
} clusterDeleteCmd;
diff --git a/src/mongo/s/commands/document_shard_key_update_util.cpp b/src/mongo/s/commands/document_shard_key_update_util.cpp
index 164007fe36f..d4dda8ae836 100644
--- a/src/mongo/s/commands/document_shard_key_update_util.cpp
+++ b/src/mongo/s/commands/document_shard_key_update_util.cpp
@@ -101,9 +101,9 @@ bool executeOperationsAsPartOfShardKeyUpdate(OperationContext* opCtx,
* Creates the delete op that will be used to delete the pre-image document. Will also attach the
* original document _id retrieved from 'updatePreImage'.
*/
-write_ops::Delete createShardKeyDeleteOp(const NamespaceString& nss,
- const BSONObj& updatePreImage) {
- write_ops::Delete deleteOp(nss);
+write_ops::DeleteCommandRequest createShardKeyDeleteOp(const NamespaceString& nss,
+ const BSONObj& updatePreImage) {
+ write_ops::DeleteCommandRequest deleteOp(nss);
deleteOp.setDeletes({[&] {
write_ops::DeleteOpEntry entry;
entry.setQ(updatePreImage);
@@ -117,9 +117,9 @@ write_ops::Delete createShardKeyDeleteOp(const NamespaceString& nss,
/**
* Creates the insert op that will be used to insert the new document with the post-update image.
*/
-write_ops::Insert createShardKeyInsertOp(const NamespaceString& nss,
- const BSONObj& updatePostImage) {
- write_ops::Insert insertOp(nss);
+write_ops::InsertCommandRequest createShardKeyInsertOp(const NamespaceString& nss,
+ const BSONObj& updatePostImage) {
+ write_ops::InsertCommandRequest insertOp(nss);
insertOp.setDocuments({updatePostImage});
return insertOp;
}
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp
index ad7245ddb7e..b7b382c6cab 100644
--- a/src/mongo/s/commands/strategy.cpp
+++ b/src/mongo/s/commands/strategy.cpp
@@ -1111,7 +1111,7 @@ DbResponse Strategy::queryOp(OperationContext* opCtx, const NamespaceString& nss
ExtensionsCallbackNoop(),
MatchExpressionParser::kAllowAllSpecialFeatures));
- const FindCommand& findCommand = canonicalQuery->getFindCommand();
+ const FindCommandRequest& findCommand = canonicalQuery->getFindCommandRequest();
// Handle query option $maxTimeMS (not used with commands).
if (findCommand.getMaxTimeMS().value_or(0) > 0) {
uassert(50749,
@@ -1331,7 +1331,7 @@ DbResponse Strategy::getMore(OperationContext* opCtx, const NamespaceString& nss
}
uassertStatusOK(statusGetDb);
- GetMoreCommand getMoreCmd(cursorId, nss.coll().toString());
+ GetMoreCommandRequest getMoreCmd(cursorId, nss.coll().toString());
getMoreCmd.setDbName(nss.db());
if (ntoreturn) {
getMoreCmd.setBatchSize(ntoreturn);
@@ -1459,7 +1459,7 @@ void Strategy::writeOp(std::shared_ptr<RequestExecutionContext> rec) {
void Strategy::explainFind(OperationContext* opCtx,
const BSONObj& findCommandObj,
- const FindCommand& findCommand,
+ const FindCommandRequest& findCommand,
ExplainOptions::Verbosity verbosity,
const ReadPreferenceSetting& readPref,
BSONObjBuilder* out) {
diff --git a/src/mongo/s/commands/strategy.h b/src/mongo/s/commands/strategy.h
index 4ea30690bf2..284b562da52 100644
--- a/src/mongo/s/commands/strategy.h
+++ b/src/mongo/s/commands/strategy.h
@@ -43,7 +43,7 @@ struct DbResponse;
class Message;
class NamespaceString;
class OperationContext;
-class FindCommand;
+class FindCommandRequest;
/**
* Legacy interface for processing client read/write/cmd requests.
@@ -94,7 +94,7 @@ public:
*/
static void explainFind(OperationContext* opCtx,
const BSONObj& findCommandObj,
- const FindCommand& findCommand,
+ const FindCommandRequest& findCommand,
ExplainOptions::Verbosity verbosity,
const ReadPreferenceSetting& readPref,
BSONObjBuilder* out);
diff --git a/src/mongo/s/query/async_results_merger.cpp b/src/mongo/s/query/async_results_merger.cpp
index f97dd6c6da9..71fd81ef848 100644
--- a/src/mongo/s/query/async_results_merger.cpp
+++ b/src/mongo/s/query/async_results_merger.cpp
@@ -821,7 +821,7 @@ void AsyncResultsMerger::_scheduleKillCursors(WithLock, OperationContext* opCtx)
for (const auto& remote : _remotes) {
if (remote.status.isOK() && remote.cursorId && !remote.exhausted()) {
BSONObj cmdObj =
- KillCursorsRequest(_params.getNss(), {remote.cursorId}).toBSON(BSONObj{});
+ KillCursorsCommandRequest(_params.getNss(), {remote.cursorId}).toBSON(BSONObj{});
executor::RemoteCommandRequest request(
remote.getTargetHost(), _params.getNss().db().toString(), cmdObj, opCtx);
diff --git a/src/mongo/s/query/async_results_merger_test.cpp b/src/mongo/s/query/async_results_merger_test.cpp
index 2077be2f4b1..cbe002ee0ef 100644
--- a/src/mongo/s/query/async_results_merger_test.cpp
+++ b/src/mongo/s/query/async_results_merger_test.cpp
@@ -1093,10 +1093,10 @@ TEST_F(AsyncResultsMergerTest, GetMoreBatchSizes) {
readyEvent = unittest::assertGet(arm->nextEvent());
BSONObj scheduledCmd = getNthPendingRequest(0).cmdObj;
- auto cmd = GetMoreCommand::parse({"getMore"},
- scheduledCmd.addField(BSON("$db"
- << "anydbname")
- .firstElement()));
+ auto cmd = GetMoreCommandRequest::parse({"getMore"},
+ scheduledCmd.addField(BSON("$db"
+ << "anydbname")
+ .firstElement()));
ASSERT_EQ(*cmd.getBatchSize(), 1LL);
ASSERT_EQ(cmd.getCommandParameter(), 1LL);
scheduleNetworkResponses(std::move(responses));
diff --git a/src/mongo/s/query/cluster_aggregate.cpp b/src/mongo/s/query/cluster_aggregate.cpp
index 4c78d8b8bd6..2521315c8e3 100644
--- a/src/mongo/s/query/cluster_aggregate.cpp
+++ b/src/mongo/s/query/cluster_aggregate.cpp
@@ -102,7 +102,7 @@ auto resolveInvolvedNamespaces(stdx::unordered_set<NamespaceString> involvedName
// collection UUID if provided.
boost::intrusive_ptr<ExpressionContext> makeExpressionContext(
OperationContext* opCtx,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
BSONObj collationObj,
boost::optional<UUID> uuid,
StringMap<ExpressionContext::ResolvedNamespace> resolvedNamespaces) {
@@ -192,11 +192,11 @@ void updateHostsTargetedMetrics(OperationContext* opCtx,
* Performs validations related to API versioning and time-series stages.
* Throws UserAssertion if any of the validations fails
* - validation of API versioning on each stage on the pipeline
- * - validation of API versioning on 'AggregateCommand' request
+ * - validation of API versioning on 'AggregateCommandRequest' request
* - validation of time-series related stages
*/
void performValidationChecks(const OperationContext* opCtx,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
const LiteParsedPipeline& liteParsedPipeline) {
liteParsedPipeline.validate(opCtx);
aggregation_request_helper::validateRequestForAPIVersion(opCtx, request);
@@ -206,7 +206,7 @@ void performValidationChecks(const OperationContext* opCtx,
Status ClusterAggregate::runAggregate(OperationContext* opCtx,
const Namespaces& namespaces,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
const PrivilegeVector& privileges,
BSONObjBuilder* result) {
return runAggregate(opCtx, namespaces, request, {request}, privileges, result);
@@ -214,7 +214,7 @@ Status ClusterAggregate::runAggregate(OperationContext* opCtx,
Status ClusterAggregate::runAggregate(OperationContext* opCtx,
const Namespaces& namespaces,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
const LiteParsedPipeline& liteParsedPipeline,
const PrivilegeVector& privileges,
BSONObjBuilder* result) {
@@ -227,12 +227,13 @@ Status ClusterAggregate::runAggregate(OperationContext* opCtx,
"Cannot specify runtime constants option to a mongos",
!request.getLegacyRuntimeConstants());
uassert(51089,
- str::stream() << "Internal parameter(s) [" << AggregateCommand::kNeedsMergeFieldName
- << ", " << AggregateCommand::kFromMongosFieldName
+ str::stream() << "Internal parameter(s) ["
+ << AggregateCommandRequest::kNeedsMergeFieldName << ", "
+ << AggregateCommandRequest::kFromMongosFieldName
<< "] cannot be set to 'true' when sent to mongos",
!request.getNeedsMerge() && !request.getFromMongos());
uassert(4928902,
- str::stream() << AggregateCommand::kCollectionUUIDFieldName
+ str::stream() << AggregateCommandRequest::kCollectionUUIDFieldName
<< " is not supported on a mongos",
!request.getCollectionUUID());
@@ -394,7 +395,7 @@ Status ClusterAggregate::runAggregate(OperationContext* opCtx,
}
Status ClusterAggregate::retryOnViewError(OperationContext* opCtx,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
const ResolvedView& resolvedView,
const NamespaceString& requestedNss,
const PrivilegeVector& privileges,
diff --git a/src/mongo/s/query/cluster_aggregate.h b/src/mongo/s/query/cluster_aggregate.h
index 5a071c80d32..a872aa0ea1c 100644
--- a/src/mongo/s/query/cluster_aggregate.h
+++ b/src/mongo/s/query/cluster_aggregate.h
@@ -78,7 +78,7 @@ public:
*/
static Status runAggregate(OperationContext* opCtx,
const Namespaces& namespaces,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
const LiteParsedPipeline& liteParsedPipeline,
const PrivilegeVector& privileges,
BSONObjBuilder* result);
@@ -88,7 +88,7 @@ public:
*/
static Status runAggregate(OperationContext* opCtx,
const Namespaces& namespaces,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
const PrivilegeVector& privileges,
BSONObjBuilder* result);
@@ -102,7 +102,7 @@ public:
* On success, populates 'result' with the command response.
*/
static Status retryOnViewError(OperationContext* opCtx,
- const AggregateCommand& request,
+ const AggregateCommandRequest& request,
const ResolvedView& resolvedView,
const NamespaceString& requestedNss,
const PrivilegeVector& privileges,
diff --git a/src/mongo/s/query/cluster_aggregation_planner.cpp b/src/mongo/s/query/cluster_aggregation_planner.cpp
index 272d13aa6c2..90e2b822178 100644
--- a/src/mongo/s/query/cluster_aggregation_planner.cpp
+++ b/src/mongo/s/query/cluster_aggregation_planner.cpp
@@ -124,9 +124,9 @@ BSONObj createCommandForMergingShard(Document serializedCommand,
MutableDocument mergeCmd(serializedCommand);
mergeCmd["pipeline"] = Value(pipelineForMerging->serialize());
- mergeCmd[AggregateCommand::kFromMongosFieldName] = Value(true);
+ mergeCmd[AggregateCommandRequest::kFromMongosFieldName] = Value(true);
- mergeCmd[AggregateCommand::kLetFieldName] =
+ mergeCmd[AggregateCommandRequest::kLetFieldName] =
Value(mergeCtx->variablesParseState.serialize(mergeCtx->variables));
// If the user didn't specify a collation already, make sure there's a collation attached to
diff --git a/src/mongo/s/query/cluster_find.cpp b/src/mongo/s/query/cluster_find.cpp
index 8997ee6746b..f8e9c420f37 100644
--- a/src/mongo/s/query/cluster_find.cpp
+++ b/src/mongo/s/query/cluster_find.cpp
@@ -84,11 +84,11 @@ static const int kPerDocumentOverheadBytesUpperBound = 10;
const char kFindCmdName[] = "find";
/**
- * Given the FindCommand 'findCommand' being executed by mongos, returns a copy of the query which
- * is suitable for forwarding to the targeted hosts.
+ * Given the FindCommandRequest 'findCommand' being executed by mongos, returns a copy of the query
+ * which is suitable for forwarding to the targeted hosts.
*/
-StatusWith<std::unique_ptr<FindCommand>> transformQueryForShards(
- const FindCommand& findCommand, bool appendGeoNearDistanceProjection) {
+StatusWith<std::unique_ptr<FindCommandRequest>> transformQueryForShards(
+ const FindCommandRequest& findCommand, bool appendGeoNearDistanceProjection) {
// If there is a limit, we forward the sum of the limit and the skip.
boost::optional<int64_t> newLimit;
if (findCommand.getLimit()) {
@@ -156,7 +156,7 @@ StatusWith<std::unique_ptr<FindCommand>> transformQueryForShards(
newProjection = projectionBuilder.obj();
}
- auto newQR = std::make_unique<FindCommand>(findCommand);
+ auto newQR = std::make_unique<FindCommandRequest>(findCommand);
newQR->setProjection(newProjection);
newQR->setSkip(boost::none);
newQR->setLimit(newLimit);
@@ -171,7 +171,7 @@ StatusWith<std::unique_ptr<FindCommand>> transformQueryForShards(
if (newQR->getShowRecordId())
newQR->setShowRecordId(false);
- uassertStatusOK(query_request_helper::validateFindCommand(*newQR));
+ uassertStatusOK(query_request_helper::validateFindCommandRequest(*newQR));
return std::move(newQR);
}
@@ -186,14 +186,14 @@ std::vector<std::pair<ShardId, BSONObj>> constructRequestsForShards(
const CanonicalQuery& query,
bool appendGeoNearDistanceProjection) {
- std::unique_ptr<FindCommand> findCommandToForward;
+ std::unique_ptr<FindCommandRequest> findCommandToForward;
if (shardIds.size() > 1) {
- findCommandToForward = uassertStatusOK(
- transformQueryForShards(query.getFindCommand(), appendGeoNearDistanceProjection));
+ findCommandToForward = uassertStatusOK(transformQueryForShards(
+ query.getFindCommandRequest(), appendGeoNearDistanceProjection));
} else {
- // Forwards the FindCommand as is to a single shard so that limit and skip can
+ // Forwards the FindCommandRequest as is to a single shard so that limit and skip can
// be applied on mongod.
- findCommandToForward = std::make_unique<FindCommand>(query.getFindCommand());
+ findCommandToForward = std::make_unique<FindCommandRequest>(query.getFindCommandRequest());
}
auto& readConcernArgs = repl::ReadConcernArgs::get(opCtx);
@@ -248,7 +248,7 @@ CursorId runQueryWithoutRetrying(OperationContext* opCtx,
const ChunkManager& cm,
std::vector<BSONObj>* results,
bool* partialResultsReturned) {
- auto findCommand = query.getFindCommand();
+ auto findCommand = query.getFindCommandRequest();
// Get the set of shards on which we will run the query.
auto shardIds = getTargetedShardsForQuery(
query.getExpCtx(), cm, findCommand.getFilter(), findCommand.getCollation());
@@ -438,7 +438,7 @@ CursorId runQueryWithoutRetrying(OperationContext* opCtx,
* and/or what's specified on the request.
*/
Status setUpOperationContextStateForGetMore(OperationContext* opCtx,
- const GetMoreCommand& cmd,
+ const GetMoreCommandRequest& cmd,
const ClusterCursorManager::PinnedCursor& cursor) {
if (auto readPref = cursor->getReadPreference()) {
ReadPreferenceSetting::get(opCtx) = *readPref;
@@ -494,7 +494,7 @@ CursorId ClusterFind::runQuery(OperationContext* opCtx,
// We must always have a BSONObj vector into which to output our results.
invariant(results);
- auto findCommand = query.getFindCommand();
+ auto findCommand = query.getFindCommandRequest();
// Projection on the reserved sort key field is illegal in mongos.
if (findCommand.getProjection().hasField(AsyncResultsMerger::kSortKeyField)) {
uasserted(ErrorCodes::BadValue,
@@ -689,7 +689,7 @@ void validateOperationSessionInfo(OperationContext* opCtx,
}
StatusWith<CursorResponse> ClusterFind::runGetMore(OperationContext* opCtx,
- const GetMoreCommand& cmd) {
+ const GetMoreCommandRequest& cmd) {
auto cursorManager = Grid::get(opCtx)->getCursorManager();
auto authzSession = AuthorizationSession::get(opCtx->getClient());
diff --git a/src/mongo/s/query/cluster_find.h b/src/mongo/s/query/cluster_find.h
index fe5907c0153..4f03e55991f 100644
--- a/src/mongo/s/query/cluster_find.h
+++ b/src/mongo/s/query/cluster_find.h
@@ -71,7 +71,7 @@ public:
* Executes the getMore command 'cmd', and on success returns a CursorResponse.
*/
static StatusWith<CursorResponse> runGetMore(OperationContext* opCtx,
- const GetMoreCommand& cmd);
+ const GetMoreCommandRequest& cmd);
};
} // namespace mongo
diff --git a/src/mongo/s/query/establish_cursors.cpp b/src/mongo/s/query/establish_cursors.cpp
index a741d54812a..4c44a93b2c9 100644
--- a/src/mongo/s/query/establish_cursors.cpp
+++ b/src/mongo/s/query/establish_cursors.cpp
@@ -311,8 +311,8 @@ void killRemoteCursor(OperationContext* opCtx,
executor::TaskExecutor* executor,
RemoteCursor&& cursor,
const NamespaceString& nss) {
- BSONObj cmdObj =
- KillCursorsRequest(nss, {cursor.getCursorResponse().getCursorId()}).toBSON(BSONObj{});
+ BSONObj cmdObj = KillCursorsCommandRequest(nss, {cursor.getCursorResponse().getCursorId()})
+ .toBSON(BSONObj{});
executor::RemoteCommandRequest request(
cursor.getHostAndPort(), nss.db().toString(), cmdObj, opCtx);
diff --git a/src/mongo/s/shard_key_pattern.cpp b/src/mongo/s/shard_key_pattern.cpp
index 4c6b16270cf..ffe162440a1 100644
--- a/src/mongo/s/shard_key_pattern.cpp
+++ b/src/mongo/s/shard_key_pattern.cpp
@@ -400,7 +400,7 @@ BSONObj ShardKeyPattern::emplaceMissingShardKeyValuesForDocument(const BSONObj d
StatusWith<BSONObj> ShardKeyPattern::extractShardKeyFromQuery(OperationContext* opCtx,
const NamespaceString& nss,
const BSONObj& basicQuery) const {
- auto findCommand = std::make_unique<FindCommand>(nss);
+ auto findCommand = std::make_unique<FindCommandRequest>(nss);
findCommand->setFilter(basicQuery.getOwned());
const boost::intrusive_ptr<ExpressionContext> expCtx;
@@ -420,7 +420,7 @@ StatusWith<BSONObj> ShardKeyPattern::extractShardKeyFromQuery(OperationContext*
StatusWith<BSONObj> ShardKeyPattern::extractShardKeyFromQuery(
boost::intrusive_ptr<ExpressionContext> expCtx, const BSONObj& basicQuery) const {
- auto findCommand = std::make_unique<FindCommand>(expCtx->ns);
+ auto findCommand = std::make_unique<FindCommandRequest>(expCtx->ns);
findCommand->setFilter(basicQuery.getOwned());
if (!expCtx->getCollatorBSON().isEmpty()) {
findCommand->setCollation(expCtx->getCollatorBSON().getOwned());
diff --git a/src/mongo/s/write_ops/batch_write_exec_test.cpp b/src/mongo/s/write_ops/batch_write_exec_test.cpp
index db148b18228..ca3bf151737 100644
--- a/src/mongo/s/write_ops/batch_write_exec_test.cpp
+++ b/src/mongo/s/write_ops/batch_write_exec_test.cpp
@@ -293,9 +293,9 @@ public:
TEST_F(BatchWriteExecTest, SingleOpUnordered) {
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -327,9 +327,9 @@ TEST_F(BatchWriteExecTest, SingleUpdateTargetsShardWithLet) {
const auto q = BSON("x"
<< "$$y");
BatchedCommandRequest updateRequest([&] {
- write_ops::Update updateOp(nss);
- updateOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::UpdateCommandRequest updateOp(nss);
+ updateOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -419,9 +419,9 @@ TEST_F(BatchWriteExecTest, SingleDeleteTargetsShardWithLet) {
const auto q = BSON("x"
<< "$$y");
BatchedCommandRequest deleteRequest([&] {
- write_ops::Delete deleteOp(nss);
- deleteOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::DeleteCommandRequest deleteOp(nss);
+ deleteOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -511,9 +511,9 @@ TEST_F(BatchWriteExecTest, MultiOpLargeOrdered) {
}
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(true);
return writeCommandBase;
}());
@@ -544,9 +544,9 @@ TEST_F(BatchWriteExecTest, SingleOpUnorderedError) {
errResponse.setStatus({ErrorCodes::UnknownError, "mock error"});
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -585,9 +585,9 @@ TEST_F(BatchWriteExecTest, MultiOpLargeUnorderedWithStaleShardVersionError) {
}
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -615,9 +615,9 @@ TEST_F(BatchWriteExecTest, MultiOpLargeUnorderedWithStaleShardVersionError) {
TEST_F(BatchWriteExecTest, StaleShardVersionReturnedFromBatchWithSingleMultiWrite) {
BatchedCommandRequest request([&] {
- write_ops::Update updateOp(nss);
- updateOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::UpdateCommandRequest updateOp(nss);
+ updateOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -723,9 +723,9 @@ TEST_F(BatchWriteExecTest, StaleShardVersionReturnedFromBatchWithSingleMultiWrit
TEST_F(BatchWriteExecTest,
RetryableErrorReturnedFromMultiWriteWithShard1AllOKShard2AllStaleShardVersion) {
BatchedCommandRequest request([&] {
- write_ops::Update updateOp(nss);
- updateOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::UpdateCommandRequest updateOp(nss);
+ updateOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -853,9 +853,9 @@ TEST_F(BatchWriteExecTest,
TEST_F(BatchWriteExecTest, RetryableErrorReturnedFromMultiWriteWithShard1Firs) {
BatchedCommandRequest request([&] {
- write_ops::Update updateOp(nss);
- updateOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::UpdateCommandRequest updateOp(nss);
+ updateOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -994,9 +994,9 @@ TEST_F(BatchWriteExecTest, RetryableErrorReturnedFromMultiWriteWithShard1Firs) {
TEST_F(BatchWriteExecTest, RetryableErrorReturnedFromMultiWriteWithShard1FirstOKShard2FirstOK) {
BatchedCommandRequest request([&] {
- write_ops::Update updateOp(nss);
- updateOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::UpdateCommandRequest updateOp(nss);
+ updateOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -1135,9 +1135,9 @@ TEST_F(BatchWriteExecTest, RetryableErrorReturnedFromMultiWriteWithShard1FirstOK
TEST_F(BatchWriteExecTest, RetryableErrorReturnedFromWriteWithShard1SSVShard2OK) {
BatchedCommandRequest request([&] {
- write_ops::Update updateOp(nss);
- updateOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::UpdateCommandRequest updateOp(nss);
+ updateOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -1252,9 +1252,9 @@ TEST_F(BatchWriteExecTest, RetryableErrorReturnedFromWriteWithShard1SSVShard2OK)
TEST_F(BatchWriteExecTest, StaleShardOp) {
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -1284,9 +1284,9 @@ TEST_F(BatchWriteExecTest, StaleShardOp) {
TEST_F(BatchWriteExecTest, MultiStaleShardOp) {
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -1322,9 +1322,9 @@ TEST_F(BatchWriteExecTest, TooManyStaleShardOp) {
// singleShardNSTargeter doesn't report progress on refresh). We should report a no progress
// error for everything in the batch.
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -1357,9 +1357,9 @@ TEST_F(BatchWriteExecTest, TooManyStaleShardOp) {
TEST_F(BatchWriteExecTest, StaleDbOp) {
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -1389,9 +1389,9 @@ TEST_F(BatchWriteExecTest, StaleDbOp) {
TEST_F(BatchWriteExecTest, MultiStaleDbOp) {
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -1427,9 +1427,9 @@ TEST_F(BatchWriteExecTest, TooManyStaleDbOp) {
// singleShardNSTargeter doesn't report progress on refresh). We should report a no progress
// error for everything in the batch.
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -1473,9 +1473,9 @@ TEST_F(BatchWriteExecTest, RetryableWritesLargeBatch) {
}
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(true);
return writeCommandBase;
}());
@@ -1508,9 +1508,9 @@ TEST_F(BatchWriteExecTest, RetryableErrorNoTxnNumber) {
// A retryable error without a txnNumber is not retried.
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(true);
return writeCommandBase;
}());
@@ -1547,9 +1547,9 @@ TEST_F(BatchWriteExecTest, RetryableErrorTxnNumber) {
// A retryable error with a txnNumber is automatically retried.
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(true);
return writeCommandBase;
}());
@@ -1585,9 +1585,9 @@ TEST_F(BatchWriteExecTest, NonRetryableErrorTxnNumber) {
// A non-retryable error with a txnNumber is not retried.
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(true);
return writeCommandBase;
}());
@@ -1627,9 +1627,9 @@ TEST_F(BatchWriteExecTest, StaleEpochIsNotRetryable) {
// A StaleEpoch error is not retried.
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(true);
return writeCommandBase;
}());
@@ -1717,9 +1717,9 @@ public:
TEST_F(BatchWriteExecTargeterErrorTest, TargetedFailedAndErrorResponse) {
BatchedCommandRequest request([&] {
- write_ops::Update updateOp(nss);
- updateOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::UpdateCommandRequest updateOp(nss);
+ updateOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -1863,9 +1863,9 @@ private:
TEST_F(BatchWriteExecTransactionTargeterErrorTest, TargetedFailedAndErrorResponseInTransaction) {
BatchedCommandRequest request([&] {
- write_ops::Update updateOp(nss);
- updateOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::UpdateCommandRequest updateOp(nss);
+ updateOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -2012,9 +2012,9 @@ private:
TEST_F(BatchWriteExecTransactionMultiShardTest, TargetedSucceededAndErrorResponseInTransaction) {
BatchedCommandRequest request([&] {
- write_ops::Update updateOp(nss);
- updateOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::UpdateCommandRequest updateOp(nss);
+ updateOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -2194,9 +2194,9 @@ private:
TEST_F(BatchWriteExecTransactionTest, ErrorInBatchThrows_CommandError) {
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -2226,9 +2226,9 @@ TEST_F(BatchWriteExecTransactionTest, ErrorInBatchThrows_CommandError) {
TEST_F(BatchWriteExecTransactionTest, ErrorInBatchSets_WriteError) {
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -2256,9 +2256,9 @@ TEST_F(BatchWriteExecTransactionTest, ErrorInBatchSets_WriteError) {
TEST_F(BatchWriteExecTransactionTest, ErrorInBatchSets_WriteErrorOrdered) {
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(true);
return writeCommandBase;
}());
@@ -2286,9 +2286,9 @@ TEST_F(BatchWriteExecTransactionTest, ErrorInBatchSets_WriteErrorOrdered) {
TEST_F(BatchWriteExecTransactionTest, ErrorInBatchSets_TransientTxnError) {
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -2314,9 +2314,9 @@ TEST_F(BatchWriteExecTransactionTest, ErrorInBatchSets_TransientTxnError) {
TEST_F(BatchWriteExecTransactionTest, ErrorInBatchSets_DispatchError) {
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
@@ -2346,9 +2346,9 @@ TEST_F(BatchWriteExecTransactionTest, ErrorInBatchSets_DispatchError) {
TEST_F(BatchWriteExecTransactionTest, ErrorInBatchSets_TransientDispatchError) {
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase writeCommandBase;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase writeCommandBase;
writeCommandBase.setOrdered(false);
return writeCommandBase;
}());
diff --git a/src/mongo/s/write_ops/batch_write_op.cpp b/src/mongo/s/write_ops/batch_write_op.cpp
index 3337d8f5d90..8b0030e8006 100644
--- a/src/mongo/s/write_ops/batch_write_op.cpp
+++ b/src/mongo/s/write_ops/batch_write_op.cpp
@@ -303,7 +303,7 @@ Status BatchWriteOp::targetBatch(const NSTargeter& targeter,
// [{ skey : y }, { skey : z }]
//
- const bool ordered = _clientRequest.getWriteCommandBase().getOrdered();
+ const bool ordered = _clientRequest.getWriteCommandRequestBase().getOrdered();
TargetedBatchMap batchMap;
std::set<ShardId> targetedShards;
@@ -503,7 +503,7 @@ BatchedCommandRequest BatchWriteOp::buildBatchRequest(
if (stmtIdsForOp) {
stmtIdsForOp->push_back(write_ops::getStmtIdForWriteAt(
- _clientRequest.getWriteCommandBase(), writeOpRef.first));
+ _clientRequest.getWriteCommandRequestBase(), writeOpRef.first));
}
}
@@ -511,13 +511,13 @@ BatchedCommandRequest BatchWriteOp::buildBatchRequest(
switch (batchType) {
case BatchedCommandRequest::BatchType_Insert:
return BatchedCommandRequest([&] {
- write_ops::Insert insertOp(_clientRequest.getNS());
+ write_ops::InsertCommandRequest insertOp(_clientRequest.getNS());
insertOp.setDocuments(std::move(*insertDocs));
return insertOp;
}());
case BatchedCommandRequest::BatchType_Update: {
return BatchedCommandRequest([&] {
- write_ops::Update updateOp(_clientRequest.getNS());
+ write_ops::UpdateCommandRequest updateOp(_clientRequest.getNS());
updateOp.setUpdates(std::move(*updates));
// Each child batch inherits its let params/runtime constants from the parent
// batch.
@@ -528,7 +528,7 @@ BatchedCommandRequest BatchWriteOp::buildBatchRequest(
}
case BatchedCommandRequest::BatchType_Delete:
return BatchedCommandRequest([&] {
- write_ops::Delete deleteOp(_clientRequest.getNS());
+ write_ops::DeleteCommandRequest deleteOp(_clientRequest.getNS());
deleteOp.setDeletes(std::move(*deletes));
// Each child batch inherits its let params from the parent batch.
deleteOp.setLet(_clientRequest.getLet());
@@ -539,12 +539,12 @@ BatchedCommandRequest BatchWriteOp::buildBatchRequest(
MONGO_UNREACHABLE;
}());
- request.setWriteCommandBase([&] {
- write_ops::WriteCommandBase wcb;
+ request.setWriteCommandRequestBase([&] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setBypassDocumentValidation(
- _clientRequest.getWriteCommandBase().getBypassDocumentValidation());
- wcb.setOrdered(_clientRequest.getWriteCommandBase().getOrdered());
+ _clientRequest.getWriteCommandRequestBase().getBypassDocumentValidation());
+ wcb.setOrdered(_clientRequest.getWriteCommandRequestBase().getOrdered());
if (_batchTxnNum) {
wcb.setStmtIds(std::move(stmtIdsForOp));
@@ -627,7 +627,7 @@ void BatchWriteOp::noteBatchResponse(const TargetedWriteBatch& targetedBatch,
// If the batch is ordered, cancel all writes after the first error for retargeting.
//
- const bool ordered = _clientRequest.getWriteCommandBase().getOrdered();
+ const bool ordered = _clientRequest.getWriteCommandRequestBase().getOrdered();
std::vector<WriteErrorDetail*>::iterator itemErrorIt = itemErrors.begin();
int index = 0;
@@ -698,8 +698,9 @@ void BatchWriteOp::noteBatchError(const TargetedWriteBatch& targetedBatch,
emulatedResponse.setStatus(Status::OK());
emulatedResponse.setN(0);
- const int numErrors =
- _clientRequest.getWriteCommandBase().getOrdered() ? 1 : targetedBatch.getWrites().size();
+ const int numErrors = _clientRequest.getWriteCommandRequestBase().getOrdered()
+ ? 1
+ : targetedBatch.getWrites().size();
for (int i = 0; i < numErrors; i++) {
auto errorClone(std::make_unique<WriteErrorDetail>());
@@ -717,7 +718,7 @@ void BatchWriteOp::abortBatch(const WriteErrorDetail& error) {
dassert(numWriteOpsIn(WriteOpState_Pending) == 0);
const size_t numWriteOps = _clientRequest.sizeWriteOps();
- const bool orderedOps = _clientRequest.getWriteCommandBase().getOrdered();
+ const bool orderedOps = _clientRequest.getWriteCommandRequestBase().getOrdered();
for (size_t i = 0; i < numWriteOps; ++i) {
WriteOp& writeOp = _writeOps[i];
// Can only be called with no outstanding batches
@@ -741,7 +742,7 @@ void BatchWriteOp::forgetTargetedBatchesOnTransactionAbortingError() {
bool BatchWriteOp::isFinished() {
const size_t numWriteOps = _clientRequest.sizeWriteOps();
- const bool orderedOps = _clientRequest.getWriteCommandBase().getOrdered();
+ const bool orderedOps = _clientRequest.getWriteCommandRequestBase().getOrdered();
for (size_t i = 0; i < numWriteOps; ++i) {
WriteOp& writeOp = _writeOps[i];
if (writeOp.getWriteState() < WriteOpState_Completed)
@@ -797,7 +798,7 @@ void BatchWriteOp::buildClientResponse(BatchedCommandResponse* batchResp) {
// Only return a write concern error if everything succeeded (unordered or ordered)
// OR if something succeeded and we're unordered
- const bool orderedOps = _clientRequest.getWriteCommandBase().getOrdered();
+ const bool orderedOps = _clientRequest.getWriteCommandRequestBase().getOrdered();
const bool reportWCError =
errOps.empty() || (!orderedOps && errOps.size() < _clientRequest.sizeWriteOps());
if (!_wcErrors.empty() && reportWCError) {
diff --git a/src/mongo/s/write_ops/batch_write_op_test.cpp b/src/mongo/s/write_ops/batch_write_op_test.cpp
index 3e52a01db1f..224aa009b69 100644
--- a/src/mongo/s/write_ops/batch_write_op_test.cpp
+++ b/src/mongo/s/write_ops/batch_write_op_test.cpp
@@ -127,7 +127,7 @@ TEST_F(BatchWriteOpTest, SingleOp) {
// Do single-target, single doc batch write op
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
+ write_ops::InsertCommandRequest insertOp(nss);
insertOp.setDocuments({BSON("x" << 1)});
return insertOp;
}());
@@ -160,7 +160,7 @@ TEST_F(BatchWriteOpTest, SingleError) {
// Do single-target, single doc batch write op
BatchedCommandRequest request([&] {
- write_ops::Delete deleteOp(nss);
+ write_ops::DeleteCommandRequest deleteOp(nss);
deleteOp.setDeletes({buildDelete(BSON("x" << 1), false)});
return deleteOp;
}());
@@ -199,7 +199,7 @@ TEST_F(BatchWriteOpTest, SingleTargetError) {
// Do untargetable delete op
BatchedCommandRequest request([&] {
- write_ops::Delete deleteOp(nss);
+ write_ops::DeleteCommandRequest deleteOp(nss);
deleteOp.setDeletes({buildDelete(BSON("x" << 1), false)});
return deleteOp;
}());
@@ -233,7 +233,7 @@ TEST_F(BatchWriteOpTest, SingleWriteConcernErrorOrdered) {
auto targeter = initTargeterFullRange(nss, endpoint);
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
+ write_ops::InsertCommandRequest insertOp(nss);
insertOp.setDocuments({BSON("x" << 1)});
return insertOp;
}());
@@ -275,7 +275,7 @@ TEST_F(BatchWriteOpTest, SingleStaleError) {
auto targeter = initTargeterFullRange(nss, endpoint);
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
+ write_ops::InsertCommandRequest insertOp(nss);
insertOp.setDocuments({BSON("x" << 1)});
return insertOp;
}());
@@ -330,7 +330,7 @@ TEST_F(BatchWriteOpTest, MultiOpSameShardOrdered) {
// Do single-target, multi-doc batch write op
BatchedCommandRequest request([&] {
- write_ops::Update updateOp(nss);
+ write_ops::UpdateCommandRequest updateOp(nss);
updateOp.setUpdates(
{buildUpdate(BSON("x" << 1), false), buildUpdate(BSON("x" << 2), false)});
return updateOp;
@@ -367,9 +367,9 @@ TEST_F(BatchWriteOpTest, MultiOpSameShardUnordered) {
// Do single-target, multi-doc batch write op
BatchedCommandRequest request([&] {
- write_ops::Update updateOp(nss);
- updateOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase wcb;
+ write_ops::UpdateCommandRequest updateOp(nss);
+ updateOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(false);
return wcb;
}());
@@ -411,7 +411,7 @@ TEST_F(BatchWriteOpTest, MultiOpTwoShardsOrdered) {
// Do multi-target, multi-doc batch write op
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
+ write_ops::InsertCommandRequest insertOp(nss);
insertOp.setDocuments({BSON("x" << -1), BSON("x" << 1)});
return insertOp;
}());
@@ -478,9 +478,9 @@ TEST_F(BatchWriteOpTest, MultiOpTwoShardsUnordered) {
// Do multi-target, multi-doc batch write op
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase wcb;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(false);
return wcb;
}());
@@ -524,7 +524,7 @@ TEST_F(BatchWriteOpTest, MultiOpTwoShardsEachOrdered) {
// Do multi-target, multi-doc batch write op
BatchedCommandRequest request([&] {
- write_ops::Delete deleteOp(nss);
+ write_ops::DeleteCommandRequest deleteOp(nss);
deleteOp.setDeletes({buildDelete(BSON("x" << GTE << -1 << LT << 2), true),
buildDelete(BSON("x" << GTE << -2 << LT << 1), true)});
return deleteOp;
@@ -580,9 +580,9 @@ TEST_F(BatchWriteOpTest, MultiOpTwoShardsEachUnordered) {
// Do multi-target, multi-doc batch write op
BatchedCommandRequest request([&] {
- write_ops::Update updateOp(nss);
- updateOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase wcb;
+ write_ops::UpdateCommandRequest updateOp(nss);
+ updateOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(false);
return wcb;
}());
@@ -627,7 +627,7 @@ TEST_F(BatchWriteOpTest, MultiOpOneOrTwoShardsOrdered) {
auto targeter = initTargeterSplitRange(nss, endpointA, endpointB);
BatchedCommandRequest request([&] {
- write_ops::Delete deleteOp(nss);
+ write_ops::DeleteCommandRequest deleteOp(nss);
deleteOp.setDeletes({
// These go to the same shard
buildDelete(BSON("x" << -1), false),
@@ -722,9 +722,9 @@ TEST_F(BatchWriteOpTest, MultiOpOneOrTwoShardsUnordered) {
auto targeter = initTargeterSplitRange(nss, endpointA, endpointB);
BatchedCommandRequest request([&] {
- write_ops::Update updateOp(nss);
- updateOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase wcb;
+ write_ops::UpdateCommandRequest updateOp(nss);
+ updateOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(false);
return wcb;
}());
@@ -776,9 +776,9 @@ TEST_F(BatchWriteOpTest, MultiOpSingleShardErrorUnordered) {
auto targeter = initTargeterSplitRange(nss, endpointA, endpointB);
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase wcb;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(false);
return wcb;
}());
@@ -837,9 +837,9 @@ TEST_F(BatchWriteOpTest, MultiOpTwoShardErrorsUnordered) {
auto targeter = initTargeterSplitRange(nss, endpointA, endpointB);
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase wcb;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(false);
return wcb;
}());
@@ -895,9 +895,9 @@ TEST_F(BatchWriteOpTest, MultiOpPartialSingleShardErrorUnordered) {
auto targeter = initTargeterSplitRange(nss, endpointA, endpointB);
BatchedCommandRequest request([&] {
- write_ops::Delete deleteOp(nss);
- deleteOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase wcb;
+ write_ops::DeleteCommandRequest deleteOp(nss);
+ deleteOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(false);
return wcb;
}());
@@ -958,7 +958,7 @@ TEST_F(BatchWriteOpTest, MultiOpPartialSingleShardErrorOrdered) {
auto targeter = initTargeterSplitRange(nss, endpointA, endpointB);
BatchedCommandRequest request([&] {
- write_ops::Delete deleteOp(nss);
+ write_ops::DeleteCommandRequest deleteOp(nss);
deleteOp.setDeletes({buildDelete(BSON("x" << GTE << -1 << LT << 2), true),
buildDelete(BSON("x" << GTE << -2 << LT << 1), true)});
return deleteOp;
@@ -1019,9 +1019,9 @@ TEST_F(BatchWriteOpTest, MultiOpErrorAndWriteConcernErrorUnordered) {
auto targeter = initTargeterFullRange(nss, endpoint);
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase wcb;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(false);
return wcb;
}());
@@ -1064,9 +1064,9 @@ TEST_F(BatchWriteOpTest, SingleOpErrorAndWriteConcernErrorOrdered) {
auto targeter = initTargeterSplitRange(nss, endpointA, endpointB);
BatchedCommandRequest request([&] {
- write_ops::Update updateOp(nss);
- updateOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase wcb;
+ write_ops::UpdateCommandRequest updateOp(nss);
+ updateOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(false);
return wcb;
}());
@@ -1119,7 +1119,7 @@ TEST_F(BatchWriteOpTest, MultiOpFailedTargetOrdered) {
auto targeter = initTargeterHalfRange(nss, endpoint);
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
+ write_ops::InsertCommandRequest insertOp(nss);
insertOp.setDocuments({BSON("x" << -1), BSON("x" << 2), BSON("x" << -2)});
return insertOp;
}());
@@ -1174,9 +1174,9 @@ TEST_F(BatchWriteOpTest, MultiOpFailedTargetUnordered) {
auto targeter = initTargeterHalfRange(nss, endpoint);
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase wcb;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(false);
return wcb;
}());
@@ -1229,7 +1229,7 @@ TEST_F(BatchWriteOpTest, MultiOpFailedBatchOrdered) {
auto targeter = initTargeterSplitRange(nss, endpointA, endpointB);
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
+ write_ops::InsertCommandRequest insertOp(nss);
insertOp.setDocuments({BSON("x" << -1), BSON("x" << 2), BSON("x" << 3)});
return insertOp;
}());
@@ -1277,9 +1277,9 @@ TEST_F(BatchWriteOpTest, MultiOpFailedBatchUnordered) {
auto targeter = initTargeterSplitRange(nss, endpointA, endpointB);
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase wcb;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(false);
return wcb;
}());
@@ -1334,7 +1334,7 @@ TEST_F(BatchWriteOpTest, MultiOpAbortOrdered) {
auto targeter = initTargeterSplitRange(nss, endpointA, endpointB);
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
+ write_ops::InsertCommandRequest insertOp(nss);
insertOp.setDocuments({BSON("x" << -1), BSON("x" << 2), BSON("x" << 3)});
return insertOp;
}());
@@ -1379,9 +1379,9 @@ TEST_F(BatchWriteOpTest, MultiOpAbortUnordered) {
auto targeter = initTargeterSplitRange(nss, endpointA, endpointB);
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase wcb;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(false);
return wcb;
}());
@@ -1420,7 +1420,7 @@ TEST_F(BatchWriteOpTest, MultiOpTwoWCErrors) {
auto targeter = initTargeterSplitRange(nss, endpointA, endpointB);
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
+ write_ops::InsertCommandRequest insertOp(nss);
insertOp.setDocuments({BSON("x" << -1), BSON("x" << 2)});
return insertOp;
}());
@@ -1473,9 +1473,9 @@ TEST_F(BatchWriteOpLimitTests, OneBigDoc) {
// Do single-target, single doc batch write op
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(nss);
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase wcb;
+ write_ops::InsertCommandRequest insertOp(nss);
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(false);
return wcb;
}());
@@ -1508,7 +1508,7 @@ TEST_F(BatchWriteOpLimitTests, OneBigOneSmall) {
const std::string bigString(BSONObjMaxUserSize, 'x');
BatchedCommandRequest request([&] {
- write_ops::Update updateOp(nss);
+ write_ops::UpdateCommandRequest updateOp(nss);
updateOp.setUpdates({buildUpdate(BSON("x" << 1), BSON("data" << bigString), false),
buildUpdate(BSON("x" << 2), BSONObj(), false)});
return updateOp;
@@ -1575,7 +1575,7 @@ TEST_F(BatchWriteOpTransactionTest, ThrowTargetingErrorsInTransaction_Delete) {
// Untargetable delete op.
BatchedCommandRequest deleteRequest([&] {
- write_ops::Delete deleteOp(nss);
+ write_ops::DeleteCommandRequest deleteOp(nss);
deleteOp.setDeletes({buildDelete(BSON("x" << 1), false)});
return deleteOp;
}());
@@ -1605,7 +1605,7 @@ TEST_F(BatchWriteOpTransactionTest, ThrowTargetingErrorsInTransaction_Update) {
// Untargetable update op.
BatchedCommandRequest updateRequest([&] {
- write_ops::Update updateOp(nss);
+ write_ops::UpdateCommandRequest updateOp(nss);
updateOp.setUpdates({buildUpdate(BSON("x" << 1), BSONObj(), false)});
return updateOp;
}());
diff --git a/src/mongo/s/write_ops/batched_command_request.cpp b/src/mongo/s/write_ops/batched_command_request.cpp
index 93237f90bb2..be1394dec8c 100644
--- a/src/mongo/s/write_ops/batched_command_request.cpp
+++ b/src/mongo/s/write_ops/batched_command_request.cpp
@@ -88,13 +88,13 @@ const NamespaceString& BatchedCommandRequest::getNS() const {
std::size_t BatchedCommandRequest::sizeWriteOps() const {
struct Visitor {
- auto operator()(const write_ops::Insert& op) const {
+ auto operator()(const write_ops::InsertCommandRequest& op) const {
return op.getDocuments().size();
}
- auto operator()(const write_ops::Update& op) const {
+ auto operator()(const write_ops::UpdateCommandRequest& op) const {
return op.getUpdates().size();
}
- auto operator()(const write_ops::Delete& op) const {
+ auto operator()(const write_ops::DeleteCommandRequest& op) const {
return op.getDeletes().size();
}
};
@@ -102,29 +102,35 @@ std::size_t BatchedCommandRequest::sizeWriteOps() const {
}
bool BatchedCommandRequest::hasLegacyRuntimeConstants() const {
- return _visit(visit_helper::Overloaded{
- [](write_ops::Insert&) { return false; },
- [&](write_ops::Update& op) { return op.getLegacyRuntimeConstants().has_value(); },
- [&](write_ops::Delete& op) { return op.getLegacyRuntimeConstants().has_value(); }});
+ return _visit(visit_helper::Overloaded{[](write_ops::InsertCommandRequest&) { return false; },
+ [&](write_ops::UpdateCommandRequest& op) {
+ return op.getLegacyRuntimeConstants().has_value();
+ },
+ [&](write_ops::DeleteCommandRequest& op) {
+ return op.getLegacyRuntimeConstants().has_value();
+ }});
}
void BatchedCommandRequest::setLegacyRuntimeConstants(LegacyRuntimeConstants runtimeConstants) {
- _visit(visit_helper::Overloaded{
- [](write_ops::Insert&) {},
- [&](write_ops::Update& op) { op.setLegacyRuntimeConstants(std::move(runtimeConstants)); },
- [&](write_ops::Delete& op) { op.setLegacyRuntimeConstants(std::move(runtimeConstants)); }});
+ _visit(visit_helper::Overloaded{[](write_ops::InsertCommandRequest&) {},
+ [&](write_ops::UpdateCommandRequest& op) {
+ op.setLegacyRuntimeConstants(std::move(runtimeConstants));
+ },
+ [&](write_ops::DeleteCommandRequest& op) {
+ op.setLegacyRuntimeConstants(std::move(runtimeConstants));
+ }});
}
const boost::optional<LegacyRuntimeConstants>& BatchedCommandRequest::getLegacyRuntimeConstants()
const {
struct Visitor {
- auto& operator()(const write_ops::Insert& op) const {
+ auto& operator()(const write_ops::InsertCommandRequest& op) const {
return kEmptyRuntimeConstants;
}
- auto& operator()(const write_ops::Update& op) const {
+ auto& operator()(const write_ops::UpdateCommandRequest& op) const {
return op.getLegacyRuntimeConstants();
}
- auto& operator()(const write_ops::Delete& op) const {
+ auto& operator()(const write_ops::DeleteCommandRequest& op) const {
return op.getLegacyRuntimeConstants();
}
};
@@ -133,13 +139,13 @@ const boost::optional<LegacyRuntimeConstants>& BatchedCommandRequest::getLegacyR
const boost::optional<BSONObj>& BatchedCommandRequest::getLet() const {
struct Visitor {
- auto& operator()(const write_ops::Insert& op) const {
+ auto& operator()(const write_ops::InsertCommandRequest& op) const {
return kEmptyLet;
}
- auto& operator()(const write_ops::Update& op) const {
+ auto& operator()(const write_ops::UpdateCommandRequest& op) const {
return op.getLet();
}
- auto& operator()(const write_ops::Delete& op) const {
+ auto& operator()(const write_ops::DeleteCommandRequest& op) const {
return op.getLet();
}
};
@@ -160,12 +166,14 @@ bool BatchedCommandRequest::isVerboseWC() const {
return false;
}
-const write_ops::WriteCommandBase& BatchedCommandRequest::getWriteCommandBase() const {
- return _visit([](auto&& op) -> decltype(auto) { return op.getWriteCommandBase(); });
+const write_ops::WriteCommandRequestBase& BatchedCommandRequest::getWriteCommandRequestBase()
+ const {
+ return _visit([](auto&& op) -> decltype(auto) { return op.getWriteCommandRequestBase(); });
}
-void BatchedCommandRequest::setWriteCommandBase(write_ops::WriteCommandBase writeCommandBase) {
- return _visit([&](auto&& op) { op.setWriteCommandBase(std::move(writeCommandBase)); });
+void BatchedCommandRequest::setWriteCommandRequestBase(
+ write_ops::WriteCommandRequestBase writeCommandBase) {
+ return _visit([&](auto&& op) { op.setWriteCommandRequestBase(std::move(writeCommandBase)); });
}
void BatchedCommandRequest::serialize(BSONObjBuilder* builder) const {
@@ -226,7 +234,7 @@ BatchedCommandRequest BatchedCommandRequest::buildDeleteOp(const NamespaceString
const BSONObj& query,
bool multiDelete) {
return BatchedCommandRequest([&] {
- write_ops::Delete deleteOp(nss);
+ write_ops::DeleteCommandRequest deleteOp(nss);
deleteOp.setDeletes({[&] {
write_ops::DeleteOpEntry entry;
entry.setQ(query);
@@ -240,7 +248,7 @@ BatchedCommandRequest BatchedCommandRequest::buildDeleteOp(const NamespaceString
BatchedCommandRequest BatchedCommandRequest::buildInsertOp(const NamespaceString& nss,
const std::vector<BSONObj> docs) {
return BatchedCommandRequest([&] {
- write_ops::Insert insertOp(nss);
+ write_ops::InsertCommandRequest insertOp(nss);
insertOp.setDocuments(docs);
return insertOp;
}());
@@ -252,7 +260,7 @@ BatchedCommandRequest BatchedCommandRequest::buildUpdateOp(const NamespaceString
bool upsert,
bool multi) {
return BatchedCommandRequest([&] {
- write_ops::Update updateOp(nss);
+ write_ops::UpdateCommandRequest updateOp(nss);
updateOp.setUpdates({[&] {
write_ops::UpdateOpEntry entry;
entry.setQ(query);
@@ -272,7 +280,7 @@ BatchedCommandRequest BatchedCommandRequest::buildPipelineUpdateOp(
bool upsert,
bool useMultiUpdate) {
return BatchedCommandRequest([&] {
- write_ops::Update updateOp(nss);
+ write_ops::UpdateCommandRequest updateOp(nss);
updateOp.setUpdates({[&] {
write_ops::UpdateOpEntry entry;
entry.setQ(query);
diff --git a/src/mongo/s/write_ops/batched_command_request.h b/src/mongo/s/write_ops/batched_command_request.h
index c8f537193b6..cac280533e8 100644
--- a/src/mongo/s/write_ops/batched_command_request.h
+++ b/src/mongo/s/write_ops/batched_command_request.h
@@ -48,17 +48,17 @@ class BatchedCommandRequest {
public:
enum BatchType { BatchType_Insert, BatchType_Update, BatchType_Delete };
- BatchedCommandRequest(write_ops::Insert insertOp)
+ BatchedCommandRequest(write_ops::InsertCommandRequest insertOp)
: _batchType(BatchType_Insert),
- _insertReq(std::make_unique<write_ops::Insert>(std::move(insertOp))) {}
+ _insertReq(std::make_unique<write_ops::InsertCommandRequest>(std::move(insertOp))) {}
- BatchedCommandRequest(write_ops::Update updateOp)
+ BatchedCommandRequest(write_ops::UpdateCommandRequest updateOp)
: _batchType(BatchType_Update),
- _updateReq(std::make_unique<write_ops::Update>(std::move(updateOp))) {}
+ _updateReq(std::make_unique<write_ops::UpdateCommandRequest>(std::move(updateOp))) {}
- BatchedCommandRequest(write_ops::Delete deleteOp)
+ BatchedCommandRequest(write_ops::DeleteCommandRequest deleteOp)
: _batchType(BatchType_Delete),
- _deleteReq(std::make_unique<write_ops::Delete>(std::move(deleteOp))) {}
+ _deleteReq(std::make_unique<write_ops::DeleteCommandRequest>(std::move(deleteOp))) {}
BatchedCommandRequest(BatchedCommandRequest&&) = default;
@@ -143,8 +143,8 @@ public:
const boost::optional<LegacyRuntimeConstants>& getLegacyRuntimeConstants() const;
const boost::optional<BSONObj>& getLet() const;
- const write_ops::WriteCommandBase& getWriteCommandBase() const;
- void setWriteCommandBase(write_ops::WriteCommandBase writeCommandBase);
+ const write_ops::WriteCommandRequestBase& getWriteCommandRequestBase() const;
+ void setWriteCommandRequestBase(write_ops::WriteCommandRequestBase writeCommandBase);
void serialize(BSONObjBuilder* builder) const;
BSONObj toBSON() const;
@@ -216,9 +216,9 @@ private:
BatchType _batchType;
- std::unique_ptr<write_ops::Insert> _insertReq;
- std::unique_ptr<write_ops::Update> _updateReq;
- std::unique_ptr<write_ops::Delete> _deleteReq;
+ std::unique_ptr<write_ops::InsertCommandRequest> _insertReq;
+ std::unique_ptr<write_ops::UpdateCommandRequest> _updateReq;
+ std::unique_ptr<write_ops::DeleteCommandRequest> _deleteReq;
boost::optional<ChunkVersion> _shardVersion;
boost::optional<DatabaseVersion> _dbVersion;
diff --git a/src/mongo/s/write_ops/batched_command_request_test.cpp b/src/mongo/s/write_ops/batched_command_request_test.cpp
index 1f200ea272a..e06aa4e55fa 100644
--- a/src/mongo/s/write_ops/batched_command_request_test.cpp
+++ b/src/mongo/s/write_ops/batched_command_request_test.cpp
@@ -80,9 +80,9 @@ TEST(BatchedCommandRequest, InsertWithShardVersion) {
TEST(BatchedCommandRequest, InsertCloneWithIds) {
BatchedCommandRequest batchedRequest([&] {
- write_ops::Insert insertOp(NamespaceString("xyz.abc"));
- insertOp.setWriteCommandBase([] {
- write_ops::WriteCommandBase wcb;
+ write_ops::InsertCommandRequest insertOp(NamespaceString("xyz.abc"));
+ insertOp.setWriteCommandRequestBase([] {
+ write_ops::WriteCommandRequestBase wcb;
wcb.setOrdered(true);
wcb.setBypassDocumentValidation(true);
return wcb;
@@ -95,8 +95,8 @@ TEST(BatchedCommandRequest, InsertCloneWithIds) {
const auto clonedRequest(BatchedCommandRequest::cloneInsertWithIds(std::move(batchedRequest)));
ASSERT_EQ("xyz.abc", clonedRequest.getNS().ns());
- ASSERT(clonedRequest.getWriteCommandBase().getOrdered());
- ASSERT(clonedRequest.getWriteCommandBase().getBypassDocumentValidation());
+ ASSERT(clonedRequest.getWriteCommandRequestBase().getOrdered());
+ ASSERT(clonedRequest.getWriteCommandRequestBase().getBypassDocumentValidation());
ASSERT_BSONOBJ_EQ(BSON("w" << 2), clonedRequest.getWriteConcern());
const auto& insertDocs = clonedRequest.getInsertRequest().getDocuments();
diff --git a/src/mongo/s/write_ops/write_op_test.cpp b/src/mongo/s/write_ops/write_op_test.cpp
index acbbe528b8d..68851b61cd4 100644
--- a/src/mongo/s/write_ops/write_op_test.cpp
+++ b/src/mongo/s/write_ops/write_op_test.cpp
@@ -77,7 +77,7 @@ protected:
// Test of basic error-setting on write op
TEST_F(WriteOpTest, BasicError) {
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(kNss);
+ write_ops::InsertCommandRequest insertOp(kNss);
insertOp.setDocuments({BSON("x" << 1)});
return insertOp;
}());
@@ -99,7 +99,7 @@ TEST_F(WriteOpTest, TargetSingle) {
ShardEndpoint endpoint(ShardId("shard"), ChunkVersion::IGNORED(), boost::none);
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(kNss);
+ write_ops::InsertCommandRequest insertOp(kNss);
insertOp.setDocuments({BSON("x" << 1)});
return insertOp;
}());
@@ -132,7 +132,7 @@ TEST_F(WriteOpTest, TargetMultiOneShard) {
ShardId("shardB"), ChunkVersion(20, 0, OID(), boost::none /* timestamp */), boost::none);
BatchedCommandRequest request([&] {
- write_ops::Delete deleteOp(kNss);
+ write_ops::DeleteCommandRequest deleteOp(kNss);
// Only hits first shard
deleteOp.setDeletes({buildDelete(BSON("x" << GTE << -2 << LT << -1), false)});
return deleteOp;
@@ -168,7 +168,7 @@ TEST_F(WriteOpTest, TargetMultiAllShards) {
ShardId("shardB"), ChunkVersion(20, 0, OID(), boost::none /* timestamp */), boost::none);
BatchedCommandRequest request([&] {
- write_ops::Delete deleteOp(kNss);
+ write_ops::DeleteCommandRequest deleteOp(kNss);
deleteOp.setDeletes({buildDelete(BSON("x" << GTE << -1 << LT << 1), false)});
return deleteOp;
}());
@@ -209,7 +209,7 @@ TEST_F(WriteOpTest, TargetMultiAllShardsAndErrorSingleChildOp) {
ShardId("shardB"), ChunkVersion(20, 0, OID(), boost::none /* timestamp */), boost::none);
BatchedCommandRequest request([&] {
- write_ops::Delete deleteOp(kNss);
+ write_ops::DeleteCommandRequest deleteOp(kNss);
deleteOp.setDeletes({buildDelete(BSON("x" << GTE << -1 << LT << 1), false)});
return deleteOp;
}());
@@ -253,7 +253,7 @@ TEST_F(WriteOpTest, ErrorSingle) {
ShardEndpoint endpoint(ShardId("shard"), ChunkVersion::IGNORED(), boost::none);
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(kNss);
+ write_ops::InsertCommandRequest insertOp(kNss);
insertOp.setDocuments({BSON("x" << 1)});
return insertOp;
}());
@@ -287,7 +287,7 @@ TEST_F(WriteOpTest, CancelSingle) {
ShardEndpoint endpoint(ShardId("shard"), ChunkVersion::IGNORED(), boost::none);
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(kNss);
+ write_ops::InsertCommandRequest insertOp(kNss);
insertOp.setDocuments({BSON("x" << 1)});
return insertOp;
}());
@@ -319,7 +319,7 @@ TEST_F(WriteOpTest, RetrySingleOp) {
ShardEndpoint endpoint(ShardId("shard"), ChunkVersion::IGNORED(), boost::none);
BatchedCommandRequest request([&] {
- write_ops::Insert insertOp(kNss);
+ write_ops::InsertCommandRequest insertOp(kNss);
insertOp.setDocuments({BSON("x" << 1)});
return insertOp;
}());
@@ -363,7 +363,7 @@ TEST_F(WriteOpTransactionTest, TargetMultiDoesNotTargetAllShards) {
ShardId("shardB"), ChunkVersion(20, 0, OID(), boost::none /* timestamp */), boost::none);
BatchedCommandRequest request([&] {
- write_ops::Delete deleteOp(kNss);
+ write_ops::DeleteCommandRequest deleteOp(kNss);
deleteOp.setDeletes({buildDelete(BSON("x" << GTE << -1 << LT << 1), true /*multi*/)});
return deleteOp;
}());
@@ -402,7 +402,7 @@ TEST_F(WriteOpTransactionTest, TargetMultiAllShardsAndErrorSingleChildOp) {
ShardId("shardB"), ChunkVersion(20, 0, OID(), boost::none /* timestamp */), boost::none);
BatchedCommandRequest request([&] {
- write_ops::Delete deleteOp(kNss);
+ write_ops::DeleteCommandRequest deleteOp(kNss);
deleteOp.setDeletes({buildDelete(BSON("x" << GTE << -1 << LT << 1), false)});
return deleteOp;
}());
diff --git a/src/mongo/shell/bench.cpp b/src/mongo/shell/bench.cpp
index 76d970f97a4..01d6c264f99 100644
--- a/src/mongo/shell/bench.cpp
+++ b/src/mongo/shell/bench.cpp
@@ -230,7 +230,7 @@ void abortTransaction(DBClientBase* conn,
int runQueryWithReadCommands(DBClientBase* conn,
const boost::optional<LogicalSessionIdToClient>& lsid,
boost::optional<TxnNumber> txnNumber,
- std::unique_ptr<FindCommand> findCommand,
+ std::unique_ptr<FindCommandRequest> findCommand,
Milliseconds delayBeforeGetMore,
BSONObj* objOut) {
const auto dbName =
@@ -303,11 +303,11 @@ void doNothing(const BSONObj&) {}
Timestamp getLatestClusterTime(DBClientBase* conn) {
// Sort by descending 'ts' in the query to the oplog collection. The first entry will have the
// latest cluster time.
- auto findCommand = std::make_unique<FindCommand>(NamespaceString("local.oplog.rs"));
+ auto findCommand = std::make_unique<FindCommandRequest>(NamespaceString("local.oplog.rs"));
findCommand->setSort(BSON("$natural" << -1));
findCommand->setLimit(1LL);
findCommand->setSingleBatch(true);
- invariant(query_request_helper::validateFindCommand(*findCommand));
+ invariant(query_request_helper::validateFindCommandRequest(*findCommand));
const auto dbName =
findCommand->getNamespaceOrUUID().nss().value_or(NamespaceString()).db().toString();
@@ -1014,7 +1014,7 @@ void BenchRunOp::executeOnce(DBClientBase* conn,
BSONObj fixedQuery = fixQuery(this->query, *state->bsonTemplateEvaluator);
BSONObj result;
if (this->useReadCmd) {
- auto findCommand = std::make_unique<FindCommand>(NamespaceString(this->ns));
+ auto findCommand = std::make_unique<FindCommandRequest>(NamespaceString(this->ns));
findCommand->setFilter(fixedQuery);
findCommand->setProjection(this->projection);
findCommand->setLimit(1LL);
@@ -1023,7 +1023,7 @@ void BenchRunOp::executeOnce(DBClientBase* conn,
if (config.useSnapshotReads) {
findCommand->setReadConcern(readConcernSnapshot);
}
- invariant(query_request_helper::validateFindCommand(*findCommand));
+ invariant(query_request_helper::validateFindCommandRequest(*findCommand));
BenchRunEventTrace _bret(&state->stats->findOneCounter);
boost::optional<TxnNumber> txnNumberForOp;
@@ -1101,7 +1101,7 @@ void BenchRunOp::executeOnce(DBClientBase* conn,
"cannot use 'options' in combination with read commands",
!this->options);
- auto findCommand = std::make_unique<FindCommand>(NamespaceString(this->ns));
+ auto findCommand = std::make_unique<FindCommandRequest>(NamespaceString(this->ns));
findCommand->setFilter(fixedQuery);
findCommand->setProjection(this->projection);
if (this->skip) {
@@ -1130,7 +1130,7 @@ void BenchRunOp::executeOnce(DBClientBase* conn,
}
findCommand->setReadConcern(readConcernBuilder.obj());
- invariant(query_request_helper::validateFindCommand(*findCommand));
+ invariant(query_request_helper::validateFindCommandRequest(*findCommand));
BenchRunEventTrace _bret(&state->stats->queryCounter);
boost::optional<TxnNumber> txnNumberForOp;