From 8d555140ce24b9f59e4672a0ed026502fdfffd2c Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Fri, 23 Jun 2017 10:45:48 -0400 Subject: SERVER-29731 get errmsg out of BasicCommand api It is now only used by commands deriving from ErrmsgCommandDeprecated. --- src/mongo/db/auth/sasl_commands.cpp | 4 - src/mongo/db/commands.cpp | 9 ++- src/mongo/db/commands.h | 18 ++++- src/mongo/db/commands/apply_ops_cmd.cpp | 14 ++-- src/mongo/db/commands/authentication_commands.cpp | 3 - src/mongo/db/commands/authentication_commands.h | 1 - src/mongo/db/commands/clone.cpp | 1 - src/mongo/db/commands/clone_collection.cpp | 14 ++-- src/mongo/db/commands/collection_to_capped.cpp | 28 +++---- src/mongo/db/commands/compact.cpp | 14 ++-- src/mongo/db/commands/conn_pool_stats.cpp | 1 - src/mongo/db/commands/conn_pool_sync.cpp | 1 - src/mongo/db/commands/connection_status.cpp | 1 - src/mongo/db/commands/copydb.cpp | 14 ++-- src/mongo/db/commands/copydb_start_commands.cpp | 28 +++---- src/mongo/db/commands/count_cmd.cpp | 1 - src/mongo/db/commands/cpuload.cpp | 1 - src/mongo/db/commands/cpuprofile.cpp | 44 +++++------ src/mongo/db/commands/create_indexes.cpp | 14 ++-- src/mongo/db/commands/current_op_common.cpp | 1 - src/mongo/db/commands/current_op_common.h | 1 - src/mongo/db/commands/dbcommands.cpp | 92 ++++++++++------------ src/mongo/db/commands/dbhash.cpp | 14 ++-- src/mongo/db/commands/distinct.cpp | 1 - src/mongo/db/commands/driverHelpers.cpp | 14 ++-- src/mongo/db/commands/drop_indexes.cpp | 15 ++-- src/mongo/db/commands/eval.cpp | 14 ++-- src/mongo/db/commands/explain_cmd.cpp | 1 - src/mongo/db/commands/fail_point_cmd.cpp | 14 ++-- src/mongo/db/commands/find_and_modify.cpp | 1 - src/mongo/db/commands/find_cmd.cpp | 1 - src/mongo/db/commands/fsync.cpp | 28 +++---- src/mongo/db/commands/generic.cpp | 23 ++---- src/mongo/db/commands/geo_near_cmd.cpp | 14 ++-- src/mongo/db/commands/get_last_error.cpp | 16 ++-- src/mongo/db/commands/getmore_cmd.cpp | 4 +- src/mongo/db/commands/group_cmd.cpp | 1 - src/mongo/db/commands/hashcmd.cpp | 14 ++-- src/mongo/db/commands/haystack.cpp | 14 ++-- src/mongo/db/commands/index_filter_commands.cpp | 1 - src/mongo/db/commands/index_filter_commands.h | 1 - src/mongo/db/commands/isself.cpp | 1 - src/mongo/db/commands/kill_op.cpp | 1 - src/mongo/db/commands/killcursors_common.cpp | 1 - src/mongo/db/commands/killcursors_common.h | 1 - src/mongo/db/commands/list_collections.cpp | 1 - src/mongo/db/commands/list_databases.cpp | 1 - src/mongo/db/commands/list_indexes.cpp | 1 - src/mongo/db/commands/lock_info.cpp | 1 - src/mongo/db/commands/mr.cpp | 15 ++-- src/mongo/db/commands/oplog_note.cpp | 1 - src/mongo/db/commands/parallel_collection_scan.cpp | 1 - src/mongo/db/commands/parameters.cpp | 28 +++---- src/mongo/db/commands/pipeline_command.cpp | 1 - src/mongo/db/commands/plan_cache_commands.cpp | 1 - src/mongo/db/commands/plan_cache_commands.h | 1 - src/mongo/db/commands/rename_collection_cmd.cpp | 14 ++-- src/mongo/db/commands/repair_cursor.cpp | 1 - src/mongo/db/commands/resize_oplog.cpp | 1 - src/mongo/db/commands/server_status.cpp | 1 - .../set_feature_compatibility_version_command.cpp | 1 - src/mongo/db/commands/snapshot_management.cpp | 2 - src/mongo/db/commands/test_commands.cpp | 17 ++-- src/mongo/db/commands/top_command.cpp | 1 - src/mongo/db/commands/touch.cpp | 14 ++-- src/mongo/db/commands/user_management_commands.cpp | 20 ----- src/mongo/db/commands/validate.cpp | 14 ++-- src/mongo/db/exec/stagedebug_cmd.cpp | 2 - src/mongo/db/ftdc/ftdc_commands.cpp | 1 - src/mongo/db/repl/master_slave.cpp | 1 - src/mongo/db/repl/repl_set_commands.cpp | 18 +---- src/mongo/db/repl/repl_set_request_votes.cpp | 1 - src/mongo/db/repl/replication_info.cpp | 1 - src/mongo/db/repl/resync.cpp | 14 ++-- src/mongo/db/s/check_sharding_index_command.cpp | 14 ++-- src/mongo/db/s/cleanup_orphaned_cmd.cpp | 14 ++-- .../db/s/config/configsvr_add_shard_command.cpp | 1 - .../config/configsvr_add_shard_to_zone_command.cpp | 1 - .../configsvr_commit_chunk_migration_command.cpp | 1 - .../config/configsvr_control_balancer_command.cpp | 1 - .../db/s/config/configsvr_merge_chunk_command.cpp | 1 - .../db/s/config/configsvr_move_chunk_command.cpp | 1 - .../db/s/config/configsvr_move_primary_command.cpp | 3 +- .../configsvr_remove_shard_from_zone_command.cpp | 1 - ...r_set_feature_compatibility_version_command.cpp | 1 - .../config/configsvr_shard_collection_command.cpp | 1 - .../db/s/config/configsvr_split_chunk_command.cpp | 1 - .../configsvr_update_zone_key_range_command.cpp | 1 - .../db/s/force_routing_table_refresh_command.cpp | 1 - src/mongo/db/s/get_shard_version_command.cpp | 1 - src/mongo/db/s/merge_chunks_command.cpp | 14 ++-- ...gration_chunk_cloner_source_legacy_commands.cpp | 2 - ...gration_destination_manager_legacy_commands.cpp | 17 ++-- src/mongo/db/s/move_chunk_command.cpp | 1 - src/mongo/db/s/set_shard_version_command.cpp | 14 ++-- src/mongo/db/s/sharding_state_command.cpp | 1 - src/mongo/db/s/split_chunk_command.cpp | 14 ++-- src/mongo/db/s/split_vector_command.cpp | 14 ++-- src/mongo/db/s/unset_sharding_command.cpp | 1 - .../storage/mmap_v1/journal_latency_test_cmd.cpp | 1 - src/mongo/s/client/shard_connection.cpp | 1 - src/mongo/s/commands/cluster_add_shard_cmd.cpp | 1 - .../s/commands/cluster_add_shard_to_zone_cmd.cpp | 1 - src/mongo/s/commands/cluster_apply_ops_cmd.cpp | 1 - .../cluster_available_query_options_cmd.cpp | 1 - src/mongo/s/commands/cluster_compact_cmd.cpp | 1 - .../s/commands/cluster_control_balancer_cmd.cpp | 1 - src/mongo/s/commands/cluster_count_cmd.cpp | 14 ++-- src/mongo/s/commands/cluster_db_stats_cmd.cpp | 14 ++-- src/mongo/s/commands/cluster_drop_cmd.cpp | 1 - src/mongo/s/commands/cluster_drop_database_cmd.cpp | 1 - .../s/commands/cluster_enable_sharding_cmd.cpp | 14 ++-- src/mongo/s/commands/cluster_explain_cmd.cpp | 1 - .../s/commands/cluster_find_and_modify_cmd.cpp | 1 - src/mongo/s/commands/cluster_find_cmd.cpp | 1 - .../s/commands/cluster_flush_router_config_cmd.cpp | 1 - src/mongo/s/commands/cluster_fsync_cmd.cpp | 14 ++-- src/mongo/s/commands/cluster_ftdc_commands.cpp | 14 ++-- .../s/commands/cluster_get_last_error_cmd.cpp | 1 - .../s/commands/cluster_get_prev_error_cmd.cpp | 14 ++-- src/mongo/s/commands/cluster_get_shard_map_cmd.cpp | 1 - .../s/commands/cluster_get_shard_version_cmd.cpp | 1 - src/mongo/s/commands/cluster_getmore_cmd.cpp | 1 - src/mongo/s/commands/cluster_index_filter_cmd.cpp | 1 - src/mongo/s/commands/cluster_is_db_grid_cmd.cpp | 1 - src/mongo/s/commands/cluster_is_master_cmd.cpp | 1 - src/mongo/s/commands/cluster_kill_op.cpp | 1 - .../s/commands/cluster_list_databases_cmd.cpp | 1 - src/mongo/s/commands/cluster_list_shards_cmd.cpp | 1 - src/mongo/s/commands/cluster_map_reduce_cmd.cpp | 14 ++-- src/mongo/s/commands/cluster_merge_chunks_cmd.cpp | 14 ++-- src/mongo/s/commands/cluster_move_chunk_cmd.cpp | 14 ++-- src/mongo/s/commands/cluster_move_primary_cmd.cpp | 1 - src/mongo/s/commands/cluster_netstat_cmd.cpp | 1 - src/mongo/s/commands/cluster_pipeline_cmd.cpp | 1 - src/mongo/s/commands/cluster_plan_cache_cmd.cpp | 2 - src/mongo/s/commands/cluster_profile_cmd.cpp | 14 ++-- src/mongo/s/commands/cluster_remove_shard_cmd.cpp | 1 - .../cluster_remove_shard_from_zone_cmd.cpp | 1 - .../s/commands/cluster_repl_set_get_status_cmd.cpp | 14 ++-- src/mongo/s/commands/cluster_reset_error_cmd.cpp | 1 - ...uster_set_feature_compatibility_version_cmd.cpp | 1 - .../s/commands/cluster_shard_collection_cmd.cpp | 1 - src/mongo/s/commands/cluster_shutdown_cmd.cpp | 1 - src/mongo/s/commands/cluster_split_cmd.cpp | 14 ++-- .../commands/cluster_update_zone_key_range_cmd.cpp | 1 - .../commands/cluster_user_management_commands.cpp | 19 ----- src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp | 1 - src/mongo/s/commands/commands_public.cpp | 45 ++++------- 149 files changed, 444 insertions(+), 623 deletions(-) (limited to 'src') diff --git a/src/mongo/db/auth/sasl_commands.cpp b/src/mongo/db/auth/sasl_commands.cpp index df74cea7436..57ad20647d8 100644 --- a/src/mongo/db/auth/sasl_commands.cpp +++ b/src/mongo/db/auth/sasl_commands.cpp @@ -76,7 +76,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& db, const BSONObj& cmdObj, - std::string& ignored, BSONObjBuilder& result); virtual void help(stringstream& help) const; @@ -103,7 +102,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& db, const BSONObj& cmdObj, - std::string& ignored, BSONObjBuilder& result); virtual void help(stringstream& help) const; @@ -271,7 +269,6 @@ void CmdSaslStart::redactForLogging(mutablebson::Document* cmdObj) { bool CmdSaslStart::run(OperationContext* opCtx, const std::string& db, const BSONObj& cmdObj, - std::string& ignored, BSONObjBuilder& result) { Client* client = Client::getCurrent(); AuthenticationSession::set(client, std::unique_ptr()); @@ -312,7 +309,6 @@ void CmdSaslContinue::help(std::stringstream& os) const { bool CmdSaslContinue::run(OperationContext* opCtx, const std::string& db, const BSONObj& cmdObj, - std::string& ignored, BSONObjBuilder& result) { Client* client = Client::getCurrent(); std::unique_ptr sessionGuard; diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp index b98eb1bcc6f..0e82077f6d0 100644 --- a/src/mongo/db/commands.cpp +++ b/src/mongo/db/commands.cpp @@ -371,8 +371,15 @@ bool BasicCommand::enhancedRun(OperationContext* opCtx, str::stream() << "The " << getName() << " command does not support document sequences.", request.sequences.empty()); + return run(opCtx, request.getDatabase().toString(), request.body, result); +} + +bool ErrmsgCommandDeprecated::run(OperationContext* opCtx, + const std::string& db, + const BSONObj& cmdObj, + BSONObjBuilder& result) { std::string errmsg; - bool ok = run(opCtx, request.getDatabase().toString(), request.body, errmsg, result); + auto ok = errmsgRun(opCtx, db, cmdObj, errmsg, result); if (!errmsg.empty()) { appendCommandStatus(result, ok, errmsg); } diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h index 1953866e624..c30a0471d7a 100644 --- a/src/mongo/db/commands.h +++ b/src/mongo/db/commands.h @@ -583,8 +583,24 @@ public: virtual bool run(OperationContext* opCtx, const std::string& db, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) = 0; }; +/** + * Deprecated. Do not add new subclasses. + */ +class ErrmsgCommandDeprecated : public BasicCommand { + using BasicCommand::BasicCommand; + bool run(OperationContext* opCtx, + const std::string& db, + const BSONObj& cmdObj, + BSONObjBuilder& result) final; + + virtual bool errmsgRun(OperationContext* opCtx, + const std::string& db, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& result) = 0; +}; + } // namespace mongo diff --git a/src/mongo/db/commands/apply_ops_cmd.cpp b/src/mongo/db/commands/apply_ops_cmd.cpp index ca0266908dd..caa6ec4c319 100644 --- a/src/mongo/db/commands/apply_ops_cmd.cpp +++ b/src/mongo/db/commands/apply_ops_cmd.cpp @@ -61,9 +61,9 @@ using std::stringstream; namespace { -class ApplyOpsCmd : public BasicCommand { +class ApplyOpsCmd : public ErrmsgCommandDeprecated { public: - ApplyOpsCmd() : BasicCommand("applyOps") {} + ApplyOpsCmd() : ErrmsgCommandDeprecated("applyOps") {} virtual bool slaveOk() const { return false; @@ -85,11 +85,11 @@ public: return checkAuthForApplyOpsCommand(opCtx, dbname, cmdObj); } - virtual bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { validateApplyOpsCommand(cmdObj); boost::optional maybeDisableValidation; diff --git a/src/mongo/db/commands/authentication_commands.cpp b/src/mongo/db/commands/authentication_commands.cpp index c7e6d1160aa..4c088f97493 100644 --- a/src/mongo/db/commands/authentication_commands.cpp +++ b/src/mongo/db/commands/authentication_commands.cpp @@ -116,7 +116,6 @@ public: bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { nonce64 n = getNextNonce(); stringstream ss; @@ -153,7 +152,6 @@ void CmdAuthenticate::redactForLogging(mutablebson::Document* cmdObj) { bool CmdAuthenticate::run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { if (!serverGlobalParams.quiet.load()) { mutablebson::Document cmdToLog(cmdObj, mutablebson::Document::kInPlaceDisabled); @@ -378,7 +376,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { AuthorizationSession* authSession = AuthorizationSession::get(Client::getCurrent()); authSession->logoutDatabase(dbname); diff --git a/src/mongo/db/commands/authentication_commands.h b/src/mongo/db/commands/authentication_commands.h index 5bb01ad9fae..bbb837e4015 100644 --- a/src/mongo/db/commands/authentication_commands.h +++ b/src/mongo/db/commands/authentication_commands.h @@ -58,7 +58,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result); private: diff --git a/src/mongo/db/commands/clone.cpp b/src/mongo/db/commands/clone.cpp index 97744cedf86..f219a374778 100644 --- a/src/mongo/db/commands/clone.cpp +++ b/src/mongo/db/commands/clone.cpp @@ -90,7 +90,6 @@ public: virtual bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { boost::optional maybeDisableValidation; if (shouldBypassDocumentValidationForCommand(cmdObj)) { diff --git a/src/mongo/db/commands/clone_collection.cpp b/src/mongo/db/commands/clone_collection.cpp index 3eea32aa1fc..0ec44950793 100644 --- a/src/mongo/db/commands/clone_collection.cpp +++ b/src/mongo/db/commands/clone_collection.cpp @@ -59,9 +59,9 @@ using std::string; using std::stringstream; using std::endl; -class CmdCloneCollection : public BasicCommand { +class CmdCloneCollection : public ErrmsgCommandDeprecated { public: - CmdCloneCollection() : BasicCommand("cloneCollection") {} + CmdCloneCollection() : ErrmsgCommandDeprecated("cloneCollection") {} virtual bool slaveOk() const { return false; @@ -103,11 +103,11 @@ public: "is placed at the same db.collection (namespace) as the source.\n"; } - virtual bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { boost::optional maybeDisableValidation; if (shouldBypassDocumentValidationForCommand(cmdObj)) maybeDisableValidation.emplace(opCtx); diff --git a/src/mongo/db/commands/collection_to_capped.cpp b/src/mongo/db/commands/collection_to_capped.cpp index 6a56cbaf144..55272f941a0 100644 --- a/src/mongo/db/commands/collection_to_capped.cpp +++ b/src/mongo/db/commands/collection_to_capped.cpp @@ -49,9 +49,9 @@ using std::unique_ptr; using std::string; using std::stringstream; -class CmdCloneCollectionAsCapped : public BasicCommand { +class CmdCloneCollectionAsCapped : public ErrmsgCommandDeprecated { public: - CmdCloneCollectionAsCapped() : BasicCommand("cloneCollectionAsCapped") {} + CmdCloneCollectionAsCapped() : ErrmsgCommandDeprecated("cloneCollectionAsCapped") {} virtual bool slaveOk() const { return false; } @@ -84,11 +84,11 @@ public: out->push_back(Privilege(ResourcePattern::forExactNamespace(nss), targetActions)); } - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& jsobj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& jsobj, + string& errmsg, + BSONObjBuilder& result) { const auto fromElt = jsobj["cloneCollectionAsCapped"]; const auto toElt = jsobj["toCollection"]; @@ -148,9 +148,9 @@ public: This command is not highly used, and is not currently supported with sharded environments. */ -class CmdConvertToCapped : public BasicCommand { +class CmdConvertToCapped : public ErrmsgCommandDeprecated { public: - CmdConvertToCapped() : BasicCommand("convertToCapped") {} + CmdConvertToCapped() : ErrmsgCommandDeprecated("convertToCapped") {} virtual bool slaveOk() const { return false; } @@ -168,11 +168,11 @@ public: out->push_back(Privilege(parseResourcePattern(dbname, cmdObj), actions)); } - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& jsobj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& jsobj, + string& errmsg, + BSONObjBuilder& result) { const NamespaceString nss(parseNsCollectionRequired(dbname, jsobj)); double size = jsobj.getField("size").number(); diff --git a/src/mongo/db/commands/compact.cpp b/src/mongo/db/commands/compact.cpp index 492b9c46184..780790bb994 100644 --- a/src/mongo/db/commands/compact.cpp +++ b/src/mongo/db/commands/compact.cpp @@ -53,7 +53,7 @@ namespace mongo { using std::string; using std::stringstream; -class CompactCmd : public BasicCommand { +class CompactCmd : public ErrmsgCommandDeprecated { public: virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; @@ -84,13 +84,13 @@ public: " validate - check records are noncorrupt before adding to newly compacting " "extents. slower but safer (defaults to true in this version)\n"; } - CompactCmd() : BasicCommand("compact") {} + CompactCmd() : ErrmsgCommandDeprecated("compact") {} - virtual bool run(OperationContext* opCtx, - const string& db, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const string& db, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { NamespaceString nss = parseNsCollectionRequired(db, cmdObj); repl::ReplicationCoordinator* replCoord = repl::getGlobalReplicationCoordinator(); diff --git a/src/mongo/db/commands/conn_pool_stats.cpp b/src/mongo/db/commands/conn_pool_stats.cpp index 55047a55109..119712ce811 100644 --- a/src/mongo/db/commands/conn_pool_stats.cpp +++ b/src/mongo/db/commands/conn_pool_stats.cpp @@ -76,7 +76,6 @@ public: bool run(OperationContext* opCtx, const std::string& db, const mongo::BSONObj& cmdObj, - std::string& errmsg, mongo::BSONObjBuilder& result) override { executor::ConnectionPoolStats stats{}; diff --git a/src/mongo/db/commands/conn_pool_sync.cpp b/src/mongo/db/commands/conn_pool_sync.cpp index b1ce5b26dcf..c5831277334 100644 --- a/src/mongo/db/commands/conn_pool_sync.cpp +++ b/src/mongo/db/commands/conn_pool_sync.cpp @@ -57,7 +57,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string&, const mongo::BSONObj&, - std::string&, mongo::BSONObjBuilder& result) { shardConnectionPool.flush(); globalConnPool.flush(); diff --git a/src/mongo/db/commands/connection_status.cpp b/src/mongo/db/commands/connection_status.cpp index 9454b8769b4..b8ea2e101fd 100644 --- a/src/mongo/db/commands/connection_status.cpp +++ b/src/mongo/db/commands/connection_status.cpp @@ -58,7 +58,6 @@ public: bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { AuthorizationSession* authSession = AuthorizationSession::get(Client::getCurrent()); diff --git a/src/mongo/db/commands/copydb.cpp b/src/mongo/db/commands/copydb.cpp index 4755d032916..0695a60382e 100644 --- a/src/mongo/db/commands/copydb.cpp +++ b/src/mongo/db/commands/copydb.cpp @@ -87,9 +87,9 @@ using std::stringstream; * NOTE: Since internal cluster auth works differently, "copydb" currently doesn't work between * shards in a cluster when auth is enabled. See SERVER-13080. */ -class CmdCopyDb : public BasicCommand { +class CmdCopyDb : public ErrmsgCommandDeprecated { public: - CmdCopyDb() : BasicCommand("copydb") {} + CmdCopyDb() : ErrmsgCommandDeprecated("copydb") {} virtual bool adminOnly() const { return true; @@ -115,11 +115,11 @@ public: << "[, slaveOk: , username: , nonce: , key: ]}"; } - virtual bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { boost::optional maybeDisableValidation; if (shouldBypassDocumentValidationForCommand(cmdObj)) maybeDisableValidation.emplace(opCtx); diff --git a/src/mongo/db/commands/copydb_start_commands.cpp b/src/mongo/db/commands/copydb_start_commands.cpp index fbb3d485180..d537d621977 100644 --- a/src/mongo/db/commands/copydb_start_commands.cpp +++ b/src/mongo/db/commands/copydb_start_commands.cpp @@ -68,9 +68,9 @@ std::unique_ptr& CopyDbAuthConnection::forClient(Client* client) { * nonce from the source of a "copydb" operation for authentication purposes. See the * description of the "copydb" command below. */ -class CmdCopyDbGetNonce : public BasicCommand { +class CmdCopyDbGetNonce : public ErrmsgCommandDeprecated { public: - CmdCopyDbGetNonce() : BasicCommand("copydbgetnonce") {} + CmdCopyDbGetNonce() : ErrmsgCommandDeprecated("copydbgetnonce") {} virtual bool adminOnly() const { return true; @@ -96,11 +96,11 @@ public: help << "usage: {copydbgetnonce: 1, fromhost: }"; } - virtual bool run(OperationContext* opCtx, - const string&, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const string&, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { string fromhost = cmdObj.getStringField("fromhost"); if (fromhost.empty()) { /* copy from self */ @@ -140,9 +140,9 @@ public: * Run against the mongod that is the intended target for the "copydb" command. Used to * initialize a SASL auth session for a "copydb" operation for authentication purposes. */ -class CmdCopyDbSaslStart : public BasicCommand { +class CmdCopyDbSaslStart : public ErrmsgCommandDeprecated { public: - CmdCopyDbSaslStart() : BasicCommand("copydbsaslstart") {} + CmdCopyDbSaslStart() : ErrmsgCommandDeprecated("copydbsaslstart") {} virtual bool adminOnly() const { return true; @@ -169,11 +169,11 @@ public: "from secure server\n"; } - virtual bool run(OperationContext* opCtx, - const string&, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const string&, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { const auto fromdbElt = cmdObj["fromdb"]; uassert(ErrorCodes::TypeMismatch, "'renameCollection' must be of type String", diff --git a/src/mongo/db/commands/count_cmd.cpp b/src/mongo/db/commands/count_cmd.cpp index dcd60503a80..199c3e0be9b 100644 --- a/src/mongo/db/commands/count_cmd.cpp +++ b/src/mongo/db/commands/count_cmd.cpp @@ -158,7 +158,6 @@ public: virtual bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { const bool isExplain = false; auto request = CountRequest::parseFromBSON(dbname, cmdObj, isExplain); diff --git a/src/mongo/db/commands/cpuload.cpp b/src/mongo/db/commands/cpuload.cpp index 996b6e11b46..51192715b1a 100644 --- a/src/mongo/db/commands/cpuload.cpp +++ b/src/mongo/db/commands/cpuload.cpp @@ -61,7 +61,6 @@ public: virtual bool run(OperationContext* txn, const string& badns, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { double cpuFactor = 1; if (cmdObj["cpuFactor"].isNumber()) { diff --git a/src/mongo/db/commands/cpuprofile.cpp b/src/mongo/db/commands/cpuprofile.cpp index 0586c646156..3d2ecc5da4f 100644 --- a/src/mongo/db/commands/cpuprofile.cpp +++ b/src/mongo/db/commands/cpuprofile.cpp @@ -68,9 +68,9 @@ namespace { /** * Common code for the implementation of cpu profiler commands. */ -class CpuProfilerCommand : public BasicCommand { +class CpuProfilerCommand : public ErrmsgCommandDeprecated { public: - CpuProfilerCommand(char const* name) : BasicCommand(name) {} + CpuProfilerCommand(char const* name) : ErrmsgCommandDeprecated(name) {} virtual bool slaveOk() const { return true; } @@ -103,11 +103,11 @@ class CpuProfilerStartCommand : public CpuProfilerCommand { public: CpuProfilerStartCommand() : CpuProfilerCommand(commandName) {} - virtual bool run(OperationContext* opCtx, - std::string const& db, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& result); + virtual bool errmsgRun(OperationContext* opCtx, + std::string const& db, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& result); static char const* const commandName; } cpuProfilerStartCommandInstance; @@ -119,11 +119,11 @@ class CpuProfilerStopCommand : public CpuProfilerCommand { public: CpuProfilerStopCommand() : CpuProfilerCommand(commandName) {} - virtual bool run(OperationContext* opCtx, - std::string const& db, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& result); + virtual bool errmsgRun(OperationContext* opCtx, + std::string const& db, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& result); static char const* const commandName; } cpuProfilerStopCommandInstance; @@ -131,11 +131,11 @@ public: char const* const CpuProfilerStartCommand::commandName = "_cpuProfilerStart"; char const* const CpuProfilerStopCommand::commandName = "_cpuProfilerStop"; -bool CpuProfilerStartCommand::run(OperationContext* opCtx, - std::string const& db, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& result) { +bool CpuProfilerStartCommand::errmsgRun(OperationContext* opCtx, + std::string const& db, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& result) { // The DB lock here is just so we have IX on the global lock in order to prevent shutdown Lock::DBLock dbXLock(opCtx, db, MODE_X); OldClientContext ctx(opCtx, db, false /* no shard version checking */); @@ -148,11 +148,11 @@ bool CpuProfilerStartCommand::run(OperationContext* opCtx, return true; } -bool CpuProfilerStopCommand::run(OperationContext* opCtx, - std::string const& db, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& result) { +bool CpuProfilerStopCommand::errmsgRun(OperationContext* opCtx, + std::string const& db, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& result) { // The DB lock here is just so we have IX on the global lock in order to prevent shutdown Lock::DBLock dbXLock(opCtx, db, MODE_X); OldClientContext ctx(opCtx, db, false /* no shard version checking */); diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp index 563a173d7b9..230ca733659 100644 --- a/src/mongo/db/commands/create_indexes.cpp +++ b/src/mongo/db/commands/create_indexes.cpp @@ -208,9 +208,9 @@ StatusWith> resolveCollectionDefaultProperties( /** * { createIndexes : "bar", indexes : [ { ns : "test.bar", key : { x : 1 }, name: "x_1" } ] } */ -class CmdCreateIndex : public BasicCommand { +class CmdCreateIndex : public ErrmsgCommandDeprecated { public: - CmdCreateIndex() : BasicCommand(kCommandName) {} + CmdCreateIndex() : ErrmsgCommandDeprecated(kCommandName) {} virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return true; @@ -230,11 +230,11 @@ public: return Status(ErrorCodes::Unauthorized, "Unauthorized"); } - virtual bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { const NamespaceString ns(parseNsCollectionRequired(dbname, cmdObj)); Status status = userAllowedWriteNS(ns); diff --git a/src/mongo/db/commands/current_op_common.cpp b/src/mongo/db/commands/current_op_common.cpp index b3b8ec18061..2e2a1ec799d 100644 --- a/src/mongo/db/commands/current_op_common.cpp +++ b/src/mongo/db/commands/current_op_common.cpp @@ -39,7 +39,6 @@ namespace mongo { bool CurrentOpCommandBase::run(OperationContext* opCtx, const std::string& dbName, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { // Convert the currentOp command spec into an equivalent aggregation command. This will be // of the form {aggregate:1, pipeline: [{$currentOp: {idleConnections: $all, allUsers: diff --git a/src/mongo/db/commands/current_op_common.h b/src/mongo/db/commands/current_op_common.h index 9fb143bd271..1a3ae46a1ec 100644 --- a/src/mongo/db/commands/current_op_common.h +++ b/src/mongo/db/commands/current_op_common.h @@ -58,7 +58,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) final; private: diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp index ac68b36e727..ee67ed17ccb 100644 --- a/src/mongo/db/commands/dbcommands.cpp +++ b/src/mongo/db/commands/dbcommands.cpp @@ -124,7 +124,6 @@ public: virtual bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { bool force = cmdObj.hasField("force") && cmdObj["force"].trueValue(); @@ -173,7 +172,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { // disallow dropping the config database if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer && @@ -211,7 +209,7 @@ public: } cmdDropDatabase; -class CmdRepairDatabase : public BasicCommand { +class CmdRepairDatabase : public ErrmsgCommandDeprecated { public: virtual bool slaveOk() const { return true; @@ -236,13 +234,13 @@ public: out->push_back(Privilege(ResourcePattern::forDatabaseName(dbname), actions)); } - CmdRepairDatabase() : BasicCommand("repairDatabase") {} + CmdRepairDatabase() : ErrmsgCommandDeprecated("repairDatabase") {} - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { BSONElement e = cmdObj.firstElement(); if (e.numberInt() != 1) { errmsg = "bad option"; @@ -296,7 +294,7 @@ public: todo: how do we handle profiling information put in the db with replication? sensibly or not? */ -class CmdProfile : public BasicCommand { +class CmdProfile : public ErrmsgCommandDeprecated { public: virtual bool slaveOk() const { return true; @@ -339,13 +337,13 @@ public: return Status(ErrorCodes::Unauthorized, "unauthorized"); } - CmdProfile() : BasicCommand("profile") {} + CmdProfile() : ErrmsgCommandDeprecated("profile") {} - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { BSONElement firstElement = cmdObj.firstElement(); int profilingLevel = firstElement.numberInt(); @@ -426,7 +424,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { const char* deprecationWarning = "CMD diagLogging is deprecated and will be removed in a future release"; @@ -455,9 +452,9 @@ public: } cmddiaglogging; /* drop collection */ -class CmdDrop : public BasicCommand { +class CmdDrop : public ErrmsgCommandDeprecated { public: - CmdDrop() : BasicCommand("drop") {} + CmdDrop() : ErrmsgCommandDeprecated("drop") {} virtual bool slaveOk() const { return false; } @@ -480,11 +477,11 @@ public: return true; } - virtual bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { const NamespaceString nsToDrop = parseNsCollectionRequired(dbname, cmdObj); if (NamespaceString::virtualized(nsToDrop.ns())) { @@ -540,7 +537,6 @@ public: virtual bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { const NamespaceString ns(parseNsCollectionRequired(dbname, cmdObj)); @@ -668,7 +664,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& jsobj, - string& errmsg, BSONObjBuilder& result) { const NamespaceString nss(parseNs(dbname, jsobj)); @@ -803,13 +798,13 @@ public: } cmdFileMD5; -class CmdDatasize : public BasicCommand { +class CmdDatasize : public ErrmsgCommandDeprecated { virtual string parseNs(const string& dbname, const BSONObj& cmdObj) const { return parseNsFullyQualified(dbname, cmdObj); } public: - CmdDatasize() : BasicCommand("dataSize", "datasize") {} + CmdDatasize() : ErrmsgCommandDeprecated("dataSize", "datasize") {} virtual bool slaveOk() const { return true; @@ -838,11 +833,11 @@ public: out->push_back(Privilege(parseResourcePattern(dbname, cmdObj), actions)); } - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& jsobj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& jsobj, + string& errmsg, + BSONObjBuilder& result) { Timer timer; string ns = jsobj.firstElement().String(); @@ -957,9 +952,9 @@ public: } cmdDatasize; -class CollectionStats : public BasicCommand { +class CollectionStats : public ErrmsgCommandDeprecated { public: - CollectionStats() : BasicCommand("collStats", "collstats") {} + CollectionStats() : ErrmsgCommandDeprecated("collStats", "collstats") {} virtual bool slaveOk() const { return true; @@ -981,11 +976,11 @@ public: out->push_back(Privilege(parseResourcePattern(dbname, cmdObj), actions)); } - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& jsobj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& jsobj, + string& errmsg, + BSONObjBuilder& result) { const NamespaceString nss(parseNsCollectionRequired(dbname, jsobj)); if (nss.coll().empty()) { @@ -1032,7 +1027,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& jsobj, - string& errmsg, BSONObjBuilder& result) { const NamespaceString nss(parseNsCollectionRequired(dbname, jsobj)); return appendCommandStatus(result, collMod(opCtx, nss, jsobj, &result)); @@ -1040,9 +1034,9 @@ public: } collectionModCommand; -class DBStats : public BasicCommand { +class DBStats : public ErrmsgCommandDeprecated { public: - DBStats() : BasicCommand("dbStats", "dbstats") {} + DBStats() : ErrmsgCommandDeprecated("dbStats", "dbstats") {} virtual bool slaveOk() const { return true; @@ -1064,11 +1058,11 @@ public: out->push_back(Privilege(ResourcePattern::forDatabaseName(dbname), actions)); } - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& jsobj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& jsobj, + string& errmsg, + BSONObjBuilder& result) { int scale = 1; if (jsobj["scale"].isNumber()) { scale = jsobj["scale"].numberInt(); @@ -1151,7 +1145,6 @@ public: virtual bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { result << "you" << opCtx->getClient()->clientAddress(true /*includePort*/); return true; @@ -1177,7 +1170,6 @@ public: virtual bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { result << "options" << QueryOption_AllSupported; return true; diff --git a/src/mongo/db/commands/dbhash.cpp b/src/mongo/db/commands/dbhash.cpp index b288be37c4d..78d4839e45c 100644 --- a/src/mongo/db/commands/dbhash.cpp +++ b/src/mongo/db/commands/dbhash.cpp @@ -52,9 +52,9 @@ namespace mongo { namespace { -class DBHashCmd : public BasicCommand { +class DBHashCmd : public ErrmsgCommandDeprecated { public: - DBHashCmd() : BasicCommand("dbHash", "dbhash") {} + DBHashCmd() : ErrmsgCommandDeprecated("dbHash", "dbhash") {} virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; @@ -72,11 +72,11 @@ public: out->push_back(Privilege(ResourcePattern::forDatabaseName(dbname), actions)); } - virtual bool run(OperationContext* opCtx, - const std::string& dbname, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const std::string& dbname, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& result) { Timer timer; std::set desiredCollections; diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp index 62d21c239e9..a0eceaaa7d5 100644 --- a/src/mongo/db/commands/distinct.cpp +++ b/src/mongo/db/commands/distinct.cpp @@ -158,7 +158,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { const NamespaceString nss(parseNsCollectionRequired(dbname, cmdObj)); diff --git a/src/mongo/db/commands/driverHelpers.cpp b/src/mongo/db/commands/driverHelpers.cpp index 589c2303bdb..2f1e688aa15 100644 --- a/src/mongo/db/commands/driverHelpers.cpp +++ b/src/mongo/db/commands/driverHelpers.cpp @@ -52,9 +52,9 @@ namespace mongo { using std::string; -class BasicDriverHelper : public BasicCommand { +class BasicDriverHelper : public ErrmsgCommandDeprecated { public: - BasicDriverHelper(const char* name) : BasicCommand(name) {} + BasicDriverHelper(const char* name) : ErrmsgCommandDeprecated(name) {} virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; @@ -73,11 +73,11 @@ public: virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, std::vector* out) {} // No auth required - virtual bool run(OperationContext* opCtx, - const string&, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const string&, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { if (cmdObj.firstElement().type() != jstOID) { errmsg = "not oid"; return false; diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp index 42a16dad2ab..1faedbb761c 100644 --- a/src/mongo/db/commands/drop_indexes.cpp +++ b/src/mongo/db/commands/drop_indexes.cpp @@ -87,7 +87,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& jsobj, - string& errmsg, BSONObjBuilder& result) { const NamespaceString nss = parseNsCollectionRequired(dbname, jsobj); return appendCommandStatus(result, dropIndexes(opCtx, nss, jsobj, &result)); @@ -95,7 +94,7 @@ public: } cmdDropIndexes; -class CmdReIndex : public BasicCommand { +class CmdReIndex : public ErrmsgCommandDeprecated { public: virtual bool slaveOk() const { return true; @@ -113,13 +112,13 @@ public: actions.addAction(ActionType::reIndex); out->push_back(Privilege(parseResourcePattern(dbname, cmdObj), actions)); } - CmdReIndex() : BasicCommand("reIndex") {} + CmdReIndex() : ErrmsgCommandDeprecated("reIndex") {} - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& jsobj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& jsobj, + string& errmsg, + BSONObjBuilder& result) { DBDirectClient db(opCtx); const NamespaceString toReIndexNs = parseNsCollectionRequired(dbname, jsobj); diff --git a/src/mongo/db/commands/eval.cpp b/src/mongo/db/commands/eval.cpp index bb7e13f1cfb..28a73562df7 100644 --- a/src/mongo/db/commands/eval.cpp +++ b/src/mongo/db/commands/eval.cpp @@ -152,7 +152,7 @@ bool dbEval(OperationContext* opCtx, } -class CmdEval : public BasicCommand { +class CmdEval : public ErrmsgCommandDeprecated { public: virtual bool slaveOk() const { return false; @@ -172,13 +172,13 @@ public: RoleGraph::generateUniversalPrivileges(out); } - CmdEval() : BasicCommand("eval", "$eval") {} + CmdEval() : ErrmsgCommandDeprecated("eval", "$eval") {} - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { // Note: 'eval' is not allowed to touch sharded namespaces, but we can't check the // shardVersions of the namespaces accessed in the script until the script is evaluated. // Instead, we enforce that the script does not access sharded namespaces by ensuring the diff --git a/src/mongo/db/commands/explain_cmd.cpp b/src/mongo/db/commands/explain_cmd.cpp index ec07e0f5106..c2b3893c15e 100644 --- a/src/mongo/db/commands/explain_cmd.cpp +++ b/src/mongo/db/commands/explain_cmd.cpp @@ -123,7 +123,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { auto verbosity = ExplainOptions::parseCmdBSON(cmdObj); if (!verbosity.isOK()) { diff --git a/src/mongo/db/commands/fail_point_cmd.cpp b/src/mongo/db/commands/fail_point_cmd.cpp index 74da22e059c..c5fcda4b995 100644 --- a/src/mongo/db/commands/fail_point_cmd.cpp +++ b/src/mongo/db/commands/fail_point_cmd.cpp @@ -64,9 +64,9 @@ using std::stringstream; * data: // optional arbitrary object to store. * } */ -class FaultInjectCmd : public BasicCommand { +class FaultInjectCmd : public ErrmsgCommandDeprecated { public: - FaultInjectCmd() : BasicCommand("configureFailPoint") {} + FaultInjectCmd() : ErrmsgCommandDeprecated("configureFailPoint") {} virtual bool slaveOk() const { return true; @@ -90,11 +90,11 @@ public: h << "modifies the settings of a fail point"; } - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { const string failPointName(cmdObj.firstElement().str()); FailPointRegistry* registry = getGlobalFailPointRegistry(); FailPoint* failPoint = registry->getFailPoint(failPointName); diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp index d83a44beec4..8014c67ecd0 100644 --- a/src/mongo/db/commands/find_and_modify.cpp +++ b/src/mongo/db/commands/find_and_modify.cpp @@ -338,7 +338,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbName, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { // findAndModify command is not replicated directly. invariant(opCtx->writesAreReplicated()); diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp index 392ccfcb066..8d89469a27f 100644 --- a/src/mongo/db/commands/find_cmd.cpp +++ b/src/mongo/db/commands/find_cmd.cpp @@ -221,7 +221,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { const NamespaceString nss(parseNsOrUUID(opCtx, dbname, cmdObj)); diff --git a/src/mongo/db/commands/fsync.cpp b/src/mongo/db/commands/fsync.cpp index b266281f19b..e4c3aca53bd 100644 --- a/src/mongo/db/commands/fsync.cpp +++ b/src/mongo/db/commands/fsync.cpp @@ -78,13 +78,13 @@ public: virtual void run(); }; -class FSyncCommand : public BasicCommand { +class FSyncCommand : public ErrmsgCommandDeprecated { public: static const char* url() { return "http://dochub.mongodb.org/core/fsynccommand"; } - FSyncCommand() : BasicCommand("fsync") {} + FSyncCommand() : ErrmsgCommandDeprecated("fsync") {} virtual ~FSyncCommand() { // The FSyncLockThread is owned by the FSyncCommand and accesses FsyncCommand state. It must @@ -117,11 +117,11 @@ public: actions.addAction(ActionType::fsync); out->push_back(Privilege(ResourcePattern::forClusterResource(), actions)); } - virtual bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { if (opCtx->lockState()->isLocked()) { errmsg = "fsync: Cannot execute fsync command from contexts that hold a data lock"; return false; @@ -264,9 +264,9 @@ private: bool _fsyncLocked = false; } fsyncCmd; -class FSyncUnlockCommand : public BasicCommand { +class FSyncUnlockCommand : public ErrmsgCommandDeprecated { public: - FSyncUnlockCommand() : BasicCommand("fsyncUnlock") {} + FSyncUnlockCommand() : ErrmsgCommandDeprecated("fsyncUnlock") {} virtual bool supportsWriteConcern(const BSONObj& cmd) const override { @@ -290,11 +290,11 @@ public: return isAuthorized ? Status::OK() : Status(ErrorCodes::Unauthorized, "Unauthorized"); } - bool run(OperationContext* opCtx, - const std::string& db, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& result) override { + bool errmsgRun(OperationContext* opCtx, + const std::string& db, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& result) override { log() << "command: unlock requested"; Lock::ExclusiveLock lk(opCtx->lockState(), commandMutex); diff --git a/src/mongo/db/commands/generic.cpp b/src/mongo/db/commands/generic.cpp index a9b3e982c23..35998427356 100644 --- a/src/mongo/db/commands/generic.cpp +++ b/src/mongo/db/commands/generic.cpp @@ -92,7 +92,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& jsobj, - std::string& errmsg, BSONObjBuilder& result) { VersionInfoInterface::instance().appendBuildInfo(&result); appendStorageEngineList(&result); @@ -121,7 +120,6 @@ public: virtual bool run(OperationContext* opCtx, const string& badns, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { // IMPORTANT: Don't put anything in here that might lock db - including authentication return true; @@ -146,7 +144,6 @@ public: virtual bool run(OperationContext* opCtx, const string& ns, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { if (getGlobalScriptEngine()) { BSONObjBuilder bb(result.subobjStart("js")); @@ -188,7 +185,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { ProcessInfo p; BSONObjBuilder bSys, bOs; @@ -235,7 +231,6 @@ public: virtual bool run(OperationContext* opCtx, const string& ns, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { bool didRotate = rotateLogs(serverGlobalParams.logRenameOnRotate); if (didRotate) @@ -266,7 +261,6 @@ public: virtual bool run(OperationContext* opCtx, const string& ns, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { // sort the commands before building the result BSON std::vector commands; @@ -364,16 +358,15 @@ public: bool run(OperationContext* opCtx, const string& dbnamne, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { LastError::get(cc()).setLastError(10038, "forced error"); return false; } } cmdForceError; -class GetLogCmd : public BasicCommand { +class GetLogCmd : public ErrmsgCommandDeprecated { public: - GetLogCmd() : BasicCommand("getLog") {} + GetLogCmd() : ErrmsgCommandDeprecated("getLog") {} virtual bool slaveOk() const { return true; @@ -395,11 +388,11 @@ public: help << "{ getLog : '*' } OR { getLog : 'global' }"; } - virtual bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { BSONElement val = cmdObj.firstElement(); if (val.type() != String) { return appendCommandStatus( @@ -469,7 +462,6 @@ public: virtual bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { std::string logName; Status status = bsonExtractStringField(cmdObj, "clearLog", &logName); @@ -521,7 +513,6 @@ public: virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { result.append("argv", serverGlobalParams.argvArray); result.append("parsed", serverGlobalParams.parsedOpts); diff --git a/src/mongo/db/commands/geo_near_cmd.cpp b/src/mongo/db/commands/geo_near_cmd.cpp index c40625ed1c7..238f97eaa80 100644 --- a/src/mongo/db/commands/geo_near_cmd.cpp +++ b/src/mongo/db/commands/geo_near_cmd.cpp @@ -60,9 +60,9 @@ namespace mongo { using std::unique_ptr; using std::stringstream; -class Geo2dFindNearCmd : public BasicCommand { +class Geo2dFindNearCmd : public ErrmsgCommandDeprecated { public: - Geo2dFindNearCmd() : BasicCommand("geoNear") {} + Geo2dFindNearCmd() : ErrmsgCommandDeprecated("geoNear") {} virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; @@ -97,11 +97,11 @@ public: out->push_back(Privilege(parseResourcePattern(dbname, cmdObj), actions)); } - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { if (!cmdObj["start"].eoo()) { errmsg = "using deprecated 'start' argument to geoNear"; return false; diff --git a/src/mongo/db/commands/get_last_error.cpp b/src/mongo/db/commands/get_last_error.cpp index 80ebfb78e8e..536e1d18814 100644 --- a/src/mongo/db/commands/get_last_error.cpp +++ b/src/mongo/db/commands/get_last_error.cpp @@ -73,16 +73,15 @@ public: bool run(OperationContext* opCtx, const string& db, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { LastError::get(opCtx->getClient()).reset(); return true; } } cmdResetError; -class CmdGetLastError : public BasicCommand { +class CmdGetLastError : public ErrmsgCommandDeprecated { public: - CmdGetLastError() : BasicCommand("getLastError", "getlasterror") {} + CmdGetLastError() : ErrmsgCommandDeprecated("getLastError", "getlasterror") {} virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } @@ -103,11 +102,11 @@ public: << " { wtimeout:m} - timeout for w in m milliseconds"; } - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { // // Correct behavior here is very finicky. // @@ -314,7 +313,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { LastError* le = &LastError::get(opCtx->getClient()); le->disable(); diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp index 456799b070f..48b77395635 100644 --- a/src/mongo/db/commands/getmore_cmd.cpp +++ b/src/mongo/db/commands/getmore_cmd.cpp @@ -150,7 +150,6 @@ public: const NamespaceString& origNss, const GetMoreRequest& request, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { auto curOp = CurOp::get(opCtx); @@ -399,7 +398,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { // Counted as a getMore, not as a command. globalOpCounters.gotGetMore(); @@ -415,7 +413,7 @@ public: return appendCommandStatus(result, parsedRequest.getStatus()); } auto request = parsedRequest.getValue(); - return runParsed(opCtx, request.nss, request, cmdObj, errmsg, result); + return runParsed(opCtx, request.nss, request, cmdObj, result); } /** diff --git a/src/mongo/db/commands/group_cmd.cpp b/src/mongo/db/commands/group_cmd.cpp index 5aab82e6fd3..880030387c5 100644 --- a/src/mongo/db/commands/group_cmd.cpp +++ b/src/mongo/db/commands/group_cmd.cpp @@ -150,7 +150,6 @@ private: virtual bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { RARELY { warning() << "The group command is deprecated. See " diff --git a/src/mongo/db/commands/hashcmd.cpp b/src/mongo/db/commands/hashcmd.cpp index 78f76370b15..0b4ebdba718 100644 --- a/src/mongo/db/commands/hashcmd.cpp +++ b/src/mongo/db/commands/hashcmd.cpp @@ -50,9 +50,9 @@ using std::string; using std::stringstream; // Testing only, enabled via command-line. -class CmdHashElt : public BasicCommand { +class CmdHashElt : public ErrmsgCommandDeprecated { public: - CmdHashElt() : BasicCommand("_hashBSONElement"){}; + CmdHashElt() : ErrmsgCommandDeprecated("_hashBSONElement"){}; virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } @@ -79,11 +79,11 @@ public: *> "out" : NumberLong(6271151123721111923), *> "ok" : 1 } **/ - bool run(OperationContext* opCtx, - const string& db, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string& db, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { result.appendAs(cmdObj.firstElement(), "key"); int seed = 0; diff --git a/src/mongo/db/commands/haystack.cpp b/src/mongo/db/commands/haystack.cpp index d8f418b4ccb..be169c7ded3 100644 --- a/src/mongo/db/commands/haystack.cpp +++ b/src/mongo/db/commands/haystack.cpp @@ -59,9 +59,9 @@ namespace mongo { using std::string; using std::vector; -class GeoHaystackSearchCommand : public BasicCommand { +class GeoHaystackSearchCommand : public ErrmsgCommandDeprecated { public: - GeoHaystackSearchCommand() : BasicCommand("geoSearch") {} + GeoHaystackSearchCommand() : ErrmsgCommandDeprecated("geoSearch") {} virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; @@ -95,11 +95,11 @@ public: out->push_back(Privilege(parseResourcePattern(dbname, cmdObj), actions)); } - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { const NamespaceString nss = parseNsCollectionRequired(dbname, cmdObj); AutoGetCollectionForReadCommand ctx(opCtx, nss); diff --git a/src/mongo/db/commands/index_filter_commands.cpp b/src/mongo/db/commands/index_filter_commands.cpp index e1fdc732d2e..c7e3b2043bc 100644 --- a/src/mongo/db/commands/index_filter_commands.cpp +++ b/src/mongo/db/commands/index_filter_commands.cpp @@ -118,7 +118,6 @@ IndexFilterCommand::IndexFilterCommand(const string& name, const string& helpTex bool IndexFilterCommand::run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { const NamespaceString nss(parseNsCollectionRequired(dbname, cmdObj)); Status status = runIndexFilterCommand(opCtx, nss.ns(), cmdObj, &result); diff --git a/src/mongo/db/commands/index_filter_commands.h b/src/mongo/db/commands/index_filter_commands.h index 7cdf97c8205..6a313e1f93c 100644 --- a/src/mongo/db/commands/index_filter_commands.h +++ b/src/mongo/db/commands/index_filter_commands.h @@ -66,7 +66,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result); virtual bool supportsWriteConcern(const BSONObj& cmd) const override; diff --git a/src/mongo/db/commands/isself.cpp b/src/mongo/db/commands/isself.cpp index 6186dab0d8b..ed7605f14b7 100644 --- a/src/mongo/db/commands/isself.cpp +++ b/src/mongo/db/commands/isself.cpp @@ -57,7 +57,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { result.append("id", repl::instanceId); return true; diff --git a/src/mongo/db/commands/kill_op.cpp b/src/mongo/db/commands/kill_op.cpp index 5cd6b40d4ac..7b07c87f7ba 100644 --- a/src/mongo/db/commands/kill_op.cpp +++ b/src/mongo/db/commands/kill_op.cpp @@ -131,7 +131,6 @@ public: bool run(OperationContext* opCtx, const std::string& db, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) final { long long opId = parseOpId(cmdObj); diff --git a/src/mongo/db/commands/killcursors_common.cpp b/src/mongo/db/commands/killcursors_common.cpp index eaa9ec51baf..0dcc262f56f 100644 --- a/src/mongo/db/commands/killcursors_common.cpp +++ b/src/mongo/db/commands/killcursors_common.cpp @@ -66,7 +66,6 @@ Status KillCursorsCmdBase::checkAuthForCommand(Client* client, bool KillCursorsCmdBase::run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { auto statusWithRequest = KillCursorsRequest::parseFromBSON(dbname, cmdObj); if (!statusWithRequest.isOK()) { diff --git a/src/mongo/db/commands/killcursors_common.h b/src/mongo/db/commands/killcursors_common.h index 281a5be828e..43a0443ff80 100644 --- a/src/mongo/db/commands/killcursors_common.h +++ b/src/mongo/db/commands/killcursors_common.h @@ -74,7 +74,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) final; private: diff --git a/src/mongo/db/commands/list_collections.cpp b/src/mongo/db/commands/list_collections.cpp index ee972bc64e8..ca13ebffab2 100644 --- a/src/mongo/db/commands/list_collections.cpp +++ b/src/mongo/db/commands/list_collections.cpp @@ -232,7 +232,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& jsobj, - string& errmsg, BSONObjBuilder& result) { unique_ptr matcher; diff --git a/src/mongo/db/commands/list_databases.cpp b/src/mongo/db/commands/list_databases.cpp index fe24e9b8967..b25a13b887b 100644 --- a/src/mongo/db/commands/list_databases.cpp +++ b/src/mongo/db/commands/list_databases.cpp @@ -86,7 +86,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& jsobj, - string& errmsg, BSONObjBuilder& result) { // Parse the filter. std::unique_ptr filter; diff --git a/src/mongo/db/commands/list_indexes.cpp b/src/mongo/db/commands/list_indexes.cpp index 5502b9add2f..a050e9adfff 100644 --- a/src/mongo/db/commands/list_indexes.cpp +++ b/src/mongo/db/commands/list_indexes.cpp @@ -119,7 +119,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { const NamespaceString ns(parseNsOrUUID(opCtx, dbname, cmdObj)); const long long defaultBatchSize = std::numeric_limits::max(); diff --git a/src/mongo/db/commands/lock_info.cpp b/src/mongo/db/commands/lock_info.cpp index 4becb45fcc0..7273a5ff238 100644 --- a/src/mongo/db/commands/lock_info.cpp +++ b/src/mongo/db/commands/lock_info.cpp @@ -82,7 +82,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& jsobj, - string& errmsg, BSONObjBuilder& result) { std::map lockToClientMap; diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp index dcb694116a1..cdb8a757068 100644 --- a/src/mongo/db/commands/mr.cpp +++ b/src/mongo/db/commands/mr.cpp @@ -1325,9 +1325,9 @@ BSONObj _bailFromJS(const BSONObj& args, void* data) { /** * This class represents a map/reduce command executed on a single server */ -class MapReduceCommand : public BasicCommand { +class MapReduceCommand : public ErrmsgCommandDeprecated { public: - MapReduceCommand() : BasicCommand("mapReduce", "mapreduce") {} + MapReduceCommand() : ErrmsgCommandDeprecated("mapReduce", "mapreduce") {} virtual bool slaveOk() const { return repl::getGlobalReplicationCoordinator()->getReplicationMode() != @@ -1359,11 +1359,11 @@ public: addPrivilegesRequiredForMapReduce(this, dbname, cmdObj, out); } - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmd, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmd, + string& errmsg, + BSONObjBuilder& result) { Timer t; boost::optional maybeDisableValidation; @@ -1680,7 +1680,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { if (serverGlobalParams.clusterRole == ClusterRole::ConfigServer) { return appendCommandStatus( diff --git a/src/mongo/db/commands/oplog_note.cpp b/src/mongo/db/commands/oplog_note.cpp index d95301fb484..6802f4843c1 100644 --- a/src/mongo/db/commands/oplog_note.cpp +++ b/src/mongo/db/commands/oplog_note.cpp @@ -115,7 +115,6 @@ public: virtual bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { auto replCoord = repl::ReplicationCoordinator::get(opCtx); if (!replCoord->isReplEnabled()) { diff --git a/src/mongo/db/commands/parallel_collection_scan.cpp b/src/mongo/db/commands/parallel_collection_scan.cpp index debd6973295..cfee00e4888 100644 --- a/src/mongo/db/commands/parallel_collection_scan.cpp +++ b/src/mongo/db/commands/parallel_collection_scan.cpp @@ -88,7 +88,6 @@ public: virtual bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { const NamespaceString ns(parseNsOrUUID(opCtx, dbname, cmdObj)); diff --git a/src/mongo/db/commands/parameters.cpp b/src/mongo/db/commands/parameters.cpp index 79d2421553e..2c0164fdae9 100644 --- a/src/mongo/db/commands/parameters.cpp +++ b/src/mongo/db/commands/parameters.cpp @@ -63,9 +63,9 @@ void appendParameterNames(stringstream& help) { } } -class CmdGet : public BasicCommand { +class CmdGet : public ErrmsgCommandDeprecated { public: - CmdGet() : BasicCommand("getParameter") {} + CmdGet() : ErrmsgCommandDeprecated("getParameter") {} virtual bool slaveOk() const { return true; } @@ -88,11 +88,11 @@ public: appendParameterNames(help); help << "{ getParameter:'*' } to get everything\n"; } - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { bool all = *cmdObj.firstElement().valuestrsafe() == '*'; int before = result.len(); @@ -112,9 +112,9 @@ public: } } cmdGet; -class CmdSet : public BasicCommand { +class CmdSet : public ErrmsgCommandDeprecated { public: - CmdSet() : BasicCommand("setParameter") {} + CmdSet() : ErrmsgCommandDeprecated("setParameter") {} virtual bool slaveOk() const { return true; } @@ -136,11 +136,11 @@ public: help << "{ setParameter:1, : }\n"; appendParameterNames(help); } - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { int numSet = 0; bool found = false; diff --git a/src/mongo/db/commands/pipeline_command.cpp b/src/mongo/db/commands/pipeline_command.cpp index 651cb2c9c9d..9d0c83e7af9 100644 --- a/src/mongo/db/commands/pipeline_command.cpp +++ b/src/mongo/db/commands/pipeline_command.cpp @@ -83,7 +83,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { const auto aggregationRequest = uassertStatusOK(AggregationRequest::parseFromBSON(dbname, cmdObj, boost::none)); diff --git a/src/mongo/db/commands/plan_cache_commands.cpp b/src/mongo/db/commands/plan_cache_commands.cpp index 7f5e0209695..f66bc7392b2 100644 --- a/src/mongo/db/commands/plan_cache_commands.cpp +++ b/src/mongo/db/commands/plan_cache_commands.cpp @@ -113,7 +113,6 @@ PlanCacheCommand::PlanCacheCommand(const string& name, bool PlanCacheCommand::run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { const NamespaceString nss(parseNsCollectionRequired(dbname, cmdObj)); Status status = runPlanCacheCommand(opCtx, nss.ns(), cmdObj, &result); diff --git a/src/mongo/db/commands/plan_cache_commands.h b/src/mongo/db/commands/plan_cache_commands.h index 8312e12aa8c..da3400ca863 100644 --- a/src/mongo/db/commands/plan_cache_commands.h +++ b/src/mongo/db/commands/plan_cache_commands.h @@ -60,7 +60,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result); virtual bool supportsWriteConcern(const BSONObj& cmd) const override; diff --git a/src/mongo/db/commands/rename_collection_cmd.cpp b/src/mongo/db/commands/rename_collection_cmd.cpp index a5a54249d5a..0afd8e7dce6 100644 --- a/src/mongo/db/commands/rename_collection_cmd.cpp +++ b/src/mongo/db/commands/rename_collection_cmd.cpp @@ -56,9 +56,9 @@ using std::stringstream; namespace { -class CmdRenameCollection : public BasicCommand { +class CmdRenameCollection : public ErrmsgCommandDeprecated { public: - CmdRenameCollection() : BasicCommand("renameCollection") {} + CmdRenameCollection() : ErrmsgCommandDeprecated("renameCollection") {} virtual bool adminOnly() const { return true; } @@ -85,11 +85,11 @@ public: } } - virtual bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { const auto sourceNsElt = cmdObj[getName()]; const auto targetNsElt = cmdObj["to"]; diff --git a/src/mongo/db/commands/repair_cursor.cpp b/src/mongo/db/commands/repair_cursor.cpp index b1b2b7bd963..5154731e423 100644 --- a/src/mongo/db/commands/repair_cursor.cpp +++ b/src/mongo/db/commands/repair_cursor.cpp @@ -70,7 +70,6 @@ public: virtual bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { NamespaceString ns(parseNs(dbname, cmdObj)); diff --git a/src/mongo/db/commands/resize_oplog.cpp b/src/mongo/db/commands/resize_oplog.cpp index 7166d76c96f..3323cfc996c 100644 --- a/src/mongo/db/commands/resize_oplog.cpp +++ b/src/mongo/db/commands/resize_oplog.cpp @@ -84,7 +84,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& jsobj, - string& errmsg, BSONObjBuilder& result) { const NamespaceString nss("local", "oplog.rs"); Lock::GlobalWrite global(opCtx); diff --git a/src/mongo/db/commands/server_status.cpp b/src/mongo/db/commands/server_status.cpp index 8475560432c..1d559708d73 100644 --- a/src/mongo/db/commands/server_status.cpp +++ b/src/mongo/db/commands/server_status.cpp @@ -88,7 +88,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { _runCalled = true; 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 b8b4cca670e..002cf2d1bce 100644 --- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp +++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp @@ -85,7 +85,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { const auto version = uassertStatusOK( FeatureCompatibilityVersionCommandParser::extractVersionFromCommand(getName(), cmdObj)); diff --git a/src/mongo/db/commands/snapshot_management.cpp b/src/mongo/db/commands/snapshot_management.cpp index e9004704842..8fd1742a792 100644 --- a/src/mongo/db/commands/snapshot_management.cpp +++ b/src/mongo/db/commands/snapshot_management.cpp @@ -67,7 +67,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { auto snapshotManager = getGlobalServiceContext()->getGlobalStorageEngine()->getSnapshotManager(); @@ -116,7 +115,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { auto snapshotManager = getGlobalServiceContext()->getGlobalStorageEngine()->getSnapshotManager(); diff --git a/src/mongo/db/commands/test_commands.cpp b/src/mongo/db/commands/test_commands.cpp index ffc7bf48466..0b3d1e2091d 100644 --- a/src/mongo/db/commands/test_commands.cpp +++ b/src/mongo/db/commands/test_commands.cpp @@ -56,9 +56,9 @@ using std::string; using std::stringstream; /* For testing only, not for general use. Enabled via command-line */ -class GodInsert : public BasicCommand { +class GodInsert : public ErrmsgCommandDeprecated { public: - GodInsert() : BasicCommand("godinsert") {} + GodInsert() : ErrmsgCommandDeprecated("godinsert") {} virtual bool adminOnly() const { return false; } @@ -75,11 +75,11 @@ public: virtual void help(stringstream& help) const { help << "internal. for testing only."; } - virtual bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { const NamespaceString nss(parseNsCollectionRequired(dbname, cmdObj)); log() << "test only command godinsert invoked coll:" << nss.coll(); BSONObj obj = cmdObj["obj"].embeddedObjectUserCheck(); @@ -152,7 +152,6 @@ public: bool run(OperationContext* opCtx, const string& ns, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { log() << "test only command sleep invoked"; long long millis = 0; @@ -215,7 +214,6 @@ public: virtual bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { const NamespaceString fullNs = parseNsCollectionRequired(dbname, cmdObj); if (!fullNs.isValid()) { @@ -292,7 +290,6 @@ public: virtual bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { const NamespaceString nss = parseNsCollectionRequired(dbname, cmdObj); diff --git a/src/mongo/db/commands/top_command.cpp b/src/mongo/db/commands/top_command.cpp index afb1d3401f3..678bb86b320 100644 --- a/src/mongo/db/commands/top_command.cpp +++ b/src/mongo/db/commands/top_command.cpp @@ -68,7 +68,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& db, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { { BSONObjBuilder b(result.subobjStart("totals")); diff --git a/src/mongo/db/commands/touch.cpp b/src/mongo/db/commands/touch.cpp index 00bd08dbe50..fe7dd6b0cf5 100644 --- a/src/mongo/db/commands/touch.cpp +++ b/src/mongo/db/commands/touch.cpp @@ -53,7 +53,7 @@ namespace mongo { using std::string; using std::stringstream; -class TouchCmd : public BasicCommand { +class TouchCmd : public ErrmsgCommandDeprecated { public: virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; @@ -80,13 +80,13 @@ public: actions.addAction(ActionType::touch); out->push_back(Privilege(ResourcePattern::forClusterResource(), actions)); } - TouchCmd() : BasicCommand("touch") {} + TouchCmd() : ErrmsgCommandDeprecated("touch") {} - virtual bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { const NamespaceString nss = parseNsCollectionRequired(dbname, cmdObj); if (!nss.isNormal()) { errmsg = "bad namespace name"; diff --git a/src/mongo/db/commands/user_management_commands.cpp b/src/mongo/db/commands/user_management_commands.cpp index ecb54541df1..49926a76e53 100644 --- a/src/mongo/db/commands/user_management_commands.cpp +++ b/src/mongo/db/commands/user_management_commands.cpp @@ -619,7 +619,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { auth::CreateOrUpdateUserArgs args; Status status = auth::parseCreateOrUpdateUserCommands(cmdObj, "createUser", dbname, &args); @@ -765,7 +764,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { auth::CreateOrUpdateUserArgs args; Status status = auth::parseCreateOrUpdateUserCommands(cmdObj, "updateUser", dbname, &args); @@ -882,7 +880,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { UserName userName; Status status = auth::parseAndValidateDropUserCommand(cmdObj, dbname, &userName); @@ -950,7 +947,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { Status status = auth::parseAndValidateDropAllUsersFromDatabaseCommand(cmdObj, dbname); if (!status.isOK()) { @@ -1007,7 +1003,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { std::string userNameString; std::vector roles; @@ -1081,7 +1076,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { std::string userNameString; std::vector roles; @@ -1159,7 +1153,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { auth::UsersInfoArgs args; Status status = auth::parseUsersInfoCommand(cmdObj, dbname, &args); @@ -1272,7 +1265,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { auth::CreateOrUpdateRoleArgs args; Status status = auth::parseCreateOrUpdateRoleCommands(cmdObj, "createRole", dbname, &args); @@ -1385,7 +1377,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { auth::CreateOrUpdateRoleArgs args; Status status = auth::parseCreateOrUpdateRoleCommands(cmdObj, "updateRole", dbname, &args); @@ -1483,7 +1474,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { RoleName roleName; @@ -1591,7 +1581,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { RoleName roleName; PrivilegeVector privilegesToRemove; @@ -1701,7 +1690,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { std::string roleNameString; std::vector rolesToAdd; @@ -1792,7 +1780,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { std::string roleNameString; std::vector rolesToRemove; @@ -1882,7 +1869,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { RoleName roleName; Status status = auth::parseDropRoleCommand(cmdObj, dbname, &roleName); @@ -2036,7 +2022,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { Status status = auth::parseDropAllRolesFromDatabaseCommand(cmdObj, dbname); if (!status.isOK()) { @@ -2179,7 +2164,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { auth::RolesInfoArgs args; Status status = auth::parseRolesInfoCommand(cmdObj, dbname, &args); @@ -2260,7 +2244,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { AuthorizationManager* authzManager = getGlobalAuthorizationManager(); authzManager->invalidateUserCache(); @@ -2298,7 +2281,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { AuthorizationManager* authzManager = getGlobalAuthorizationManager(); result.append("cacheGeneration", authzManager->getCacheGeneration()); @@ -2675,7 +2657,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { auth::MergeAuthzCollectionsArgs args; Status status = auth::parseMergeAuthzCollectionsCommand(cmdObj, &args); @@ -2916,7 +2897,6 @@ public: virtual bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { auth::AuthSchemaUpgradeArgs parsedArgs; Status status = auth::parseAuthSchemaUpgradeCommand(cmdObj, dbname, &parsedArgs); diff --git a/src/mongo/db/commands/validate.cpp b/src/mongo/db/commands/validate.cpp index a4a5e98b888..b506104cb73 100644 --- a/src/mongo/db/commands/validate.cpp +++ b/src/mongo/db/commands/validate.cpp @@ -49,9 +49,9 @@ using std::stringstream; MONGO_FP_DECLARE(validateCmdCollectionNotValid); -class ValidateCmd : public BasicCommand { +class ValidateCmd : public ErrmsgCommandDeprecated { public: - ValidateCmd() : BasicCommand("validate") {} + ValidateCmd() : ErrmsgCommandDeprecated("validate") {} virtual bool slaveOk() const { return true; @@ -75,11 +75,11 @@ public: } //{ validate: "collectionnamewithoutthedbpart" [, scandata: ] [, full: } */ - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { if (MONGO_FAIL_POINT(validateCmdCollectionNotValid)) { errmsg = "validateCmdCollectionNotValid fail point was triggered"; result.appendBool("valid", false); diff --git a/src/mongo/db/exec/stagedebug_cmd.cpp b/src/mongo/db/exec/stagedebug_cmd.cpp index 256dcba59fb..c92408bcbf6 100644 --- a/src/mongo/db/exec/stagedebug_cmd.cpp +++ b/src/mongo/db/exec/stagedebug_cmd.cpp @@ -140,7 +140,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { BSONElement argElt = cmdObj["stageDebug"]; if (argElt.eoo() || !argElt.isABSONObj()) { @@ -479,7 +478,6 @@ public: // that can only be checked for equality. We ignore this now. Status s = fam->getSpec().getIndexPrefix(BSONObj(), ¶ms.indexPrefix); if (!s.isOK()) { - // errmsg = s.toString(); return NULL; } diff --git a/src/mongo/db/ftdc/ftdc_commands.cpp b/src/mongo/db/ftdc/ftdc_commands.cpp index 312c4204dd8..ba6d7c92af2 100644 --- a/src/mongo/db/ftdc/ftdc_commands.cpp +++ b/src/mongo/db/ftdc/ftdc_commands.cpp @@ -91,7 +91,6 @@ public: bool run(OperationContext* opCtx, const std::string& db, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { result.append( diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp index b6cea5fc57e..1567d6dc603 100644 --- a/src/mongo/db/repl/master_slave.cpp +++ b/src/mongo/db/repl/master_slave.cpp @@ -383,7 +383,6 @@ public: virtual bool run(OperationContext* opCtx, const string& ns, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { HandshakeArgs handshake; Status status = handshake.initialize(cmdObj); diff --git a/src/mongo/db/repl/repl_set_commands.cpp b/src/mongo/db/repl/repl_set_commands.cpp index 2c35b250c9a..3d966b8d1b1 100644 --- a/src/mongo/db/repl/repl_set_commands.cpp +++ b/src/mongo/db/repl/repl_set_commands.cpp @@ -97,7 +97,6 @@ public: virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { log() << "replSetTest command received: " << cmdObj.toString(); @@ -165,7 +164,6 @@ public: virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result); if (!status.isOK()) @@ -192,7 +190,6 @@ public: virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { if (cmdObj["forShell"].trueValue()) LastError::get(opCtx->getClient()).disable(); @@ -233,7 +230,6 @@ public: virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result); if (!status.isOK()) @@ -332,7 +328,6 @@ public: virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { BSONObj configObj; if (cmdObj["replSetInitiate"].type() == Object) { @@ -408,7 +403,6 @@ public: virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result); if (!status.isOK()) { @@ -416,7 +410,7 @@ public: } if (cmdObj["replSetReconfig"].type() != Object) { - errmsg = "no configuration specified"; + result.append("errmsg", "no configuration specified"); return false; } @@ -464,7 +458,6 @@ public: virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result); if (!status.isOK()) @@ -495,7 +488,6 @@ public: virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result); if (!status.isOK()) @@ -560,7 +552,6 @@ public: virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result); if (!status.isOK()) @@ -588,7 +579,6 @@ public: virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result); if (!status.isOK()) @@ -616,7 +606,6 @@ public: virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { auto replCoord = repl::ReplicationCoordinator::get(opCtx->getClient()->getServiceContext()); @@ -715,7 +704,6 @@ public: virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { MONGO_FAIL_POINT_BLOCK(rsDelayHeartbeatResponse, delay) { const BSONObj& data = delay.getData(); @@ -801,7 +789,6 @@ public: virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result); if (!status.isOK()) @@ -833,7 +820,6 @@ private: virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { DEV log() << "received elect msg " << cmdObj.toString(); else LOG(2) << "received elect msg " << cmdObj.toString(); @@ -866,7 +852,6 @@ public: virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result); if (!status.isOK()) @@ -902,7 +887,6 @@ public: virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) override { Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result); if (!status.isOK()) diff --git a/src/mongo/db/repl/repl_set_request_votes.cpp b/src/mongo/db/repl/repl_set_request_votes.cpp index 7914e8aed01..57bf4a9a537 100644 --- a/src/mongo/db/repl/repl_set_request_votes.cpp +++ b/src/mongo/db/repl/repl_set_request_votes.cpp @@ -50,7 +50,6 @@ private: bool run(OperationContext* opCtx, const std::string&, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) final { Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result); if (!status.isOK()) { diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp index 723c75c1b04..9717c56d921 100644 --- a/src/mongo/db/repl/replication_info.cpp +++ b/src/mongo/db/repl/replication_info.cpp @@ -234,7 +234,6 @@ public: virtual bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { /* currently request to arbiter is (somewhat arbitrarily) an ismaster request that is not authenticated. diff --git a/src/mongo/db/repl/resync.cpp b/src/mongo/db/repl/resync.cpp index 68f85a7af0e..c18c26bfd46 100644 --- a/src/mongo/db/repl/resync.cpp +++ b/src/mongo/db/repl/resync.cpp @@ -48,7 +48,7 @@ constexpr StringData kWaitFieldName = "wait"_sd; } // namespace // operator requested resynchronization of replication (on a slave or secondary). {resync: 1} -class CmdResync : public BasicCommand { +class CmdResync : public ErrmsgCommandDeprecated { public: virtual bool slaveOk() const { return true; @@ -71,12 +71,12 @@ public: h << "resync (from scratch) a stale slave or replica set secondary node.\n"; } - CmdResync() : BasicCommand(kResyncFieldName) {} - virtual bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + CmdResync() : ErrmsgCommandDeprecated(kResyncFieldName) {} + virtual bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { bool waitForResync = !cmdObj.hasField(kWaitFieldName) || cmdObj[kWaitFieldName].trueValue(); // Replica set resync. diff --git a/src/mongo/db/s/check_sharding_index_command.cpp b/src/mongo/db/s/check_sharding_index_command.cpp index 576bb7bbc72..f05e036d55c 100644 --- a/src/mongo/db/s/check_sharding_index_command.cpp +++ b/src/mongo/db/s/check_sharding_index_command.cpp @@ -54,9 +54,9 @@ namespace dps = ::mongo::dotted_path_support; namespace { -class CheckShardingIndex : public BasicCommand { +class CheckShardingIndex : public ErrmsgCommandDeprecated { public: - CheckShardingIndex() : BasicCommand("checkShardingIndex") {} + CheckShardingIndex() : ErrmsgCommandDeprecated("checkShardingIndex") {} virtual void help(std::stringstream& help) const { help << "Internal command.\n"; @@ -82,11 +82,11 @@ public: return parseNsFullyQualified(dbname, cmdObj); } - bool run(OperationContext* opCtx, - const std::string& dbname, - const BSONObj& jsobj, - std::string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const std::string& dbname, + const BSONObj& jsobj, + std::string& errmsg, + BSONObjBuilder& result) { const NamespaceString nss = NamespaceString(parseNs(dbname, jsobj)); BSONObj keyPattern = jsobj.getObjectField("keyPattern"); diff --git a/src/mongo/db/s/cleanup_orphaned_cmd.cpp b/src/mongo/db/s/cleanup_orphaned_cmd.cpp index a7af78a64f8..c5b1582a7d3 100644 --- a/src/mongo/db/s/cleanup_orphaned_cmd.cpp +++ b/src/mongo/db/s/cleanup_orphaned_cmd.cpp @@ -168,9 +168,9 @@ CleanupResult cleanupOrphanedData(OperationContext* opCtx, * writeConcern: { } * } */ -class CleanupOrphanedCommand : public BasicCommand { +class CleanupOrphanedCommand : public ErrmsgCommandDeprecated { public: - CleanupOrphanedCommand() : BasicCommand("cleanupOrphaned") {} + CleanupOrphanedCommand() : ErrmsgCommandDeprecated("cleanupOrphaned") {} virtual bool slaveOk() const { return false; @@ -203,11 +203,11 @@ public: // Output static BSONField stoppedAtKeyField; - bool run(OperationContext* opCtx, - string const& db, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + string const& db, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { string ns; if (!FieldParser::extract(cmdObj, nsField, &ns, &errmsg)) { return false; diff --git a/src/mongo/db/s/config/configsvr_add_shard_command.cpp b/src/mongo/db/s/config/configsvr_add_shard_command.cpp index 6459347f185..e568ccb0a89 100644 --- a/src/mongo/db/s/config/configsvr_add_shard_command.cpp +++ b/src/mongo/db/s/config/configsvr_add_shard_command.cpp @@ -89,7 +89,6 @@ public: bool run(OperationContext* opCtx, const std::string& unusedDbName, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { if (serverGlobalParams.clusterRole != ClusterRole::ConfigServer) { return appendCommandStatus( diff --git a/src/mongo/db/s/config/configsvr_add_shard_to_zone_command.cpp b/src/mongo/db/s/config/configsvr_add_shard_to_zone_command.cpp index d5bbc204458..50d0779737f 100644 --- a/src/mongo/db/s/config/configsvr_add_shard_to_zone_command.cpp +++ b/src/mongo/db/s/config/configsvr_add_shard_to_zone_command.cpp @@ -90,7 +90,6 @@ public: bool run(OperationContext* opCtx, const std::string& unusedDbName, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { if (serverGlobalParams.clusterRole != ClusterRole::ConfigServer) { uasserted(ErrorCodes::IllegalOperation, diff --git a/src/mongo/db/s/config/configsvr_commit_chunk_migration_command.cpp b/src/mongo/db/s/config/configsvr_commit_chunk_migration_command.cpp index 7cdb5a8522b..4581f2d9b9e 100644 --- a/src/mongo/db/s/config/configsvr_commit_chunk_migration_command.cpp +++ b/src/mongo/db/s/config/configsvr_commit_chunk_migration_command.cpp @@ -120,7 +120,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbName, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { const NamespaceString nss = NamespaceString(parseNs(dbName, cmdObj)); diff --git a/src/mongo/db/s/config/configsvr_control_balancer_command.cpp b/src/mongo/db/s/config/configsvr_control_balancer_command.cpp index 01b348367a9..f264d07b821 100644 --- a/src/mongo/db/s/config/configsvr_control_balancer_command.cpp +++ b/src/mongo/db/s/config/configsvr_control_balancer_command.cpp @@ -75,7 +75,6 @@ public: bool run(OperationContext* opCtx, const std::string& unusedDbName, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) final { uassert(ErrorCodes::InternalError, str::stream() << "Expected to find a " << getName() << " command, but found " diff --git a/src/mongo/db/s/config/configsvr_merge_chunk_command.cpp b/src/mongo/db/s/config/configsvr_merge_chunk_command.cpp index c9b92fc8160..5dbc9401d58 100644 --- a/src/mongo/db/s/config/configsvr_merge_chunk_command.cpp +++ b/src/mongo/db/s/config/configsvr_merge_chunk_command.cpp @@ -101,7 +101,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbName, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { if (serverGlobalParams.clusterRole != ClusterRole::ConfigServer) { uasserted(ErrorCodes::IllegalOperation, diff --git a/src/mongo/db/s/config/configsvr_move_chunk_command.cpp b/src/mongo/db/s/config/configsvr_move_chunk_command.cpp index 9ebc98537a0..7156a604fd5 100644 --- a/src/mongo/db/s/config/configsvr_move_chunk_command.cpp +++ b/src/mongo/db/s/config/configsvr_move_chunk_command.cpp @@ -81,7 +81,6 @@ public: bool run(OperationContext* opCtx, const std::string& unusedDbName, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { auto request = uassertStatusOK(BalanceChunkRequest::parseFromConfigCommand(cmdObj)); diff --git a/src/mongo/db/s/config/configsvr_move_primary_command.cpp b/src/mongo/db/s/config/configsvr_move_primary_command.cpp index d663c4d56e0..227c6b05bc5 100644 --- a/src/mongo/db/s/config/configsvr_move_primary_command.cpp +++ b/src/mongo/db/s/config/configsvr_move_primary_command.cpp @@ -101,8 +101,7 @@ public: bool run(OperationContext* opCtx, const std::string& dbname_unused, const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& result) { + BSONObjBuilder& result) override { if (serverGlobalParams.clusterRole != ClusterRole::ConfigServer) { return appendCommandStatus( diff --git a/src/mongo/db/s/config/configsvr_remove_shard_from_zone_command.cpp b/src/mongo/db/s/config/configsvr_remove_shard_from_zone_command.cpp index e053985255a..7ca7c14ebbd 100644 --- a/src/mongo/db/s/config/configsvr_remove_shard_from_zone_command.cpp +++ b/src/mongo/db/s/config/configsvr_remove_shard_from_zone_command.cpp @@ -90,7 +90,6 @@ public: bool run(OperationContext* opCtx, const std::string& unusedDbName, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { if (serverGlobalParams.clusterRole != ClusterRole::ConfigServer) { uasserted(ErrorCodes::IllegalOperation, diff --git a/src/mongo/db/s/config/configsvr_set_feature_compatibility_version_command.cpp b/src/mongo/db/s/config/configsvr_set_feature_compatibility_version_command.cpp index 021f19d62e5..233f5678bca 100644 --- a/src/mongo/db/s/config/configsvr_set_feature_compatibility_version_command.cpp +++ b/src/mongo/db/s/config/configsvr_set_feature_compatibility_version_command.cpp @@ -94,7 +94,6 @@ public: bool run(OperationContext* opCtx, const std::string& unusedDbName, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { const auto version = uassertStatusOK( FeatureCompatibilityVersionCommandParser::extractVersionFromCommand(getName(), cmdObj)); diff --git a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp index 4bf43a0635b..44eb62c753b 100644 --- a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp +++ b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp @@ -163,7 +163,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { uassert(ErrorCodes::IllegalOperation, diff --git a/src/mongo/db/s/config/configsvr_split_chunk_command.cpp b/src/mongo/db/s/config/configsvr_split_chunk_command.cpp index acfd59c1cf2..10cc59c6d4c 100644 --- a/src/mongo/db/s/config/configsvr_split_chunk_command.cpp +++ b/src/mongo/db/s/config/configsvr_split_chunk_command.cpp @@ -99,7 +99,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbName, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { if (serverGlobalParams.clusterRole != ClusterRole::ConfigServer) { uasserted(ErrorCodes::IllegalOperation, diff --git a/src/mongo/db/s/config/configsvr_update_zone_key_range_command.cpp b/src/mongo/db/s/config/configsvr_update_zone_key_range_command.cpp index 488e432f2eb..f41ce235507 100644 --- a/src/mongo/db/s/config/configsvr_update_zone_key_range_command.cpp +++ b/src/mongo/db/s/config/configsvr_update_zone_key_range_command.cpp @@ -92,7 +92,6 @@ public: bool run(OperationContext* opCtx, const std::string& unusedDbName, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { if (serverGlobalParams.clusterRole != ClusterRole::ConfigServer) { uasserted(ErrorCodes::IllegalOperation, diff --git a/src/mongo/db/s/force_routing_table_refresh_command.cpp b/src/mongo/db/s/force_routing_table_refresh_command.cpp index b863fa677b8..6d144041702 100644 --- a/src/mongo/db/s/force_routing_table_refresh_command.cpp +++ b/src/mongo/db/s/force_routing_table_refresh_command.cpp @@ -107,7 +107,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { auto shardingState = ShardingState::get(opCtx); uassertStatusOK(shardingState->canAcceptShardedCommands()); diff --git a/src/mongo/db/s/get_shard_version_command.cpp b/src/mongo/db/s/get_shard_version_command.cpp index 7808b08005a..f400d9f31bc 100644 --- a/src/mongo/db/s/get_shard_version_command.cpp +++ b/src/mongo/db/s/get_shard_version_command.cpp @@ -85,7 +85,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { const NamespaceString nss(parseNs(dbname, cmdObj)); uassert(ErrorCodes::InvalidNamespace, diff --git a/src/mongo/db/s/merge_chunks_command.cpp b/src/mongo/db/s/merge_chunks_command.cpp index 13286839627..211ae01117c 100644 --- a/src/mongo/db/s/merge_chunks_command.cpp +++ b/src/mongo/db/s/merge_chunks_command.cpp @@ -319,9 +319,9 @@ Status mergeChunks(OperationContext* opCtx, return Status::OK(); } -class MergeChunksCommand : public BasicCommand { +class MergeChunksCommand : public ErrmsgCommandDeprecated { public: - MergeChunksCommand() : BasicCommand("mergeChunks") {} + MergeChunksCommand() : ErrmsgCommandDeprecated("mergeChunks") {} void help(stringstream& h) const override { h << "Merge Chunks command\n" @@ -361,11 +361,11 @@ public: // Optional, if the merge is only valid for a particular epoch static BSONField epochField; - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) override { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) override { uassertStatusOK(ShardingState::get(opCtx)->canAcceptShardedCommands()); string ns = parseNs(dbname, cmdObj); diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp b/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp index 5ccadd3f724..9e3e83774ee 100644 --- a/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp +++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp @@ -142,7 +142,6 @@ public: bool run(OperationContext* opCtx, const std::string&, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { const MigrationSessionId migrationSessionId( uassertStatusOK(MigrationSessionId::extractFromBSON(cmdObj))); @@ -205,7 +204,6 @@ public: bool run(OperationContext* opCtx, const std::string&, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { const MigrationSessionId migrationSessionId( uassertStatusOK(MigrationSessionId::extractFromBSON(cmdObj))); diff --git a/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp b/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp index 5bbd09cdddb..d7d1a351973 100644 --- a/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp +++ b/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp @@ -55,9 +55,9 @@ using std::string; namespace { -class RecvChunkStartCommand : public BasicCommand { +class RecvChunkStartCommand : public ErrmsgCommandDeprecated { public: - RecvChunkStartCommand() : BasicCommand("_recvChunkStart") {} + RecvChunkStartCommand() : ErrmsgCommandDeprecated("_recvChunkStart") {} void help(std::stringstream& h) const { h << "internal"; @@ -84,11 +84,11 @@ public: out->push_back(Privilege(ResourcePattern::forClusterResource(), actions)); } - bool run(OperationContext* opCtx, - const string&, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const string&, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { auto shardingState = ShardingState::get(opCtx); uassertStatusOK(shardingState->canAcceptShardedCommands()); @@ -187,7 +187,6 @@ public: bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { ShardingState::get(opCtx)->migrationDestinationManager()->report(result); return true; @@ -227,7 +226,6 @@ public: bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { auto const sessionId = uassertStatusOK(MigrationSessionId::extractFromBSON(cmdObj)); auto mdm = ShardingState::get(opCtx)->migrationDestinationManager(); @@ -274,7 +272,6 @@ public: bool run(OperationContext* opCtx, const string&, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { auto const mdm = ShardingState::get(opCtx)->migrationDestinationManager(); diff --git a/src/mongo/db/s/move_chunk_command.cpp b/src/mongo/db/s/move_chunk_command.cpp index b7d52f5058e..eb14fb36943 100644 --- a/src/mongo/db/s/move_chunk_command.cpp +++ b/src/mongo/db/s/move_chunk_command.cpp @@ -116,7 +116,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) override { auto shardingState = ShardingState::get(opCtx); uassertStatusOK(shardingState->canAcceptShardedCommands()); diff --git a/src/mongo/db/s/set_shard_version_command.cpp b/src/mongo/db/s/set_shard_version_command.cpp index 56675280e5f..c1af7de81b0 100644 --- a/src/mongo/db/s/set_shard_version_command.cpp +++ b/src/mongo/db/s/set_shard_version_command.cpp @@ -60,9 +60,9 @@ using str::stream; namespace { -class SetShardVersion : public BasicCommand { +class SetShardVersion : public ErrmsgCommandDeprecated { public: - SetShardVersion() : BasicCommand("setShardVersion") {} + SetShardVersion() : ErrmsgCommandDeprecated("setShardVersion") {} void help(std::stringstream& help) const override { help << "internal"; @@ -88,11 +88,11 @@ public: out->push_back(Privilege(ResourcePattern::forClusterResource(), actions)); } - bool run(OperationContext* opCtx, - const std::string&, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) { + bool errmsgRun(OperationContext* opCtx, + const std::string&, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) { uassert(ErrorCodes::IllegalOperation, "can't issue setShardVersion from 'eval'", !opCtx->getClient()->isInDirectClient()); diff --git a/src/mongo/db/s/sharding_state_command.cpp b/src/mongo/db/s/sharding_state_command.cpp index 8bb4e5fc8b3..4a2e546ac76 100644 --- a/src/mongo/db/s/sharding_state_command.cpp +++ b/src/mongo/db/s/sharding_state_command.cpp @@ -70,7 +70,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { ShardingState::get(opCtx)->appendInfo(opCtx, result); return true; diff --git a/src/mongo/db/s/split_chunk_command.cpp b/src/mongo/db/s/split_chunk_command.cpp index 2830a77915d..cc3b5dba493 100644 --- a/src/mongo/db/s/split_chunk_command.cpp +++ b/src/mongo/db/s/split_chunk_command.cpp @@ -130,9 +130,9 @@ bool _checkMetadataForSuccess(OperationContext* opCtx, return true; } -class SplitChunkCommand : public BasicCommand { +class SplitChunkCommand : public ErrmsgCommandDeprecated { public: - SplitChunkCommand() : BasicCommand("splitChunk") {} + SplitChunkCommand() : ErrmsgCommandDeprecated("splitChunk") {} void help(std::stringstream& help) const override { help << "internal command usage only\n" @@ -167,11 +167,11 @@ public: return parseNsFullyQualified(dbname, cmdObj); } - bool run(OperationContext* opCtx, - const std::string& dbname, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& result) override { + bool errmsgRun(OperationContext* opCtx, + const std::string& dbname, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& result) override { auto shardingState = ShardingState::get(opCtx); uassertStatusOK(shardingState->canAcceptShardedCommands()); diff --git a/src/mongo/db/s/split_vector_command.cpp b/src/mongo/db/s/split_vector_command.cpp index a01287bf773..3b2581c5093 100644 --- a/src/mongo/db/s/split_vector_command.cpp +++ b/src/mongo/db/s/split_vector_command.cpp @@ -69,9 +69,9 @@ BSONObj prettyKey(const BSONObj& keyPattern, const BSONObj& key) { return key.replaceFieldNames(keyPattern).clientReadable(); } -class SplitVector : public BasicCommand { +class SplitVector : public ErrmsgCommandDeprecated { public: - SplitVector() : BasicCommand("splitVector") {} + SplitVector() : ErrmsgCommandDeprecated("splitVector") {} bool supportsWriteConcern(const BSONObj& cmd) const override { return false; @@ -111,11 +111,11 @@ public: return parseNsFullyQualified(dbname, cmdObj); } - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& jsobj, - string& errmsg, - BSONObjBuilder& result) override { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& jsobj, + string& errmsg, + BSONObjBuilder& result) override { // // 1.a We'll parse the parameters in two steps. First, make sure the we can use the split // index to get a good approximation of the size of the chunk -- without needing to diff --git a/src/mongo/db/s/unset_sharding_command.cpp b/src/mongo/db/s/unset_sharding_command.cpp index 18bf30403a5..81c6bb6c638 100644 --- a/src/mongo/db/s/unset_sharding_command.cpp +++ b/src/mongo/db/s/unset_sharding_command.cpp @@ -75,7 +75,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { ShardedConnectionInfo::reset(opCtx->getClient()); return true; diff --git a/src/mongo/db/storage/mmap_v1/journal_latency_test_cmd.cpp b/src/mongo/db/storage/mmap_v1/journal_latency_test_cmd.cpp index 828b5d44abd..6a94fc2d0b1 100644 --- a/src/mongo/db/storage/mmap_v1/journal_latency_test_cmd.cpp +++ b/src/mongo/db/storage/mmap_v1/journal_latency_test_cmd.cpp @@ -87,7 +87,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { boost::filesystem::path p = dur::getJournalDir(); p /= "journalLatencyTest"; diff --git a/src/mongo/s/client/shard_connection.cpp b/src/mongo/s/client/shard_connection.cpp index 274857ec995..940b88522ae 100644 --- a/src/mongo/s/client/shard_connection.cpp +++ b/src/mongo/s/client/shard_connection.cpp @@ -114,7 +114,6 @@ public: virtual bool run(OperationContext* opCtx, const string& dbname, const mongo::BSONObj& cmdObj, - std::string& errmsg, mongo::BSONObjBuilder& result) { // Connection information executor::ConnectionPoolStats stats{}; diff --git a/src/mongo/s/commands/cluster_add_shard_cmd.cpp b/src/mongo/s/commands/cluster_add_shard_cmd.cpp index 6b6ed92ae98..458e5a40f76 100644 --- a/src/mongo/s/commands/cluster_add_shard_cmd.cpp +++ b/src/mongo/s/commands/cluster_add_shard_cmd.cpp @@ -83,7 +83,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { auto parsedRequest = uassertStatusOK(AddShardRequest::parseFromMongosCommand(cmdObj)); diff --git a/src/mongo/s/commands/cluster_add_shard_to_zone_cmd.cpp b/src/mongo/s/commands/cluster_add_shard_to_zone_cmd.cpp index e16b79b3c67..d05c086d75a 100644 --- a/src/mongo/s/commands/cluster_add_shard_to_zone_cmd.cpp +++ b/src/mongo/s/commands/cluster_add_shard_to_zone_cmd.cpp @@ -99,7 +99,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { auto parsedRequest = uassertStatusOK(AddShardToZoneRequest::parseFromMongosCommand(cmdObj)); diff --git a/src/mongo/s/commands/cluster_apply_ops_cmd.cpp b/src/mongo/s/commands/cluster_apply_ops_cmd.cpp index 62c88d41e8c..f2f67b37c3a 100644 --- a/src/mongo/s/commands/cluster_apply_ops_cmd.cpp +++ b/src/mongo/s/commands/cluster_apply_ops_cmd.cpp @@ -59,7 +59,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbName, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { uasserted(ErrorCodes::CommandNotSupported, "applyOps not allowed through mongos"); } diff --git a/src/mongo/s/commands/cluster_available_query_options_cmd.cpp b/src/mongo/s/commands/cluster_available_query_options_cmd.cpp index c0851ba1d22..d209c2ace34 100644 --- a/src/mongo/s/commands/cluster_available_query_options_cmd.cpp +++ b/src/mongo/s/commands/cluster_available_query_options_cmd.cpp @@ -56,7 +56,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { result << "options" << QueryOption_AllSupportedForSharding; return true; diff --git a/src/mongo/s/commands/cluster_compact_cmd.cpp b/src/mongo/s/commands/cluster_compact_cmd.cpp index c668bc3152d..3d933804c49 100644 --- a/src/mongo/s/commands/cluster_compact_cmd.cpp +++ b/src/mongo/s/commands/cluster_compact_cmd.cpp @@ -60,7 +60,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbName, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { uasserted(ErrorCodes::CommandNotSupported, "compact not allowed through mongos"); } diff --git a/src/mongo/s/commands/cluster_control_balancer_cmd.cpp b/src/mongo/s/commands/cluster_control_balancer_cmd.cpp index 6df5d8c5ebe..65d955efc8f 100644 --- a/src/mongo/s/commands/cluster_control_balancer_cmd.cpp +++ b/src/mongo/s/commands/cluster_control_balancer_cmd.cpp @@ -80,7 +80,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard(); auto cmdResponse = uassertStatusOK( diff --git a/src/mongo/s/commands/cluster_count_cmd.cpp b/src/mongo/s/commands/cluster_count_cmd.cpp index d90f3156e36..107f006d789 100644 --- a/src/mongo/s/commands/cluster_count_cmd.cpp +++ b/src/mongo/s/commands/cluster_count_cmd.cpp @@ -47,9 +47,9 @@ namespace mongo { namespace { -class ClusterCountCmd : public BasicCommand { +class ClusterCountCmd : public ErrmsgCommandDeprecated { public: - ClusterCountCmd() : BasicCommand("count") {} + ClusterCountCmd() : ErrmsgCommandDeprecated("count") {} bool slaveOk() const override { return true; @@ -71,11 +71,11 @@ public: out->push_back(Privilege(parseResourcePattern(dbname, cmdObj), actions)); } - bool run(OperationContext* opCtx, - const std::string& dbname, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& result) override { + bool errmsgRun(OperationContext* opCtx, + const std::string& dbname, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& result) override { const NamespaceString nss(parseNs(dbname, cmdObj)); uassert(ErrorCodes::InvalidNamespace, str::stream() << "Invalid namespace specified '" << nss.ns() << "'", diff --git a/src/mongo/s/commands/cluster_db_stats_cmd.cpp b/src/mongo/s/commands/cluster_db_stats_cmd.cpp index 1da192120c5..abb1e5810f7 100644 --- a/src/mongo/s/commands/cluster_db_stats_cmd.cpp +++ b/src/mongo/s/commands/cluster_db_stats_cmd.cpp @@ -40,9 +40,9 @@ namespace { using std::vector; -class DBStatsCmd : public BasicCommand { +class DBStatsCmd : public ErrmsgCommandDeprecated { public: - DBStatsCmd() : BasicCommand("dbStats", "dbstats") {} + DBStatsCmd() : ErrmsgCommandDeprecated("dbStats", "dbstats") {} bool slaveOk() const override { return true; @@ -63,11 +63,11 @@ public: return false; } - bool run(OperationContext* opCtx, - const std::string& dbName, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& output) override { + bool errmsgRun(OperationContext* opCtx, + const std::string& dbName, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& output) override { auto shardResponses = uassertStatusOK(scatterGather(opCtx, dbName, diff --git a/src/mongo/s/commands/cluster_drop_cmd.cpp b/src/mongo/s/commands/cluster_drop_cmd.cpp index 61579466220..109ba3f2458 100644 --- a/src/mongo/s/commands/cluster_drop_cmd.cpp +++ b/src/mongo/s/commands/cluster_drop_cmd.cpp @@ -73,7 +73,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { const NamespaceString nss(parseNsCollectionRequired(dbname, cmdObj)); diff --git a/src/mongo/s/commands/cluster_drop_database_cmd.cpp b/src/mongo/s/commands/cluster_drop_database_cmd.cpp index 26ed92309f0..dd46027ef37 100644 --- a/src/mongo/s/commands/cluster_drop_database_cmd.cpp +++ b/src/mongo/s/commands/cluster_drop_database_cmd.cpp @@ -72,7 +72,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { uassert(ErrorCodes::IllegalOperation, "Cannot drop the config database", diff --git a/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp b/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp index d6fbfb44381..d7fa8e95ed1 100644 --- a/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp +++ b/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp @@ -47,9 +47,9 @@ namespace mongo { namespace { -class EnableShardingCmd : public BasicCommand { +class EnableShardingCmd : public ErrmsgCommandDeprecated { public: - EnableShardingCmd() : BasicCommand("enableSharding", "enablesharding") {} + EnableShardingCmd() : ErrmsgCommandDeprecated("enableSharding", "enablesharding") {} virtual bool slaveOk() const { return true; @@ -86,11 +86,11 @@ public: return cmdObj.firstElement().str(); } - virtual bool run(OperationContext* opCtx, - const std::string& dbname_unused, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const std::string& dbname_unused, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& result) { const std::string dbname = parseNs("", cmdObj); uassert( diff --git a/src/mongo/s/commands/cluster_explain_cmd.cpp b/src/mongo/s/commands/cluster_explain_cmd.cpp index 547a8b33e74..6397a2d3f07 100644 --- a/src/mongo/s/commands/cluster_explain_cmd.cpp +++ b/src/mongo/s/commands/cluster_explain_cmd.cpp @@ -108,7 +108,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbName, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { auto verbosity = ExplainOptions::parseCmdBSON(cmdObj); if (!verbosity.isOK()) { diff --git a/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp b/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp index 3ce88868f6b..c56599ad383 100644 --- a/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp +++ b/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp @@ -156,7 +156,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbName, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { const NamespaceString nss = parseNsCollectionRequired(dbName, cmdObj); diff --git a/src/mongo/s/commands/cluster_find_cmd.cpp b/src/mongo/s/commands/cluster_find_cmd.cpp index 9e5cb80138d..381638eca5b 100644 --- a/src/mongo/s/commands/cluster_find_cmd.cpp +++ b/src/mongo/s/commands/cluster_find_cmd.cpp @@ -152,7 +152,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) final { // We count find command as a query op. globalOpCounters.gotQuery(); diff --git a/src/mongo/s/commands/cluster_flush_router_config_cmd.cpp b/src/mongo/s/commands/cluster_flush_router_config_cmd.cpp index 40522351d6b..89717969365 100644 --- a/src/mongo/s/commands/cluster_flush_router_config_cmd.cpp +++ b/src/mongo/s/commands/cluster_flush_router_config_cmd.cpp @@ -67,7 +67,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { Grid::get(opCtx)->catalogCache()->purgeAllDatabases(); diff --git a/src/mongo/s/commands/cluster_fsync_cmd.cpp b/src/mongo/s/commands/cluster_fsync_cmd.cpp index 9928576cc89..691b6c41caf 100644 --- a/src/mongo/s/commands/cluster_fsync_cmd.cpp +++ b/src/mongo/s/commands/cluster_fsync_cmd.cpp @@ -38,9 +38,9 @@ namespace mongo { namespace { -class FsyncCommand : public BasicCommand { +class FsyncCommand : public ErrmsgCommandDeprecated { public: - FsyncCommand() : BasicCommand("fsync", "fsync") {} + FsyncCommand() : ErrmsgCommandDeprecated("fsync", "fsync") {} virtual bool slaveOk() const { return true; @@ -67,11 +67,11 @@ public: out->push_back(Privilege(ResourcePattern::forClusterResource(), actions)); } - virtual bool run(OperationContext* opCtx, - const std::string& dbname, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const std::string& dbname, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& result) { if (cmdObj["lock"].trueValue()) { errmsg = "can't do lock through mongos"; return false; diff --git a/src/mongo/s/commands/cluster_ftdc_commands.cpp b/src/mongo/s/commands/cluster_ftdc_commands.cpp index d87f5529fdc..14b087d446f 100644 --- a/src/mongo/s/commands/cluster_ftdc_commands.cpp +++ b/src/mongo/s/commands/cluster_ftdc_commands.cpp @@ -44,9 +44,9 @@ namespace { * getDiagnosticData is a MongoD only command. We implement in MongoS to give users a better error * message. */ -class GetDiagnosticDataCommand final : public BasicCommand { +class GetDiagnosticDataCommand final : public ErrmsgCommandDeprecated { public: - GetDiagnosticDataCommand() : BasicCommand("getDiagnosticData") {} + GetDiagnosticDataCommand() : ErrmsgCommandDeprecated("getDiagnosticData") {} bool adminOnly() const override { return true; @@ -92,11 +92,11 @@ public: return Status::OK(); } - bool run(OperationContext* opCtx, - const std::string& db, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& result) override { + bool errmsgRun(OperationContext* opCtx, + const std::string& db, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& result) override { result.append( "data", diff --git a/src/mongo/s/commands/cluster_get_last_error_cmd.cpp b/src/mongo/s/commands/cluster_get_last_error_cmd.cpp index 8633618dd4c..e8ea9c593de 100644 --- a/src/mongo/s/commands/cluster_get_last_error_cmd.cpp +++ b/src/mongo/s/commands/cluster_get_last_error_cmd.cpp @@ -209,7 +209,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { // Mongos GLE - finicky. // diff --git a/src/mongo/s/commands/cluster_get_prev_error_cmd.cpp b/src/mongo/s/commands/cluster_get_prev_error_cmd.cpp index 0dd37af4ae4..3d4ed9a44ca 100644 --- a/src/mongo/s/commands/cluster_get_prev_error_cmd.cpp +++ b/src/mongo/s/commands/cluster_get_prev_error_cmd.cpp @@ -38,9 +38,9 @@ namespace mongo { namespace { -class GetPrevErrorCmd : public BasicCommand { +class GetPrevErrorCmd : public ErrmsgCommandDeprecated { public: - GetPrevErrorCmd() : BasicCommand("getPrevError", "getpreverror") {} + GetPrevErrorCmd() : ErrmsgCommandDeprecated("getPrevError", "getpreverror") {} virtual bool supportsWriteConcern(const BSONObj& cmd) const override { @@ -61,11 +61,11 @@ public: // No auth required } - virtual bool run(OperationContext* opCtx, - const std::string& dbname, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const std::string& dbname, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& result) { errmsg += "getpreverror not supported for sharded environments"; return false; } diff --git a/src/mongo/s/commands/cluster_get_shard_map_cmd.cpp b/src/mongo/s/commands/cluster_get_shard_map_cmd.cpp index 37f63803f1a..b264f000479 100644 --- a/src/mongo/s/commands/cluster_get_shard_map_cmd.cpp +++ b/src/mongo/s/commands/cluster_get_shard_map_cmd.cpp @@ -70,7 +70,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { // MongoD instances do not know that they are part of a sharded cluster until they // receive a setShardVersion command and that's when the catalog manager and the shard diff --git a/src/mongo/s/commands/cluster_get_shard_version_cmd.cpp b/src/mongo/s/commands/cluster_get_shard_version_cmd.cpp index f7ea6c50c70..6758342d307 100644 --- a/src/mongo/s/commands/cluster_get_shard_version_cmd.cpp +++ b/src/mongo/s/commands/cluster_get_shard_version_cmd.cpp @@ -82,7 +82,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { const NamespaceString nss(parseNs(dbname, cmdObj)); diff --git a/src/mongo/s/commands/cluster_getmore_cmd.cpp b/src/mongo/s/commands/cluster_getmore_cmd.cpp index 664d4ade18a..dcf15e263ac 100644 --- a/src/mongo/s/commands/cluster_getmore_cmd.cpp +++ b/src/mongo/s/commands/cluster_getmore_cmd.cpp @@ -94,7 +94,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) final { // Counted as a getMore, not as a command. globalOpCounters.gotGetMore(); diff --git a/src/mongo/s/commands/cluster_index_filter_cmd.cpp b/src/mongo/s/commands/cluster_index_filter_cmd.cpp index 9d114bccdba..b050368e3a0 100644 --- a/src/mongo/s/commands/cluster_index_filter_cmd.cpp +++ b/src/mongo/s/commands/cluster_index_filter_cmd.cpp @@ -94,7 +94,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { const NamespaceString nss(parseNs(dbname, cmdObj)); uassert(ErrorCodes::InvalidNamespace, diff --git a/src/mongo/s/commands/cluster_is_db_grid_cmd.cpp b/src/mongo/s/commands/cluster_is_db_grid_cmd.cpp index 9926799772c..308bfb4a2da 100644 --- a/src/mongo/s/commands/cluster_is_db_grid_cmd.cpp +++ b/src/mongo/s/commands/cluster_is_db_grid_cmd.cpp @@ -55,7 +55,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { result.append("isdbgrid", 1); result.append("hostname", getHostNameCached()); diff --git a/src/mongo/s/commands/cluster_is_master_cmd.cpp b/src/mongo/s/commands/cluster_is_master_cmd.cpp index b2a294f81b3..0209981de08 100644 --- a/src/mongo/s/commands/cluster_is_master_cmd.cpp +++ b/src/mongo/s/commands/cluster_is_master_cmd.cpp @@ -70,7 +70,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { auto& clientMetadataIsMasterState = ClientMetadataIsMasterState::get(opCtx->getClient()); diff --git a/src/mongo/s/commands/cluster_kill_op.cpp b/src/mongo/s/commands/cluster_kill_op.cpp index 871dd20bfe0..9ede8a5661a 100644 --- a/src/mongo/s/commands/cluster_kill_op.cpp +++ b/src/mongo/s/commands/cluster_kill_op.cpp @@ -79,7 +79,6 @@ public: bool run(OperationContext* opCtx, const std::string& db, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) final { // The format of op is shardid:opid // This is different than the format passed to the mongod killOp command. diff --git a/src/mongo/s/commands/cluster_list_databases_cmd.cpp b/src/mongo/s/commands/cluster_list_databases_cmd.cpp index 329cfb012b7..2087dce822c 100644 --- a/src/mongo/s/commands/cluster_list_databases_cmd.cpp +++ b/src/mongo/s/commands/cluster_list_databases_cmd.cpp @@ -87,7 +87,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbname_unused, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { const bool nameOnly = cmdObj["nameOnly"].trueValue(); diff --git a/src/mongo/s/commands/cluster_list_shards_cmd.cpp b/src/mongo/s/commands/cluster_list_shards_cmd.cpp index 69498c2b121..8527703c3b7 100644 --- a/src/mongo/s/commands/cluster_list_shards_cmd.cpp +++ b/src/mongo/s/commands/cluster_list_shards_cmd.cpp @@ -71,7 +71,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { auto shardsStatus = grid.catalogClient()->getAllShards(opCtx, repl::ReadConcernLevel::kMajorityReadConcern); diff --git a/src/mongo/s/commands/cluster_map_reduce_cmd.cpp b/src/mongo/s/commands/cluster_map_reduce_cmd.cpp index b77a45fc95d..16f44fa2723 100644 --- a/src/mongo/s/commands/cluster_map_reduce_cmd.cpp +++ b/src/mongo/s/commands/cluster_map_reduce_cmd.cpp @@ -147,9 +147,9 @@ BSONObj fixForShards(const BSONObj& orig, * * 11. Inspects the BSONObject size from step #8 and determines if it needs to split. */ -class MRCmd : public BasicCommand { +class MRCmd : public ErrmsgCommandDeprecated { public: - MRCmd() : BasicCommand("mapReduce", "mapreduce") {} + MRCmd() : ErrmsgCommandDeprecated("mapReduce", "mapreduce") {} bool slaveOk() const override { return true; @@ -177,11 +177,11 @@ public: mr::addPrivilegesRequiredForMapReduce(this, dbname, cmdObj, out); } - bool run(OperationContext* opCtx, - const std::string& dbname, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& result) override { + bool errmsgRun(OperationContext* opCtx, + const std::string& dbname, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& result) override { Timer t; const NamespaceString nss(parseNs(dbname, cmdObj)); diff --git a/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp b/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp index d9f980c52ae..b4bd8c04e9a 100644 --- a/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp +++ b/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp @@ -54,9 +54,9 @@ namespace { /** * Mongos-side command for merging chunks, passes command to appropriate shard. */ -class ClusterMergeChunksCommand : public BasicCommand { +class ClusterMergeChunksCommand : public ErrmsgCommandDeprecated { public: - ClusterMergeChunksCommand() : BasicCommand("mergeChunks") {} + ClusterMergeChunksCommand() : ErrmsgCommandDeprecated("mergeChunks") {} void help(stringstream& h) const override { h << "Merge Chunks command\n" @@ -99,11 +99,11 @@ public: static BSONField configField; - bool run(OperationContext* opCtx, - const string& dbname, - const BSONObj& cmdObj, - string& errmsg, - BSONObjBuilder& result) override { + bool errmsgRun(OperationContext* opCtx, + const string& dbname, + const BSONObj& cmdObj, + string& errmsg, + BSONObjBuilder& result) override { const NamespaceString nss(parseNs(dbname, cmdObj)); auto routingInfo = uassertStatusOK( diff --git a/src/mongo/s/commands/cluster_move_chunk_cmd.cpp b/src/mongo/s/commands/cluster_move_chunk_cmd.cpp index 4e1e0b9b57e..2a6f4147180 100644 --- a/src/mongo/s/commands/cluster_move_chunk_cmd.cpp +++ b/src/mongo/s/commands/cluster_move_chunk_cmd.cpp @@ -55,9 +55,9 @@ using std::string; namespace { -class MoveChunkCmd : public BasicCommand { +class MoveChunkCmd : public ErrmsgCommandDeprecated { public: - MoveChunkCmd() : BasicCommand("moveChunk", "movechunk") {} + MoveChunkCmd() : ErrmsgCommandDeprecated("moveChunk", "movechunk") {} bool slaveOk() const override { return true; @@ -95,11 +95,11 @@ public: return parseNsFullyQualified(dbname, cmdObj); } - bool run(OperationContext* opCtx, - const std::string& dbname, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& result) override { + bool errmsgRun(OperationContext* opCtx, + const std::string& dbname, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& result) override { Timer t; const NamespaceString nss(parseNs(dbname, cmdObj)); diff --git a/src/mongo/s/commands/cluster_move_primary_cmd.cpp b/src/mongo/s/commands/cluster_move_primary_cmd.cpp index a7a0c496af1..e67afb64e04 100644 --- a/src/mongo/s/commands/cluster_move_primary_cmd.cpp +++ b/src/mongo/s/commands/cluster_move_primary_cmd.cpp @@ -95,7 +95,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { auto movePrimaryRequest = MovePrimary::parse(IDLParserErrorContext("MovePrimary"), cmdObj); diff --git a/src/mongo/s/commands/cluster_netstat_cmd.cpp b/src/mongo/s/commands/cluster_netstat_cmd.cpp index 33076de0db4..1e14f9bd5ad 100644 --- a/src/mongo/s/commands/cluster_netstat_cmd.cpp +++ b/src/mongo/s/commands/cluster_netstat_cmd.cpp @@ -68,7 +68,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { result.append("configserver", grid.shardRegistry()->getConfigServerConnectionString().toString()); diff --git a/src/mongo/s/commands/cluster_pipeline_cmd.cpp b/src/mongo/s/commands/cluster_pipeline_cmd.cpp index a48de3400cc..e433c6d252d 100644 --- a/src/mongo/s/commands/cluster_pipeline_cmd.cpp +++ b/src/mongo/s/commands/cluster_pipeline_cmd.cpp @@ -69,7 +69,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { return appendCommandStatus(result, _runAggCommand(opCtx, dbname, cmdObj, boost::none, &result)); diff --git a/src/mongo/s/commands/cluster_plan_cache_cmd.cpp b/src/mongo/s/commands/cluster_plan_cache_cmd.cpp index 7f339b20c2d..748459fe163 100644 --- a/src/mongo/s/commands/cluster_plan_cache_cmd.cpp +++ b/src/mongo/s/commands/cluster_plan_cache_cmd.cpp @@ -89,7 +89,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result); public: @@ -112,7 +111,6 @@ private: bool ClusterPlanCacheCmd::run(OperationContext* opCtx, const std::string& dbName, const BSONObj& cmdObj, - std::string& errMsg, BSONObjBuilder& result) { const NamespaceString nss(parseNsCollectionRequired(dbName, cmdObj)); diff --git a/src/mongo/s/commands/cluster_profile_cmd.cpp b/src/mongo/s/commands/cluster_profile_cmd.cpp index 5c1fde01243..cab007638d9 100644 --- a/src/mongo/s/commands/cluster_profile_cmd.cpp +++ b/src/mongo/s/commands/cluster_profile_cmd.cpp @@ -33,9 +33,9 @@ namespace mongo { namespace { -class ProfileCmd : public BasicCommand { +class ProfileCmd : public ErrmsgCommandDeprecated { public: - ProfileCmd() : BasicCommand("profile") {} + ProfileCmd() : ErrmsgCommandDeprecated("profile") {} virtual bool slaveOk() const { return true; @@ -58,11 +58,11 @@ public: out->push_back(Privilege(ResourcePattern::forDatabaseName(dbname), actions)); } - virtual bool run(OperationContext* opCtx, - const std::string& dbname, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const std::string& dbname, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& result) { errmsg = "profile currently not supported via mongos"; return false; } diff --git a/src/mongo/s/commands/cluster_remove_shard_cmd.cpp b/src/mongo/s/commands/cluster_remove_shard_cmd.cpp index 8a649cf52a4..79c2df15c47 100644 --- a/src/mongo/s/commands/cluster_remove_shard_cmd.cpp +++ b/src/mongo/s/commands/cluster_remove_shard_cmd.cpp @@ -82,7 +82,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { uassert(ErrorCodes::TypeMismatch, str::stream() << "Field '" << cmdObj.firstElement().fieldName() diff --git a/src/mongo/s/commands/cluster_remove_shard_from_zone_cmd.cpp b/src/mongo/s/commands/cluster_remove_shard_from_zone_cmd.cpp index 88d019b7847..cfff64d3625 100644 --- a/src/mongo/s/commands/cluster_remove_shard_from_zone_cmd.cpp +++ b/src/mongo/s/commands/cluster_remove_shard_from_zone_cmd.cpp @@ -106,7 +106,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { auto parsedRequest = uassertStatusOK(RemoveShardFromZoneRequest::parseFromMongosCommand(cmdObj)); diff --git a/src/mongo/s/commands/cluster_repl_set_get_status_cmd.cpp b/src/mongo/s/commands/cluster_repl_set_get_status_cmd.cpp index 24f1e8dd31d..aba2f927bd4 100644 --- a/src/mongo/s/commands/cluster_repl_set_get_status_cmd.cpp +++ b/src/mongo/s/commands/cluster_repl_set_get_status_cmd.cpp @@ -36,9 +36,9 @@ namespace mongo { namespace { -class CmdReplSetGetStatus : public BasicCommand { +class CmdReplSetGetStatus : public ErrmsgCommandDeprecated { public: - CmdReplSetGetStatus() : BasicCommand("replSetGetStatus") {} + CmdReplSetGetStatus() : ErrmsgCommandDeprecated("replSetGetStatus") {} virtual bool slaveOk() const { return true; @@ -64,11 +64,11 @@ public: return Status::OK(); } - virtual bool run(OperationContext* opCtx, - const std::string& dbname, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& result) { + virtual bool errmsgRun(OperationContext* opCtx, + const std::string& dbname, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& result) { if (cmdObj["forShell"].trueValue()) { LastError::get(cc()).disable(); ClusterLastErrorInfo::get(cc())->disableForCommand(); diff --git a/src/mongo/s/commands/cluster_reset_error_cmd.cpp b/src/mongo/s/commands/cluster_reset_error_cmd.cpp index 30fef011f72..8fbe4c7a78b 100644 --- a/src/mongo/s/commands/cluster_reset_error_cmd.cpp +++ b/src/mongo/s/commands/cluster_reset_error_cmd.cpp @@ -62,7 +62,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { LastError::get(cc()).reset(); diff --git a/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp b/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp index 1b865553b30..c186b56f693 100644 --- a/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp +++ b/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp @@ -86,7 +86,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { const auto version = uassertStatusOK( FeatureCompatibilityVersionCommandParser::extractVersionFromCommand(getName(), cmdObj)); diff --git a/src/mongo/s/commands/cluster_shard_collection_cmd.cpp b/src/mongo/s/commands/cluster_shard_collection_cmd.cpp index d58268bb9ae..266fcb71944 100644 --- a/src/mongo/s/commands/cluster_shard_collection_cmd.cpp +++ b/src/mongo/s/commands/cluster_shard_collection_cmd.cpp @@ -107,7 +107,6 @@ public: bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) override { const NamespaceString nss(parseNs(dbname, cmdObj)); auto shardCollRequest = diff --git a/src/mongo/s/commands/cluster_shutdown_cmd.cpp b/src/mongo/s/commands/cluster_shutdown_cmd.cpp index fde7564a285..5918cc4dabc 100644 --- a/src/mongo/s/commands/cluster_shutdown_cmd.cpp +++ b/src/mongo/s/commands/cluster_shutdown_cmd.cpp @@ -44,7 +44,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { // Never returns shutdownHelper(); diff --git a/src/mongo/s/commands/cluster_split_cmd.cpp b/src/mongo/s/commands/cluster_split_cmd.cpp index 2deaebb830f..61c2ff04bfd 100644 --- a/src/mongo/s/commands/cluster_split_cmd.cpp +++ b/src/mongo/s/commands/cluster_split_cmd.cpp @@ -84,9 +84,9 @@ BSONObj selectMedianKey(OperationContext* opCtx, "Unable to find median in chunk, possibly because chunk is empty."); } -class SplitCollectionCmd : public BasicCommand { +class SplitCollectionCmd : public ErrmsgCommandDeprecated { public: - SplitCollectionCmd() : BasicCommand("split", "split") {} + SplitCollectionCmd() : ErrmsgCommandDeprecated("split", "split") {} bool slaveOk() const override { return true; @@ -123,11 +123,11 @@ public: return parseNsFullyQualified(dbname, cmdObj); } - bool run(OperationContext* opCtx, - const std::string& dbname, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& result) override { + bool errmsgRun(OperationContext* opCtx, + const std::string& dbname, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& result) override { const NamespaceString nss(parseNs(dbname, cmdObj)); auto routingInfo = uassertStatusOK( diff --git a/src/mongo/s/commands/cluster_update_zone_key_range_cmd.cpp b/src/mongo/s/commands/cluster_update_zone_key_range_cmd.cpp index 72b479c32c7..22d926ac053 100644 --- a/src/mongo/s/commands/cluster_update_zone_key_range_cmd.cpp +++ b/src/mongo/s/commands/cluster_update_zone_key_range_cmd.cpp @@ -121,7 +121,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { auto parsedRequest = uassertStatusOK(UpdateZoneKeyRangeRequest::parseFromMongosCommand(cmdObj)); diff --git a/src/mongo/s/commands/cluster_user_management_commands.cpp b/src/mongo/s/commands/cluster_user_management_commands.cpp index e29b970d04d..323b51c9403 100644 --- a/src/mongo/s/commands/cluster_user_management_commands.cpp +++ b/src/mongo/s/commands/cluster_user_management_commands.cpp @@ -89,7 +89,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { return Grid::get(opCtx)->catalogClient()->runUserManagementWriteCommand( opCtx, getName(), dbname, filterCommandRequestForPassthrough(cmdObj), &result); @@ -127,7 +126,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { auth::CreateOrUpdateUserArgs args; Status status = auth::parseCreateOrUpdateUserCommands(cmdObj, getName(), dbname, &args); @@ -176,7 +174,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { UserName userName; Status status = auth::parseAndValidateDropUserCommand(cmdObj, dbname, &userName); @@ -221,7 +218,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { const bool ok = Grid::get(opCtx)->catalogClient()->runUserManagementWriteCommand( opCtx, getName(), dbname, filterCommandRequestForPassthrough(cmdObj), &result); @@ -261,7 +257,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { string userNameString; vector roles; @@ -308,7 +303,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { string userNameString; vector unusedRoles; @@ -359,7 +353,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { return Grid::get(opCtx)->catalogClient()->runUserManagementReadCommand( opCtx, dbname, filterCommandRequestForPassthrough(cmdObj), &result); @@ -393,7 +386,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { return Grid::get(opCtx)->catalogClient()->runUserManagementWriteCommand( opCtx, getName(), dbname, filterCommandRequestForPassthrough(cmdObj), &result); @@ -427,7 +419,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { const bool ok = Grid::get(opCtx)->catalogClient()->runUserManagementWriteCommand( opCtx, getName(), dbname, filterCommandRequestForPassthrough(cmdObj), &result); @@ -467,7 +458,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { const bool ok = Grid::get(opCtx)->catalogClient()->runUserManagementWriteCommand( opCtx, getName(), dbname, filterCommandRequestForPassthrough(cmdObj), &result); @@ -507,7 +497,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { const bool ok = Grid::get(opCtx)->catalogClient()->runUserManagementWriteCommand( opCtx, getName(), dbname, filterCommandRequestForPassthrough(cmdObj), &result); @@ -547,7 +536,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { const bool ok = Grid::get(opCtx)->catalogClient()->runUserManagementWriteCommand( opCtx, getName(), dbname, filterCommandRequestForPassthrough(cmdObj), &result); @@ -587,7 +575,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { const bool ok = Grid::get(opCtx)->catalogClient()->runUserManagementWriteCommand( opCtx, getName(), dbname, filterCommandRequestForPassthrough(cmdObj), &result); @@ -630,7 +617,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { const bool ok = Grid::get(opCtx)->catalogClient()->runUserManagementWriteCommand( opCtx, getName(), dbname, filterCommandRequestForPassthrough(cmdObj), &result); @@ -674,7 +660,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { const bool ok = Grid::get(opCtx)->catalogClient()->runUserManagementWriteCommand( opCtx, getName(), dbname, filterCommandRequestForPassthrough(cmdObj), &result); @@ -718,7 +703,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { return Grid::get(opCtx)->catalogClient()->runUserManagementReadCommand( opCtx, dbname, filterCommandRequestForPassthrough(cmdObj), &result); @@ -756,7 +740,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { AuthorizationManager* authzManager = getGlobalAuthorizationManager(); invariant(authzManager); @@ -806,7 +789,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { return Grid::get(opCtx)->catalogClient()->runUserManagementWriteCommand( opCtx, getName(), dbname, filterCommandRequestForPassthrough(cmdObj), &result); @@ -895,7 +877,6 @@ public: bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) { // Run the authSchemaUpgrade command on the config servers if (!Grid::get(opCtx)->catalogClient()->runUserManagementWriteCommand( diff --git a/src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp b/src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp index bdb8cce85a8..b5ecdd2f330 100644 --- a/src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp +++ b/src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp @@ -60,7 +60,6 @@ public: virtual bool run(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, - std::string& errmsg, BSONObjBuilder& result) { result << "you" << cc().getRemote().toString(); return true; diff --git a/src/mongo/s/commands/commands_public.cpp b/src/mongo/s/commands/commands_public.cpp index 717f7057fba..e5a546baf3a 100644 --- a/src/mongo/s/commands/commands_public.cpp +++ b/src/mongo/s/commands/commands_public.cpp @@ -194,13 +194,13 @@ protected: * Base class for commands on collections that simply need to broadcast the command to shards that * own data for the collection and aggregate the raw results. */ -class AllShardsCollectionCommand : public BasicCommand { +class AllShardsCollectionCommand : public ErrmsgCommandDeprecated { protected: AllShardsCollectionCommand(const char* name, const char* oldname = NULL, bool implicitCreateDb = false, bool appendShardVersion = true) - : BasicCommand(name, oldname), + : ErrmsgCommandDeprecated(name, oldname), _implicitCreateDb(implicitCreateDb), _appendShardVersion(appendShardVersion) {} @@ -211,11 +211,11 @@ protected: return false; } - bool run(OperationContext* opCtx, - const string& dbName, - const BSONObj& cmdObj, - std::string& errmsg, - BSONObjBuilder& output) override { + bool errmsgRun(OperationContext* opCtx, + const string& dbName, + const BSONObj& cmdObj, + std::string& errmsg, + BSONObjBuilder& output) override { const NamespaceString nss(parseNsCollectionRequired(dbName, cmdObj)); LOG(1) << "AllShardsCollectionCommand: " << nss << " cmd:" << redact(cmdObj); @@ -251,7 +251,6 @@ protected: bool run(OperationContext* opCtx, const string& dbName, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) override { const NamespaceString nss(parseNs(dbName, cmdObj)); @@ -357,7 +356,6 @@ public: bool run(OperationContext* opCtx, const string& dbName, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& output) { const NamespaceString nss(parseNsCollectionRequired(dbName, cmdObj)); @@ -392,7 +390,7 @@ public: if (!result["errmsg"].eoo()) { // errmsg indicates a user error, so returning the message from one shard is // sufficient. - errmsg = result["errmsg"].toString(); + output.append(result["errmsg"]); errored = true; } rawResBuilder.append(shardName.toString(), result); @@ -433,7 +431,6 @@ public: bool run(OperationContext* opCtx, const string& dbName, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) override { uassertStatusOK(createShardDatabase(opCtx, dbName)); @@ -465,7 +462,6 @@ public: bool run(OperationContext* opCtx, const string& dbName, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) override { const auto fullNsFromElt = cmdObj.firstElement(); uassert(ErrorCodes::InvalidNamespace, @@ -523,7 +519,6 @@ public: bool run(OperationContext* opCtx, const string& dbName, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) override { const auto todbElt = cmdObj["todb"]; uassert(ErrorCodes::InvalidNamespace, @@ -596,7 +591,6 @@ public: bool run(OperationContext* opCtx, const string& dbName, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) override { const NamespaceString nss(parseNsCollectionRequired(dbName, cmdObj)); @@ -638,7 +632,7 @@ public: if (!res["code"].eoo()) { result.append(res["code"]); } - errmsg = "failed on shard: " + res.toString(); + result.append("errmsg", "failed on shard: " + res.toString()); return false; } conn.done(); @@ -776,7 +770,6 @@ public: bool run(OperationContext* opCtx, const string& dbName, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) override { const NamespaceString nss(parseNs(dbName, cmdObj)); @@ -969,14 +962,13 @@ public: bool run(OperationContext* opCtx, const string& dbName, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) override { const std::string ns = parseNs(dbName, cmdObj); uassert(ErrorCodes::IllegalOperation, "Performing splitVector across dbs isn't supported via mongos", str::startsWith(ns, dbName)); - return NotAllowedOnShardedCollectionCmd::run(opCtx, dbName, cmdObj, errmsg, result); + return NotAllowedOnShardedCollectionCmd::run(opCtx, dbName, cmdObj, result); } } splitVectorCmd; @@ -1004,7 +996,6 @@ public: bool run(OperationContext* opCtx, const string& dbName, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) override { const NamespaceString nss(parseNsCollectionRequired(dbName, cmdObj)); @@ -1252,7 +1243,6 @@ public: bool run(OperationContext* opCtx, const string& dbName, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) override { const NamespaceString nss(parseNs(dbName, cmdObj)); @@ -1338,8 +1328,9 @@ public: log() << "Sharded filemd5 failed: " << redact(result.asTempObj()); - errmsg = - string("sharded filemd5 failed because: ") + res["errmsg"].valuestrsafe(); + result.append("errmsg", + string("sharded filemd5 failed because: ") + + res["errmsg"].valuestrsafe()); return false; } @@ -1368,9 +1359,9 @@ public: // We could support arbitrary shard keys by sending commands to all shards but I don't // think we should - errmsg = - "GridFS fs.chunks collection must be sharded on either {files_id:1} or " - "{files_id:1, n:1}"; + result.append("errmsg", + "GridFS fs.chunks collection must be sharded on either {files_id:1} or " + "{files_id:1, n:1}"); return false; } } fileMD5Cmd; @@ -1398,7 +1389,6 @@ public: bool run(OperationContext* opCtx, const string& dbName, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) override { const NamespaceString nss(parseNsCollectionRequired(dbName, cmdObj)); @@ -1523,7 +1513,6 @@ public: bool run(OperationContext* opCtx, const string& dbName, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) override { RARELY { warning() << "the eval command is deprecated" << startupWarningsLog; @@ -1568,7 +1557,6 @@ public: bool run(OperationContext* opCtx, const string& dbName, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) final { auto nss = NamespaceString::makeListCollectionsNSS(dbName); @@ -1617,7 +1605,6 @@ public: bool run(OperationContext* opCtx, const string& dbName, const BSONObj& cmdObj, - string& errmsg, BSONObjBuilder& result) final { const NamespaceString nss(parseNsCollectionRequired(dbName, cmdObj)); -- cgit v1.2.1