diff options
Diffstat (limited to 'src')
107 files changed, 211 insertions, 202 deletions
diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp index 3d7acd01705..d3d92172ae4 100644 --- a/src/mongo/db/commands.cpp +++ b/src/mongo/db/commands.cpp @@ -881,7 +881,7 @@ public: : CommandInvocation(command), _command(command), _request(request), - _dbName(_request.getValidatedTenantId(), _request.getDatabase().toString()) {} + _dbName(_request.getValidatedTenantId(), _request.getDatabase()) {} private: void run(OperationContext* opCtx, rpc::ReplyBuilderInterface* result) override { @@ -1029,11 +1029,11 @@ void Command::generateHelpResponse(OperationContext* opCtx, } bool ErrmsgCommandDeprecated::run(OperationContext* opCtx, - const std::string& db, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) { std::string errmsg; - auto ok = errmsgRun(opCtx, db, cmdObj, errmsg, result); + auto ok = errmsgRun(opCtx, dbName.toStringWithTenantId(), cmdObj, errmsg, result); if (!errmsg.empty()) { CommandHelpers::appendSimpleCommandStatus(result, ok, errmsg); } diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h index d07865bf33f..f23abe97a98 100644 --- a/src/mongo/db/commands.h +++ b/src/mongo/db/commands.h @@ -1011,7 +1011,7 @@ public: * Runs the given command. Returns true upon success. */ virtual bool run(OperationContext* opCtx, - const std::string& db, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) = 0; @@ -1020,8 +1020,7 @@ public: const BSONObj& cmdObj, rpc::ReplyBuilderInterface* replyBuilder) override { auto result = replyBuilder->getBodyBuilder(); - // TODO SERVER-67459 change BasicCommand::run to take in DatabaseName - return run(opCtx, dbName.toStringWithTenantId(), cmdObj, result); + return run(opCtx, dbName, cmdObj, result); } }; @@ -1174,7 +1173,7 @@ private: class ErrmsgCommandDeprecated : public BasicCommand { using BasicCommand::BasicCommand; bool run(OperationContext* opCtx, - const std::string& db, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) final; diff --git a/src/mongo/db/commands/apply_ops_cmd.cpp b/src/mongo/db/commands/apply_ops_cmd.cpp index 1a31cb0d8f8..56adcab2cb6 100644 --- a/src/mongo/db/commands/apply_ops_cmd.cpp +++ b/src/mongo/db/commands/apply_ops_cmd.cpp @@ -211,7 +211,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override { validateApplyOpsCommand(cmdObj); @@ -260,8 +260,11 @@ public: OperationShardingState::ScopedAllowImplicitCollectionCreate_UNSAFE unsafeCreateCollection( opCtx); + // TODO SERVER-68550: call applyOps with DatabaseName object instead of db string. auto applyOpsStatus = CommandHelpers::appendCommandStatusNoThrow( - result, repl::applyOps(opCtx, dbname, cmdObj, oplogApplicationMode, &result)); + result, + repl::applyOps( + opCtx, dbName.toStringWithTenantId(), cmdObj, oplogApplicationMode, &result)); return applyOpsStatus; } diff --git a/src/mongo/db/commands/authentication_commands.cpp b/src/mongo/db/commands/authentication_commands.cpp index 9f1bb3595d7..826bc6b23a0 100644 --- a/src/mongo/db/commands/authentication_commands.cpp +++ b/src/mongo/db/commands/authentication_commands.cpp @@ -121,7 +121,7 @@ public: } bool run(OperationContext* opCtx, - const std::string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) final { CommandHelpers::handleMarkKillOnClientDisconnect(opCtx); diff --git a/src/mongo/db/commands/conn_pool_stats.cpp b/src/mongo/db/commands/conn_pool_stats.cpp index 3952309e987..25c0a385952 100644 --- a/src/mongo/db/commands/conn_pool_stats.cpp +++ b/src/mongo/db/commands/conn_pool_stats.cpp @@ -71,7 +71,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& db, + const DatabaseName&, const mongo::BSONObj& cmdObj, 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 6496c64bf5a..2111ec42931 100644 --- a/src/mongo/db/commands/conn_pool_sync.cpp +++ b/src/mongo/db/commands/conn_pool_sync.cpp @@ -60,7 +60,7 @@ public: } bool run(OperationContext* opCtx, - const std::string&, + const DatabaseName&, const mongo::BSONObj&, mongo::BSONObjBuilder& result) override { globalConnPool.flush(); diff --git a/src/mongo/db/commands/count_cmd.cpp b/src/mongo/db/commands/count_cmd.cpp index 507e52bc7d5..43377f76da6 100644 --- a/src/mongo/db/commands/count_cmd.cpp +++ b/src/mongo/db/commands/count_cmd.cpp @@ -103,6 +103,10 @@ public: return false; } + bool allowedWithSecurityToken() const final { + return true; + } + ReadConcernSupportResult supportsReadConcern(const BSONObj& cmdObj, repl::ReadConcernLevel level, bool isImplicitDefault) const override { @@ -224,7 +228,7 @@ public: } bool run(OperationContext* opCtx, - const string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override { CommandHelpers::handleMarkKillOnClientDisconnect(opCtx); @@ -232,7 +236,7 @@ public: // of a view, the locks need to be released. boost::optional<AutoGetCollectionForReadCommandMaybeLockFree> ctx; ctx.emplace(opCtx, - CommandHelpers::parseNsOrUUID({boost::none, dbname}, cmdObj), + CommandHelpers::parseNsOrUUID(dbName, cmdObj), AutoGetCollectionViewMode::kViewsPermitted); const auto& nss = ctx->getNss(); @@ -257,7 +261,8 @@ public: uassertStatusOK(viewAggregation.getStatus()); BSONObj aggResult = CommandHelpers::runCommandDirectly( - opCtx, OpMsgRequest::fromDBAndBody(dbname, std::move(viewAggregation.getValue()))); + opCtx, + OpMsgRequest::fromDBAndBody(dbName.db(), std::move(viewAggregation.getValue()))); uassertStatusOK(ViewResponseFormatter(aggResult).appendAsCountResponse(&result)); return true; diff --git a/src/mongo/db/commands/cpuload.cpp b/src/mongo/db/commands/cpuload.cpp index 400cdc3a4d8..7699275426b 100644 --- a/src/mongo/db/commands/cpuload.cpp +++ b/src/mongo/db/commands/cpuload.cpp @@ -63,7 +63,7 @@ public: const BSONObj& cmdObj, std::vector<Privilege>* out) const {} // No auth required virtual bool run(OperationContext* txn, - const string& badns, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { double cpuFactor = 1; diff --git a/src/mongo/db/commands/cst_command.cpp b/src/mongo/db/commands/cst_command.cpp index 6335031fe10..9f68f8ca2be 100644 --- a/src/mongo/db/commands/cst_command.cpp +++ b/src/mongo/db/commands/cst_command.cpp @@ -72,7 +72,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override { @@ -87,7 +87,7 @@ public: } result.append("cst", BSONArray(pipelineCst.toBson())); - auto nss = NamespaceString{dbname, ""}; + auto nss = NamespaceString{dbName, ""}; auto expCtx = make_intrusive<ExpressionContext>(opCtx, nullptr /*collator*/, nss); auto pipeline = cst_pipeline_translation::translatePipeline(pipelineCst, expCtx); result.append("ds", pipeline->serializeToBson()); diff --git a/src/mongo/db/commands/current_op_common.cpp b/src/mongo/db/commands/current_op_common.cpp index 304009accdb..7b8565f75d5 100644 --- a/src/mongo/db/commands/current_op_common.cpp +++ b/src/mongo/db/commands/current_op_common.cpp @@ -46,7 +46,7 @@ static const StringDataSet kCurOpCmdParams = {kAll, kOwnOps, kTruncateOps}; } // namespace bool CurrentOpCommandBase::run(OperationContext* opCtx, - const std::string& dbName, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { // Convert the currentOp command spec into an equivalent aggregation command. This will be diff --git a/src/mongo/db/commands/current_op_common.h b/src/mongo/db/commands/current_op_common.h index 789ece31e0a..4d22ef7d67b 100644 --- a/src/mongo/db/commands/current_op_common.h +++ b/src/mongo/db/commands/current_op_common.h @@ -59,7 +59,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) final; diff --git a/src/mongo/db/commands/dbcheck.cpp b/src/mongo/db/commands/dbcheck.cpp index 11530897b6b..a27c4e6a141 100644 --- a/src/mongo/db/commands/dbcheck.cpp +++ b/src/mongo/db/commands/dbcheck.cpp @@ -154,7 +154,7 @@ struct DbCheckCollectionInfo { using DbCheckRun = std::vector<DbCheckCollectionInfo>; std::unique_ptr<DbCheckRun> singleCollectionRun(OperationContext* opCtx, - const std::string& dbName, + const DatabaseName& dbName, const DbCheckSingleInvocation& invocation) { NamespaceString nss(dbName, invocation.getColl()); AutoGetCollectionForRead agc(opCtx, nss); @@ -192,14 +192,14 @@ std::unique_ptr<DbCheckRun> singleCollectionRun(OperationContext* opCtx, } std::unique_ptr<DbCheckRun> fullDatabaseRun(OperationContext* opCtx, - const std::string& dbName, + const DatabaseName& dbName, const DbCheckAllInvocation& invocation) { - uassert( - ErrorCodes::InvalidNamespace, "Cannot run dbCheck on local database", dbName != "local"); + uassert(ErrorCodes::InvalidNamespace, + "Cannot run dbCheck on local database", + dbName.db() != "local"); - // TODO SERVER-63353 Change to use dbName directly - AutoGetDb agd(opCtx, DatabaseName(boost::none, dbName), MODE_IS); - uassert(ErrorCodes::NamespaceNotFound, "Database " + dbName + " not found", agd.getDb()); + AutoGetDb agd(opCtx, dbName, MODE_IS); + uassert(ErrorCodes::NamespaceNotFound, "Database " + dbName.db() + " not found", agd.getDb()); const int64_t max = std::numeric_limits<int64_t>::max(); const auto rate = invocation.getMaxCountPerSecond(); @@ -225,9 +225,7 @@ std::unique_ptr<DbCheckRun> fullDatabaseRun(OperationContext* opCtx, result->push_back(info); return true; }; - // TODO SERVER-63353: Change dbcheck command to use DatabaseName - mongo::catalog::forEachCollectionFromDb( - opCtx, DatabaseName(boost::none, dbName), MODE_IS, perCollectionWork); + mongo::catalog::forEachCollectionFromDb(opCtx, dbName, MODE_IS, perCollectionWork); return result; } @@ -237,7 +235,7 @@ std::unique_ptr<DbCheckRun> fullDatabaseRun(OperationContext* opCtx, * Factory function for producing DbCheckRun's from command objects. */ std::unique_ptr<DbCheckRun> getRun(OperationContext* opCtx, - const std::string& dbName, + const DatabaseName& dbName, const BSONObj& obj) { BSONObjBuilder builder; @@ -267,7 +265,7 @@ std::unique_ptr<DbCheckRun> getRun(OperationContext* opCtx, */ class DbCheckJob : public BackgroundJob { public: - DbCheckJob(const StringData& dbName, std::unique_ptr<DbCheckRun> run) + DbCheckJob(const DatabaseName& dbName, std::unique_ptr<DbCheckRun> run) : BackgroundJob(true), _done(false), _dbName(dbName.toString()), _run(std::move(run)) {} protected: @@ -683,12 +681,12 @@ public: } virtual bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) { - auto job = getRun(opCtx, dbname, cmdObj); + auto job = getRun(opCtx, dbName, cmdObj); try { - (new DbCheckJob(dbname, std::move(job)))->go(); + (new DbCheckJob(dbName, std::move(job)))->go(); } catch (const DBException& e) { result.append("ok", false); result.append("err", e.toString()); diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp index e18644c0649..b19eb539ba3 100644 --- a/src/mongo/db/commands/dbcommands.cpp +++ b/src/mongo/db/commands/dbcommands.cpp @@ -777,7 +777,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& jsobj, BSONObjBuilder& result) final { VersionInfoInterface::instance().appendBuildInfo(&result); diff --git a/src/mongo/db/commands/dbcommands_d.cpp b/src/mongo/db/commands/dbcommands_d.cpp index 2dee3bf87ec..b1596fdc81b 100644 --- a/src/mongo/db/commands/dbcommands_d.cpp +++ b/src/mongo/db/commands/dbcommands_d.cpp @@ -247,10 +247,10 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName& dbName, const BSONObj& jsobj, BSONObjBuilder& result) { - const NamespaceString nss(parseNs({boost::none, dbname}, jsobj)); + const NamespaceString nss(parseNs(dbName, jsobj)); md5digest d; md5_state_t st; @@ -283,7 +283,7 @@ public: BSONObj query = BSON("files_id" << jsobj["filemd5"] << "n" << GTE << n); BSONObj sort = BSON("files_id" << 1 << "n" << 1); - return writeConflictRetry(opCtx, "filemd5", dbname, [&] { + return writeConflictRetry(opCtx, "filemd5", dbName.toString(), [&] { auto findCommand = std::make_unique<FindCommandRequest>(nss); findCommand->setFilter(query.getOwned()); findCommand->setSort(sort.getOwned()); diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp index 3a80f3af849..542f4e773b6 100644 --- a/src/mongo/db/commands/distinct.cpp +++ b/src/mongo/db/commands/distinct.cpp @@ -139,17 +139,21 @@ public: return true; } + bool allowedWithSecurityToken() const final { + return true; + } + Status explain(OperationContext* opCtx, const OpMsgRequest& request, ExplainOptions::Verbosity verbosity, rpc::ReplyBuilderInterface* result) const override { - std::string dbname = request.getDatabase().toString(); + const DatabaseName dbName(request.getValidatedTenantId(), request.getDatabase()); const BSONObj& cmdObj = request.body; // Acquire locks. The RAII object is optional, because in the case of a view, the locks // need to be released. boost::optional<AutoGetCollectionForReadCommandMaybeLockFree> ctx; ctx.emplace(opCtx, - CommandHelpers::parseNsCollectionRequired(dbname, cmdObj), + CommandHelpers::parseNsCollectionRequired(dbName, cmdObj), AutoGetCollectionViewMode::kViewsPermitted); const auto nss = ctx->getNss(); @@ -195,7 +199,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override { CommandHelpers::handleMarkKillOnClientDisconnect(opCtx); @@ -203,7 +207,7 @@ public: // of a view, the locks need to be released. boost::optional<AutoGetCollectionForReadCommandMaybeLockFree> ctx; ctx.emplace(opCtx, - CommandHelpers::parseNsOrUUID({boost::none, dbname}, cmdObj), + CommandHelpers::parseNsOrUUID(dbName, cmdObj), AutoGetCollectionViewMode::kViewsPermitted); const auto& nss = ctx->getNss(); @@ -245,7 +249,8 @@ public: uassertStatusOK(viewAggregation.getStatus()); BSONObj aggResult = CommandHelpers::runCommandDirectly( - opCtx, OpMsgRequest::fromDBAndBody(dbname, std::move(viewAggregation.getValue()))); + opCtx, + OpMsgRequest::fromDBAndBody(dbName.db(), std::move(viewAggregation.getValue()))); uassertStatusOK(ViewResponseFormatter(aggResult).appendAsDistinctResponse(&result)); return true; } diff --git a/src/mongo/db/commands/fail_point_cmd.cpp b/src/mongo/db/commands/fail_point_cmd.cpp index 0940c811d5a..00a2626e8cc 100644 --- a/src/mongo/db/commands/fail_point_cmd.cpp +++ b/src/mongo/db/commands/fail_point_cmd.cpp @@ -96,7 +96,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { const std::string failPointName(cmdObj.firstElement().str()); diff --git a/src/mongo/db/commands/generic.cpp b/src/mongo/db/commands/generic.cpp index ef4a557d38b..f61ead33f83 100644 --- a/src/mongo/db/commands/generic.cpp +++ b/src/mongo/db/commands/generic.cpp @@ -165,7 +165,7 @@ public: return false; } virtual bool run(OperationContext* opCtx, - const string& ns, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { // Sort the command names before building the result BSON. diff --git a/src/mongo/db/commands/generic_servers.cpp b/src/mongo/db/commands/generic_servers.cpp index a01604ec1b0..14dd3cc15ee 100644 --- a/src/mongo/db/commands/generic_servers.cpp +++ b/src/mongo/db/commands/generic_servers.cpp @@ -274,7 +274,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& db, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) final { if (MONGO_unlikely(hangInGetLog.shouldFail())) { diff --git a/src/mongo/db/commands/hashcmd.cpp b/src/mongo/db/commands/hashcmd.cpp index e6d729ab29b..ff6335ec6dc 100644 --- a/src/mongo/db/commands/hashcmd.cpp +++ b/src/mongo/db/commands/hashcmd.cpp @@ -80,7 +80,7 @@ public: *> "ok" : 1 } **/ bool run(OperationContext* opCtx, - const string& db, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { result.appendAs(cmdObj.firstElement(), "key"); diff --git a/src/mongo/db/commands/index_filter_commands.cpp b/src/mongo/db/commands/index_filter_commands.cpp index 6ac8c306fb2..f3f291bbae1 100644 --- a/src/mongo/db/commands/index_filter_commands.cpp +++ b/src/mongo/db/commands/index_filter_commands.cpp @@ -88,10 +88,10 @@ IndexFilterCommand::IndexFilterCommand(const string& name, const string& helpTex : BasicCommand(name), helpText(helpText) {} bool IndexFilterCommand::run(OperationContext* opCtx, - const string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) { - const NamespaceString nss(CommandHelpers::parseNsCollectionRequired(dbname, cmdObj)); + const NamespaceString nss(CommandHelpers::parseNsCollectionRequired(dbName, cmdObj)); AutoGetCollectionForReadCommand ctx(opCtx, nss); uassertStatusOK(runIndexFilterCommand(opCtx, ctx.getCollection(), cmdObj, &result)); return true; diff --git a/src/mongo/db/commands/index_filter_commands.h b/src/mongo/db/commands/index_filter_commands.h index e707f5292b2..462fc9c8df2 100644 --- a/src/mongo/db/commands/index_filter_commands.h +++ b/src/mongo/db/commands/index_filter_commands.h @@ -66,7 +66,7 @@ public: */ bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override; diff --git a/src/mongo/db/commands/isself.cpp b/src/mongo/db/commands/isself.cpp index 3669190782d..2139d822c03 100644 --- a/src/mongo/db/commands/isself.cpp +++ b/src/mongo/db/commands/isself.cpp @@ -61,7 +61,7 @@ public: const BSONObj& cmdObj, std::vector<Privilege>* out) const override {} bool run(OperationContext* opCtx, - const string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { result.append("id", repl::instanceId); diff --git a/src/mongo/db/commands/kill_all_sessions_by_pattern_command.cpp b/src/mongo/db/commands/kill_all_sessions_by_pattern_command.cpp index 044e56c12c4..de3fedd0e8a 100644 --- a/src/mongo/db/commands/kill_all_sessions_by_pattern_command.cpp +++ b/src/mongo/db/commands/kill_all_sessions_by_pattern_command.cpp @@ -88,7 +88,7 @@ public: } virtual bool run(OperationContext* opCtx, - const std::string& db, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { IDLParserContext ctx("KillAllSessionsByPatternCmd"); diff --git a/src/mongo/db/commands/kill_all_sessions_command.cpp b/src/mongo/db/commands/kill_all_sessions_command.cpp index c9c344b2252..73717c15c2f 100644 --- a/src/mongo/db/commands/kill_all_sessions_command.cpp +++ b/src/mongo/db/commands/kill_all_sessions_command.cpp @@ -88,7 +88,7 @@ public: } virtual bool run(OperationContext* opCtx, - const std::string& db, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { IDLParserContext ctx("KillAllSessionsCmd"); diff --git a/src/mongo/db/commands/kill_op.cpp b/src/mongo/db/commands/kill_op.cpp index fc00f0a1a08..633b10ef325 100644 --- a/src/mongo/db/commands/kill_op.cpp +++ b/src/mongo/db/commands/kill_op.cpp @@ -53,7 +53,7 @@ namespace mongo { class KillOpCommand : public KillOpCmdBase { public: bool run(OperationContext* opCtx, - const std::string& db, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) final { long long opId = KillOpCmdBase::parseOpId(cmdObj); @@ -62,7 +62,7 @@ public: result.append("info", "attempting to kill op"); LOGV2(20482, "Going to kill op: {opId}", "Going to kill op", "opId"_attr = opId); KillOpCmdBase::killLocalOperation(opCtx, opId); - reportSuccessfulCompletion(opCtx, db, cmdObj); + reportSuccessfulCompletion(opCtx, dbName, cmdObj); // killOp always reports success once past the auth check. return true; diff --git a/src/mongo/db/commands/kill_op_cmd_base.cpp b/src/mongo/db/commands/kill_op_cmd_base.cpp index a056e6cc514..c8595618488 100644 --- a/src/mongo/db/commands/kill_op_cmd_base.cpp +++ b/src/mongo/db/commands/kill_op_cmd_base.cpp @@ -45,7 +45,7 @@ namespace mongo { void KillOpCmdBase::reportSuccessfulCompletion(OperationContext* opCtx, - const std::string& db, + const DatabaseName& dbName, const BSONObj& cmdObj) { logv2::DynamicAttributes attr; @@ -69,7 +69,7 @@ void KillOpCmdBase::reportSuccessfulCompletion(OperationContext* opCtx, } } - attr.add("db", db); + attr.add("db", dbName.db()); attr.add("command", cmdObj); LOGV2(558700, "Successful killOp", attr); diff --git a/src/mongo/db/commands/kill_op_cmd_base.h b/src/mongo/db/commands/kill_op_cmd_base.h index 57c914eb182..7439daddeeb 100644 --- a/src/mongo/db/commands/kill_op_cmd_base.h +++ b/src/mongo/db/commands/kill_op_cmd_base.h @@ -73,7 +73,7 @@ protected: static unsigned int parseOpId(const BSONObj& cmdObj); static void reportSuccessfulCompletion(OperationContext* opCtx, - const std::string& db, + const DatabaseName& dbName, const BSONObj& cmdObj); /** diff --git a/src/mongo/db/commands/kill_sessions_command.cpp b/src/mongo/db/commands/kill_sessions_command.cpp index 572f98d204e..2e237c4e7f6 100644 --- a/src/mongo/db/commands/kill_sessions_command.cpp +++ b/src/mongo/db/commands/kill_sessions_command.cpp @@ -108,7 +108,7 @@ public: } virtual bool run(OperationContext* opCtx, - const std::string& db, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { IDLParserContext ctx("KillSessionsCmd"); diff --git a/src/mongo/db/commands/lock_info.cpp b/src/mongo/db/commands/lock_info.cpp index df5715602a9..525c0a31671 100644 --- a/src/mongo/db/commands/lock_info.cpp +++ b/src/mongo/db/commands/lock_info.cpp @@ -75,7 +75,7 @@ public: CmdLockInfo() : BasicCommand("lockInfo") {} bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& jsobj, BSONObjBuilder& result) { auto lockToClientMap = LockManager::getLockToClientMap(opCtx->getServiceContext()); diff --git a/src/mongo/db/commands/oplog_note.cpp b/src/mongo/db/commands/oplog_note.cpp index 040aac464d1..c7017f99b2d 100644 --- a/src/mongo/db/commands/oplog_note.cpp +++ b/src/mongo/db/commands/oplog_note.cpp @@ -118,7 +118,7 @@ public: } virtual bool run(OperationContext* opCtx, - const string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { hangInAppendOplogNote.pauseWhileSet(); diff --git a/src/mongo/db/commands/plan_cache_clear_command.cpp b/src/mongo/db/commands/plan_cache_clear_command.cpp index 880c7098cca..05107ba795f 100644 --- a/src/mongo/db/commands/plan_cache_clear_command.cpp +++ b/src/mongo/db/commands/plan_cache_clear_command.cpp @@ -142,7 +142,7 @@ public: PlanCacheClearCommand() : BasicCommand("planCacheClear") {} bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override; @@ -177,10 +177,10 @@ Status PlanCacheClearCommand::checkAuthForCommand(Client* client, } bool PlanCacheClearCommand::run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) { - const NamespaceString nss(CommandHelpers::parseNsCollectionRequired(dbname, cmdObj)); + const NamespaceString nss(CommandHelpers::parseNsCollectionRequired(dbName, cmdObj)); // This is a read lock. The query cache is owned by the collection. AutoGetCollectionForReadCommand ctx(opCtx, nss); diff --git a/src/mongo/db/commands/profile_common.cpp b/src/mongo/db/commands/profile_common.cpp index c9f06aef56b..a35e9e7bf3e 100644 --- a/src/mongo/db/commands/profile_common.cpp +++ b/src/mongo/db/commands/profile_common.cpp @@ -68,7 +68,7 @@ Status ProfileCmdBase::checkAuthForCommand(Client* client, } bool ProfileCmdBase::run(OperationContext* opCtx, - const std::string& dbName, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) { auto request = ProfileCmdRequest::parse(IDLParserContext("profile"), cmdObj); @@ -81,11 +81,9 @@ bool ProfileCmdBase::run(OperationContext* opCtx, *sampleRate >= 0.0 && *sampleRate <= 1.0); } - // TODO SERVER-67459: For _applyProfilingLevel, takes the passed in "const DatabaseName& dbName" - // directly. // Delegate to _applyProfilingLevel to set the profiling level appropriately whether // we are on mongoD or mongoS. - auto oldSettings = _applyProfilingLevel(opCtx, {boost::none, dbName}, request); + auto oldSettings = _applyProfilingLevel(opCtx, dbName, request); auto oldSlowMS = serverGlobalParams.slowMS; auto oldSampleRate = serverGlobalParams.sampleRate; @@ -124,14 +122,10 @@ bool ProfileCmdBase::run(OperationContext* opCtx, } attrs.add("from", oldState.obj()); - // TODO SERVER-67459: For getDatabaseProfileSettings, takes the passed in "const - // DatabaseName& dbName" directly. - // newSettings.level may differ from profilingLevel: profilingLevel is part of the request, // and if the request specifies {profile: -1, ...} then we want to show the unchanged value // (0, 1, or 2). - auto newSettings = - CollectionCatalog::get(opCtx)->getDatabaseProfileSettings({boost::none, dbName}); + auto newSettings = CollectionCatalog::get(opCtx)->getDatabaseProfileSettings(dbName); newState.append("level"_sd, newSettings.level); newState.append("slowms"_sd, serverGlobalParams.slowMS); newState.append("sampleRate"_sd, serverGlobalParams.sampleRate); diff --git a/src/mongo/db/commands/profile_common.h b/src/mongo/db/commands/profile_common.h index adab840ff63..e691636bf8b 100644 --- a/src/mongo/db/commands/profile_common.h +++ b/src/mongo/db/commands/profile_common.h @@ -69,7 +69,7 @@ public: const BSONObj& cmdObj) const final; bool run(OperationContext* opCtx, - const std::string& dbName, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) final; diff --git a/src/mongo/db/commands/reap_logical_session_cache_now.cpp b/src/mongo/db/commands/reap_logical_session_cache_now.cpp index c1a4d9baf65..a53aef63fdd 100644 --- a/src/mongo/db/commands/reap_logical_session_cache_now.cpp +++ b/src/mongo/db/commands/reap_logical_session_cache_now.cpp @@ -66,7 +66,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& db, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { const auto cache = LogicalSessionCache::get(opCtx); diff --git a/src/mongo/db/commands/refresh_logical_session_cache_now.cpp b/src/mongo/db/commands/refresh_logical_session_cache_now.cpp index 2580b4f427d..a22ca5e4897 100644 --- a/src/mongo/db/commands/refresh_logical_session_cache_now.cpp +++ b/src/mongo/db/commands/refresh_logical_session_cache_now.cpp @@ -70,7 +70,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& db, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { const auto cache = LogicalSessionCache::get(opCtx); diff --git a/src/mongo/db/commands/resize_oplog.cpp b/src/mongo/db/commands/resize_oplog.cpp index 8a834ec2af0..5aa3c693dab 100644 --- a/src/mongo/db/commands/resize_oplog.cpp +++ b/src/mongo/db/commands/resize_oplog.cpp @@ -79,7 +79,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& jsobj, BSONObjBuilder& result) { AutoGetCollection coll(opCtx, NamespaceString::kRsOplogNamespace, MODE_X); diff --git a/src/mongo/db/commands/server_status_command.cpp b/src/mongo/db/commands/server_status_command.cpp index eccd2c0174c..b98e6fc4cd2 100644 --- a/src/mongo/db/commands/server_status_command.cpp +++ b/src/mongo/db/commands/server_status_command.cpp @@ -75,7 +75,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) final { const auto service = opCtx->getServiceContext(); 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 6c2fe8f8387..d8c4e8a88e4 100644 --- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp +++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp @@ -260,7 +260,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { // Always wait for at least majority writeConcern to ensure all writes involved in the diff --git a/src/mongo/db/commands/sleep_command.cpp b/src/mongo/db/commands/sleep_command.cpp index 8a56e807e75..156615b2f4c 100644 --- a/src/mongo/db/commands/sleep_command.cpp +++ b/src/mongo/db/commands/sleep_command.cpp @@ -141,7 +141,7 @@ public: CmdSleep() : BasicCommand("sleep") {} bool run(OperationContext* opCtx, - const std::string& ns, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { LOGV2(20504, "Test-only command 'sleep' invoked"); diff --git a/src/mongo/db/commands/snapshot_management.cpp b/src/mongo/db/commands/snapshot_management.cpp index fc72c038c14..5dfcab27983 100644 --- a/src/mongo/db/commands/snapshot_management.cpp +++ b/src/mongo/db/commands/snapshot_management.cpp @@ -67,7 +67,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { auto snapshotManager = getGlobalServiceContext()->getStorageEngine()->getSnapshotManager(); @@ -112,7 +112,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { auto snapshotManager = getGlobalServiceContext()->getStorageEngine()->getSnapshotManager(); diff --git a/src/mongo/db/commands/start_session_command.cpp b/src/mongo/db/commands/start_session_command.cpp index 02293532a34..cdb16ca1fdf 100644 --- a/src/mongo/db/commands/start_session_command.cpp +++ b/src/mongo/db/commands/start_session_command.cpp @@ -77,7 +77,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& db, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { const auto service = opCtx->getServiceContext(); diff --git a/src/mongo/db/commands/test_api_version_2_commands.cpp b/src/mongo/db/commands/test_api_version_2_commands.cpp index 738e13b1366..be228e1afe3 100644 --- a/src/mongo/db/commands/test_api_version_2_commands.cpp +++ b/src/mongo/db/commands/test_api_version_2_commands.cpp @@ -52,7 +52,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { auto apiParameters = APIParameters::get(opCtx); @@ -78,7 +78,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { auto apiParameters = APIParameters::get(opCtx); @@ -108,7 +108,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { auto apiParameters = APIParameters::get(opCtx); @@ -134,7 +134,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { auto apiParameters = APIParameters::get(opCtx); diff --git a/src/mongo/db/commands/test_commands.cpp b/src/mongo/db/commands/test_commands.cpp index 889129d269d..d40430c7143 100644 --- a/src/mongo/db/commands/test_commands.cpp +++ b/src/mongo/db/commands/test_commands.cpp @@ -137,10 +137,10 @@ public: const BSONObj& cmdObj, std::vector<Privilege>* out) const {} virtual bool run(OperationContext* opCtx, - const string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) { - const NamespaceString fullNs = CommandHelpers::parseNsCollectionRequired(dbname, cmdObj); + const NamespaceString fullNs = CommandHelpers::parseNsCollectionRequired(dbName, cmdObj); if (!fullNs.isValid()) { uasserted(ErrorCodes::InvalidNamespace, str::stream() << "collection name " << fullNs.ns() << " is not valid"); @@ -210,10 +210,10 @@ public: std::vector<Privilege>* out) const {} virtual bool run(OperationContext* opCtx, - const string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) { - const NamespaceString nss = CommandHelpers::parseNsCollectionRequired(dbname, cmdObj); + const NamespaceString nss = CommandHelpers::parseNsCollectionRequired(dbName, cmdObj); uassertStatusOK(emptyCapped(opCtx, nss)); return true; @@ -252,7 +252,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override { const Timestamp requestedPinTs = cmdObj.firstElement().timestamp(); diff --git a/src/mongo/db/commands/test_deprecation_command.cpp b/src/mongo/db/commands/test_deprecation_command.cpp index 74d93942ddd..4e4362322ed 100644 --- a/src/mongo/db/commands/test_deprecation_command.cpp +++ b/src/mongo/db/commands/test_deprecation_command.cpp @@ -69,7 +69,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { APIParameters::get(opCtx).appendInfo(&result); diff --git a/src/mongo/db/commands/top_command.cpp b/src/mongo/db/commands/top_command.cpp index 50999b993c1..bea0c20f800 100644 --- a/src/mongo/db/commands/top_command.cpp +++ b/src/mongo/db/commands/top_command.cpp @@ -67,7 +67,7 @@ public: out->push_back(Privilege(ResourcePattern::forClusterResource(), actions)); } virtual bool run(OperationContext* opCtx, - const std::string& db, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { { diff --git a/src/mongo/db/commands/validate.cpp b/src/mongo/db/commands/validate.cpp index 8d0313fcc44..27c7fd14670 100644 --- a/src/mongo/db/commands/validate.cpp +++ b/src/mongo/db/commands/validate.cpp @@ -122,7 +122,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) { if (MONGO_unlikely(validateCmdCollectionNotValid.shouldFail())) { @@ -130,7 +130,7 @@ public: return true; } - const NamespaceString nss(CommandHelpers::parseNsCollectionRequired(dbname, cmdObj)); + const NamespaceString nss(CommandHelpers::parseNsCollectionRequired(dbName, cmdObj)); bool background = cmdObj["background"].trueValue(); const bool fullValidate = cmdObj["full"].trueValue(); diff --git a/src/mongo/db/commands/whats_my_sni_command.cpp b/src/mongo/db/commands/whats_my_sni_command.cpp index c70d8b82a13..f0d1838b312 100644 --- a/src/mongo/db/commands/whats_my_sni_command.cpp +++ b/src/mongo/db/commands/whats_my_sni_command.cpp @@ -42,7 +42,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& ns, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { auto sniName = opCtx->getClient()->getSniNameForSession(); diff --git a/src/mongo/db/commands/whats_my_uri_cmd.cpp b/src/mongo/db/commands/whats_my_uri_cmd.cpp index 6c6b30fb876..33634534444 100644 --- a/src/mongo/db/commands/whats_my_uri_cmd.cpp +++ b/src/mongo/db/commands/whats_my_uri_cmd.cpp @@ -60,7 +60,7 @@ public: std::vector<Privilege>* out) const override {} // No auth required bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { result << "you" << opCtx->getClient()->clientAddress(true /*includePort*/); diff --git a/src/mongo/db/exec/stagedebug_cmd.cpp b/src/mongo/db/exec/stagedebug_cmd.cpp index a4548ce4a4c..3d52323be75 100644 --- a/src/mongo/db/exec/stagedebug_cmd.cpp +++ b/src/mongo/db/exec/stagedebug_cmd.cpp @@ -124,7 +124,7 @@ public: } bool run(OperationContext* opCtx, - const string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) { BSONElement argElt = cmdObj["stageDebug"]; @@ -139,7 +139,7 @@ public: return false; } - const NamespaceString nss(dbname, collElt.String()); + const NamespaceString nss(dbName, collElt.String()); uassert(ErrorCodes::InvalidNamespace, str::stream() << nss.toString() << " is not a valid namespace", nss.isValid()); diff --git a/src/mongo/db/free_mon/free_mon_commands.cpp b/src/mongo/db/free_mon/free_mon_commands.cpp index d3e28b13a3f..d1fa55285f1 100644 --- a/src/mongo/db/free_mon/free_mon_commands.cpp +++ b/src/mongo/db/free_mon/free_mon_commands.cpp @@ -76,7 +76,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) final { // Command has no members, invoke the parser to confirm that. @@ -132,7 +132,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) final { IDLParserContext ctx("setFreeMonitoring"); diff --git a/src/mongo/db/free_mon/free_mon_commands_stub.cpp b/src/mongo/db/free_mon/free_mon_commands_stub.cpp index 0cde267410d..7a9942ccee2 100644 --- a/src/mongo/db/free_mon/free_mon_commands_stub.cpp +++ b/src/mongo/db/free_mon/free_mon_commands_stub.cpp @@ -74,7 +74,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) final { // Command has no members, invoke the parser to confirm that. diff --git a/src/mongo/db/ftdc/ftdc_commands.cpp b/src/mongo/db/ftdc/ftdc_commands.cpp index aa274c1858e..12b604ce9cf 100644 --- a/src/mongo/db/ftdc/ftdc_commands.cpp +++ b/src/mongo/db/ftdc/ftdc_commands.cpp @@ -90,7 +90,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& db, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { diff --git a/src/mongo/db/repl/repl_set_commands.cpp b/src/mongo/db/repl/repl_set_commands.cpp index a5988938b6a..97a1e2ac1cd 100644 --- a/src/mongo/db/repl/repl_set_commands.cpp +++ b/src/mongo/db/repl/repl_set_commands.cpp @@ -101,7 +101,7 @@ public: } CmdReplSetTest() : ReplSetCommand("replSetTest") {} virtual bool run(OperationContext* opCtx, - const string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { LOGV2(21573, @@ -186,7 +186,7 @@ class CmdReplSetGetRBID : public ReplSetCommand { public: CmdReplSetGetRBID() : ReplSetCommand("replSetGetRBID") {} virtual bool run(OperationContext* opCtx, - const string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result); @@ -206,7 +206,7 @@ public: } CmdReplSetGetConfig() : ReplSetCommand("replSetGetConfig") {} virtual bool run(OperationContext* opCtx, - const string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result); @@ -338,7 +338,7 @@ public: "http://dochub.mongodb.org/core/replicasetcommands"; } virtual bool run(OperationContext* opCtx, - const string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { BSONObj configObj; @@ -433,7 +433,7 @@ public: } bool run(OperationContext* opCtx, - const string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { const auto replCoord = ReplicationCoordinator::get(opCtx); @@ -501,7 +501,7 @@ public: } CmdReplSetFreeze() : ReplSetCommand("replSetFreeze") {} virtual bool run(OperationContext* opCtx, - const string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result); @@ -536,7 +536,7 @@ public: CmdReplSetStepDown() : ReplSetCommand("replSetStepDown") {} virtual bool run(OperationContext* opCtx, - const string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { const bool force = cmdObj["force"].trueValue(); @@ -616,7 +616,7 @@ public: } CmdReplSetMaintenance() : ReplSetCommand("replSetMaintenance") {} virtual bool run(OperationContext* opCtx, - const string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result); @@ -642,7 +642,7 @@ public: } CmdReplSetSyncFrom() : ReplSetCommand("replSetSyncFrom") {} virtual bool run(OperationContext* opCtx, - const string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result); @@ -667,7 +667,7 @@ class CmdReplSetUpdatePosition : public ReplSetCommand { public: CmdReplSetUpdatePosition() : ReplSetCommand("replSetUpdatePosition") {} virtual bool run(OperationContext* opCtx, - const string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { auto replCoord = repl::ReplicationCoordinator::get(opCtx->getClient()->getServiceContext()); @@ -744,7 +744,7 @@ class CmdReplSetHeartbeat : public ReplSetCommand { public: CmdReplSetHeartbeat() : ReplSetCommand("replSetHeartbeat") {} virtual bool run(OperationContext* opCtx, - const string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { rsDelayHeartbeatResponse.execute( @@ -795,7 +795,7 @@ public: CmdReplSetStepUp() : ReplSetCommand("replSetStepUp") {} virtual bool run(OperationContext* opCtx, - const string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result); @@ -834,7 +834,7 @@ public: CmdReplSetAbortPrimaryCatchUp() : ReplSetCommand("replSetAbortPrimaryCatchUp") {} virtual bool run(OperationContext* opCtx, - const string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result); diff --git a/src/mongo/db/repl/repl_set_get_status_cmd.cpp b/src/mongo/db/repl/repl_set_get_status_cmd.cpp index ad4fe674ccd..7b4e4a171dd 100644 --- a/src/mongo/db/repl/repl_set_get_status_cmd.cpp +++ b/src/mongo/db/repl/repl_set_get_status_cmd.cpp @@ -46,7 +46,7 @@ public: CmdReplSetGetStatus() : ReplSetCommand("replSetGetStatus") {} bool run(OperationContext* opCtx, - const std::string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { if (cmdObj["forShell"].trueValue()) diff --git a/src/mongo/db/repl/repl_set_request_votes.cpp b/src/mongo/db/repl/repl_set_request_votes.cpp index 2654bc24ccb..3d2c77ea143 100644 --- a/src/mongo/db/repl/repl_set_request_votes.cpp +++ b/src/mongo/db/repl/repl_set_request_votes.cpp @@ -49,7 +49,7 @@ public: private: bool run(OperationContext* opCtx, - const std::string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) final { Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result); diff --git a/src/mongo/db/s/clone_catalog_data_command.cpp b/src/mongo/db/s/clone_catalog_data_command.cpp index b0df5c0cb98..b996368e454 100644 --- a/src/mongo/db/s/clone_catalog_data_command.cpp +++ b/src/mongo/db/s/clone_catalog_data_command.cpp @@ -86,7 +86,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname_unused, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { 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 d35c3a38062..c8d2a1cc685 100644 --- a/src/mongo/db/s/config/configsvr_add_shard_command.cpp +++ b/src/mongo/db/s/config/configsvr_add_shard_command.cpp @@ -94,7 +94,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& unusedDbName, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { uassert(ErrorCodes::IllegalOperation, 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 cb0c78ce8e4..141fe3d9ddb 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 @@ -93,7 +93,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& unusedDbName, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { uassert(ErrorCodes::IllegalOperation, 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 399a8924fe4..b02a6b1a266 100644 --- a/src/mongo/db/s/config/configsvr_control_balancer_command.cpp +++ b/src/mongo/db/s/config/configsvr_control_balancer_command.cpp @@ -81,7 +81,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& unusedDbName, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) final { uassert(ErrorCodes::InternalError, 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 cfa02c94711..10c19ab53d8 100644 --- a/src/mongo/db/s/config/configsvr_move_chunk_command.cpp +++ b/src/mongo/db/s/config/configsvr_move_chunk_command.cpp @@ -83,7 +83,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& unusedDbName, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { uassert(ErrorCodes::IllegalOperation, diff --git a/src/mongo/db/s/config/configsvr_remove_shard_command.cpp b/src/mongo/db/s/config/configsvr_remove_shard_command.cpp index 167f9be672f..a17fb730363 100644 --- a/src/mongo/db/s/config/configsvr_remove_shard_command.cpp +++ b/src/mongo/db/s/config/configsvr_remove_shard_command.cpp @@ -94,7 +94,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { uassert(ErrorCodes::IllegalOperation, 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 6146e133fa7..1be2824081e 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 @@ -96,7 +96,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& unusedDbName, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { uassert(ErrorCodes::IllegalOperation, diff --git a/src/mongo/db/s/config/configsvr_repair_sharded_collection_chunks_history_command.cpp b/src/mongo/db/s/config/configsvr_repair_sharded_collection_chunks_history_command.cpp index 6413f26e5ef..a91151f12f7 100644 --- a/src/mongo/db/s/config/configsvr_repair_sharded_collection_chunks_history_command.cpp +++ b/src/mongo/db/s/config/configsvr_repair_sharded_collection_chunks_history_command.cpp @@ -83,7 +83,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& unusedDbName, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override { uassert(ErrorCodes::IllegalOperation, @@ -96,7 +96,7 @@ public: CommandHelpers::uassertCommandRunWithMajority(getName(), opCtx->getWriteConcern()); - const NamespaceString nss{parseNs({boost::none, unusedDbName}, cmdObj)}; + const NamespaceString nss{parseNs(dbName, cmdObj)}; auto currentTime = VectorClock::get(opCtx)->getTime(); auto validAfter = currentTime.configTime().asTimestamp(); diff --git a/src/mongo/db/s/config/configsvr_run_restore_command.cpp b/src/mongo/db/s/config/configsvr_run_restore_command.cpp index 021f454128d..4790aefa1f8 100644 --- a/src/mongo/db/s/config/configsvr_run_restore_command.cpp +++ b/src/mongo/db/s/config/configsvr_run_restore_command.cpp @@ -142,7 +142,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname_unused, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { uassert(ErrorCodes::CommandFailed, 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 3e8fef11c20..713f7252356 100644 --- a/src/mongo/db/s/config/configsvr_split_chunk_command.cpp +++ b/src/mongo/db/s/config/configsvr_split_chunk_command.cpp @@ -106,7 +106,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbName, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { uassert(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 f185235c1b8..fa562f8b04c 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 @@ -98,7 +98,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& unusedDbName, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { uassert(ErrorCodes::IllegalOperation, diff --git a/src/mongo/db/s/get_shard_version_command.cpp b/src/mongo/db/s/get_shard_version_command.cpp index 1ad1689faf8..858e1be224f 100644 --- a/src/mongo/db/s/get_shard_version_command.cpp +++ b/src/mongo/db/s/get_shard_version_command.cpp @@ -81,10 +81,10 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override { - const NamespaceString nss(parseNs({boost::none, dbname}, cmdObj)); + const NamespaceString nss(parseNs(dbName, cmdObj)); uassertStatusOK(ShardingState::get(opCtx)->canAcceptShardedCommands()); 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 376f3d35880..7f64c9614ad 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 @@ -155,7 +155,7 @@ public: } bool run(OperationContext* opCtx, - const std::string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { const MigrationSessionId migrationSessionId( @@ -222,7 +222,7 @@ public: } bool run(OperationContext* opCtx, - const std::string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { const MigrationSessionId migrationSessionId( @@ -336,7 +336,7 @@ public: } bool run(OperationContext* opCtx, - const std::string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { const MigrationSessionId migrationSessionId( 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 89d2183de79..8e2ab56f624 100644 --- a/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp +++ b/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp @@ -193,7 +193,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { bool waitForSteadyOrDone = cmdObj["waitForSteadyOrDone"].boolean(); @@ -238,7 +238,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName& dbname, const BSONObj& cmdObj, BSONObjBuilder& result) override { auto const sessionId = uassertStatusOK(MigrationSessionId::extractFromBSON(cmdObj)); @@ -292,7 +292,7 @@ public: } bool run(OperationContext* opCtx, - const std::string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { auto const mdm = MigrationDestinationManager::get(opCtx); @@ -350,7 +350,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { opCtx->setAlwaysInterruptAtStepDownOrUp_UNSAFE(); diff --git a/src/mongo/db/s/sharding_state_command.cpp b/src/mongo/db/s/sharding_state_command.cpp index 1af025a2ecc..c9f43ea3e0f 100644 --- a/src/mongo/db/s/sharding_state_command.cpp +++ b/src/mongo/db/s/sharding_state_command.cpp @@ -69,7 +69,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { auto const shardingState = ShardingState::get(opCtx); diff --git a/src/mongo/db/s/shardsvr_move_primary_command.cpp b/src/mongo/db/s/shardsvr_move_primary_command.cpp index a0f95e47e13..3f08102515d 100644 --- a/src/mongo/db/s/shardsvr_move_primary_command.cpp +++ b/src/mongo/db/s/shardsvr_move_primary_command.cpp @@ -87,7 +87,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname_unused, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { uassertStatusOK(ShardingState::get(opCtx)->canAcceptShardedCommands()); diff --git a/src/mongo/db/s/wait_for_ongoing_chunk_splits_command.cpp b/src/mongo/db/s/wait_for_ongoing_chunk_splits_command.cpp index e61b02e6777..c354c46f517 100644 --- a/src/mongo/db/s/wait_for_ongoing_chunk_splits_command.cpp +++ b/src/mongo/db/s/wait_for_ongoing_chunk_splits_command.cpp @@ -75,7 +75,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& db, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { ChunkSplitter::get(opCtx).waitForIdle(); diff --git a/src/mongo/embedded/embedded_ismaster.cpp b/src/mongo/embedded/embedded_ismaster.cpp index b2a26796d62..3894f9b83d5 100644 --- a/src/mongo/embedded/embedded_ismaster.cpp +++ b/src/mongo/embedded/embedded_ismaster.cpp @@ -67,7 +67,7 @@ public: CmdIsMaster() : BasicCommand("isMaster", "ismaster") {} virtual bool run(OperationContext* opCtx, - const std::string&, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { diff --git a/src/mongo/s/commands/cluster_add_shard_cmd.cpp b/src/mongo/s/commands/cluster_add_shard_cmd.cpp index 25831702d90..9b7e013accd 100644 --- a/src/mongo/s/commands/cluster_add_shard_cmd.cpp +++ b/src/mongo/s/commands/cluster_add_shard_cmd.cpp @@ -74,7 +74,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { 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 764b154bbd0..4c6dc7e762b 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 @@ -101,7 +101,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { auto parsedRequest = uassertStatusOK(AddShardToZoneRequest::parseFromMongosCommand(cmdObj)); diff --git a/src/mongo/s/commands/cluster_build_info.cpp b/src/mongo/s/commands/cluster_build_info.cpp index 742ab9832eb..c946ab8e6af 100644 --- a/src/mongo/s/commands/cluster_build_info.cpp +++ b/src/mongo/s/commands/cluster_build_info.cpp @@ -100,7 +100,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& jsobj, BSONObjBuilder& result) final { VersionInfoInterface::instance().appendBuildInfo(&result); diff --git a/src/mongo/s/commands/cluster_coll_stats_cmd.cpp b/src/mongo/s/commands/cluster_coll_stats_cmd.cpp index fc879a34605..25b3e15b578 100644 --- a/src/mongo/s/commands/cluster_coll_stats_cmd.cpp +++ b/src/mongo/s/commands/cluster_coll_stats_cmd.cpp @@ -191,10 +191,10 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbName, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override { - const NamespaceString nss(parseNs({boost::none, dbName}, cmdObj)); + const NamespaceString nss(parseNs(dbName, cmdObj)); const auto targeter = ChunkManagerTargeter(opCtx, nss); const auto cm = targeter.getRoutingInfo(); diff --git a/src/mongo/s/commands/cluster_compact_cmd.cpp b/src/mongo/s/commands/cluster_compact_cmd.cpp index f5df95fbe92..055e8d81688 100644 --- a/src/mongo/s/commands/cluster_compact_cmd.cpp +++ b/src/mongo/s/commands/cluster_compact_cmd.cpp @@ -59,7 +59,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbName, + const DatabaseName&, const BSONObj& cmdObj, 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 c7ac1734bb8..2cf2bfd5eef 100644 --- a/src/mongo/s/commands/cluster_control_balancer_cmd.cpp +++ b/src/mongo/s/commands/cluster_control_balancer_cmd.cpp @@ -86,7 +86,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard(); diff --git a/src/mongo/s/commands/cluster_convert_to_capped_cmd.cpp b/src/mongo/s/commands/cluster_convert_to_capped_cmd.cpp index 7251ddc61c6..35f7e9d9701 100644 --- a/src/mongo/s/commands/cluster_convert_to_capped_cmd.cpp +++ b/src/mongo/s/commands/cluster_convert_to_capped_cmd.cpp @@ -42,7 +42,7 @@ namespace mongo { namespace { bool nonShardedCollectionCommandPassthrough(OperationContext* opCtx, - StringData dbName, + const DatabaseName& dbName, const NamespaceString& nss, const ChunkManager& cm, const BSONObj& cmdObj, @@ -53,8 +53,15 @@ bool nonShardedCollectionCommandPassthrough(OperationContext* opCtx, str::stream() << "Can't do command: " << cmdName << " on a sharded collection", !cm.isSharded()); - auto responses = scatterGatherVersionedTargetByRoutingTable( - opCtx, dbName, nss, cm, cmdObj, ReadPreferenceSetting::get(opCtx), retryPolicy, {}, {}); + auto responses = scatterGatherVersionedTargetByRoutingTable(opCtx, + dbName.toStringWithTenantId(), + nss, + cm, + cmdObj, + ReadPreferenceSetting::get(opCtx), + retryPolicy, + {}, + {}); invariant(responses.size() == 1); const auto cmdResponse = uassertStatusOK(std::move(responses.front().swResponse)); @@ -93,10 +100,10 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbName, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override { - const NamespaceString nss(parseNs({boost::none, dbName}, cmdObj)); + const NamespaceString nss(parseNs(dbName, cmdObj)); const auto cm = uassertStatusOK(Grid::get(opCtx)->catalogCache()->getCollectionRoutingInfo(opCtx, nss)); uassert(ErrorCodes::IllegalOperation, diff --git a/src/mongo/s/commands/cluster_distinct_cmd.cpp b/src/mongo/s/commands/cluster_distinct_cmd.cpp index b15ed932677..a14afdd4063 100644 --- a/src/mongo/s/commands/cluster_distinct_cmd.cpp +++ b/src/mongo/s/commands/cluster_distinct_cmd.cpp @@ -181,11 +181,11 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbName, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override { CommandHelpers::handleMarkKillOnClientDisconnect(opCtx); - const NamespaceString nss(parseNs({boost::none, dbName}, cmdObj)); + const NamespaceString nss(parseNs(dbName, cmdObj)); auto parsedDistinctCmd = ParsedDistinct::parse(opCtx, nss, cmdObj, ExtensionsCallbackNoop(), false); @@ -249,7 +249,7 @@ public: } BSONObj aggResult = CommandHelpers::runCommandDirectly( - opCtx, OpMsgRequest::fromDBAndBody(dbName, std::move(resolvedAggCmd))); + opCtx, OpMsgRequest::fromDBAndBody(dbName.db(), std::move(resolvedAggCmd))); ViewResponseFormatter formatter(aggResult); auto formatStatus = formatter.appendAsDistinctResponse(&result); diff --git a/src/mongo/s/commands/cluster_filemd5_cmd.cpp b/src/mongo/s/commands/cluster_filemd5_cmd.cpp index 0bd0a711fc2..3922205749c 100644 --- a/src/mongo/s/commands/cluster_filemd5_cmd.cpp +++ b/src/mongo/s/commands/cluster_filemd5_cmd.cpp @@ -82,10 +82,10 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbName, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override { - const NamespaceString nss(parseNs({boost::none, dbName}, cmdObj)); + const NamespaceString nss(parseNs(dbName, cmdObj)); const auto cm = uassertStatusOK(Grid::get(opCtx)->catalogCache()->getCollectionRoutingInfo(opCtx, nss)); 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 657e1e9086d..f789a6cf7b2 100644 --- a/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp +++ b/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp @@ -457,7 +457,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbName, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override { const NamespaceString nss(CommandHelpers::parseNsCollectionRequired(dbName, cmdObj)); 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 2e7766c4767..008a4d349e3 100644 --- a/src/mongo/s/commands/cluster_get_last_error_cmd.cpp +++ b/src/mongo/s/commands/cluster_get_last_error_cmd.cpp @@ -61,7 +61,7 @@ public: return false; } - virtual bool run(OperationContext*, const std::string&, const BSONObj&, BSONObjBuilder&) { + virtual bool run(OperationContext*, const DatabaseName&, const BSONObj&, BSONObjBuilder&) { uasserted(5739001, "getLastError command is not supported"); return false; } 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 94e4b2a6cf4..5b4eebb96b8 100644 --- a/src/mongo/s/commands/cluster_get_shard_version_cmd.cpp +++ b/src/mongo/s/commands/cluster_get_shard_version_cmd.cpp @@ -85,11 +85,10 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override { - const NamespaceString nss(parseNs({boost::none, dbname}, cmdObj)); - + const NamespaceString nss(parseNs(dbName, cmdObj)); const auto catalogCache = Grid::get(opCtx)->catalogCache(); if (nss.coll().empty()) { diff --git a/src/mongo/s/commands/cluster_index_filter_cmd.cpp b/src/mongo/s/commands/cluster_index_filter_cmd.cpp index eafe9b8b539..26fecc0ae19 100644 --- a/src/mongo/s/commands/cluster_index_filter_cmd.cpp +++ b/src/mongo/s/commands/cluster_index_filter_cmd.cpp @@ -87,10 +87,10 @@ public: // Cluster plan cache command entry point. bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override { - const NamespaceString nss(parseNs({boost::none, dbname}, cmdObj)); + const NamespaceString nss(parseNs(dbName, cmdObj)); const BSONObj query; const auto routingInfo = uassertStatusOK(Grid::get(opCtx)->catalogCache()->getCollectionRoutingInfo(opCtx, nss)); 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 c5e2358b6eb..6fc4f1b9263 100644 --- a/src/mongo/s/commands/cluster_is_db_grid_cmd.cpp +++ b/src/mongo/s/commands/cluster_is_db_grid_cmd.cpp @@ -58,7 +58,7 @@ public: } virtual bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { result.append("isdbgrid", 1); diff --git a/src/mongo/s/commands/cluster_kill_op.cpp b/src/mongo/s/commands/cluster_kill_op.cpp index 90cfb4eda20..8a49520da77 100644 --- a/src/mongo/s/commands/cluster_kill_op.cpp +++ b/src/mongo/s/commands/cluster_kill_op.cpp @@ -58,7 +58,7 @@ namespace { class ClusterKillOpCommand : public KillOpCmdBase { public: bool run(OperationContext* opCtx, - const std::string& db, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) final { BSONElement element = cmdObj.getField("op"); @@ -67,14 +67,14 @@ public: if (isKillingLocalOp(element)) { const unsigned int opId = KillOpCmdBase::parseOpId(cmdObj); killLocalOperation(opCtx, opId); - reportSuccessfulCompletion(opCtx, db, cmdObj); + reportSuccessfulCompletion(opCtx, dbName, cmdObj); // killOp always reports success once past the auth check. return true; } else if (element.type() == BSONType::String) { // It's a string. Should be of the form shardid:opid. if (_killShardOperation(opCtx, element.str(), result)) { - reportSuccessfulCompletion(opCtx, db, cmdObj); + reportSuccessfulCompletion(opCtx, dbName, cmdObj); return true; } else { return false; diff --git a/src/mongo/s/commands/cluster_list_shards_cmd.cpp b/src/mongo/s/commands/cluster_list_shards_cmd.cpp index 9834a1524dd..cb5fb91c6ec 100644 --- a/src/mongo/s/commands/cluster_list_shards_cmd.cpp +++ b/src/mongo/s/commands/cluster_list_shards_cmd.cpp @@ -65,7 +65,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { const auto opTimeWithShards = diff --git a/src/mongo/s/commands/cluster_move_primary_cmd.cpp b/src/mongo/s/commands/cluster_move_primary_cmd.cpp index 665fbc79dd4..b39a3f7f23d 100644 --- a/src/mongo/s/commands/cluster_move_primary_cmd.cpp +++ b/src/mongo/s/commands/cluster_move_primary_cmd.cpp @@ -91,12 +91,11 @@ public: } virtual bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) { auto request = MovePrimary::parse(IDLParserContext("MovePrimary"), cmdObj); - - const string db = parseNs({boost::none, ""}, cmdObj).dbName().db(); + const string db = parseNs(dbName, cmdObj).dbName().db(); const StringData toShard(request.getTo()); // Invalidate the routing table cache entry for this database so that we reload the diff --git a/src/mongo/s/commands/cluster_multicast_cmd.cpp b/src/mongo/s/commands/cluster_multicast_cmd.cpp index 4a38364c63b..90ff772122f 100644 --- a/src/mongo/s/commands/cluster_multicast_cmd.cpp +++ b/src/mongo/s/commands/cluster_multicast_cmd.cpp @@ -88,7 +88,7 @@ public: std::vector<Privilege>* out) const override {} bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { IDLParserContext ctx("ClusterMulticast"); diff --git a/src/mongo/s/commands/cluster_netstat_cmd.cpp b/src/mongo/s/commands/cluster_netstat_cmd.cpp index 273dd738d24..1b1fd469d6c 100644 --- a/src/mongo/s/commands/cluster_netstat_cmd.cpp +++ b/src/mongo/s/commands/cluster_netstat_cmd.cpp @@ -66,7 +66,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { auto const shardRegistry = Grid::get(opCtx)->shardRegistry(); diff --git a/src/mongo/s/commands/cluster_oplog_note_cmd.cpp b/src/mongo/s/commands/cluster_oplog_note_cmd.cpp index 1d4877ced9e..12c16f58ffc 100644 --- a/src/mongo/s/commands/cluster_oplog_note_cmd.cpp +++ b/src/mongo/s/commands/cluster_oplog_note_cmd.cpp @@ -83,13 +83,13 @@ public: } virtual bool run(OperationContext* opCtx, - const string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) { auto shardResponses = scatterGatherUnversionedTargetAllShards( opCtx, - dbname, + dbName.toStringWithTenantId(), applyReadWriteConcern( opCtx, this, CommandHelpers::filterCommandRequestForPassthrough(cmdObj)), ReadPreferenceSetting::get(opCtx), diff --git a/src/mongo/s/commands/cluster_plan_cache_clear_cmd.cpp b/src/mongo/s/commands/cluster_plan_cache_clear_cmd.cpp index 1736e5eb233..cd042d46071 100644 --- a/src/mongo/s/commands/cluster_plan_cache_clear_cmd.cpp +++ b/src/mongo/s/commands/cluster_plan_cache_clear_cmd.cpp @@ -87,13 +87,13 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result); } clusterPlanCacheClearCmd; bool ClusterPlanCacheClearCmd::run(OperationContext* opCtx, - const std::string& dbName, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) { const NamespaceString nss(CommandHelpers::parseNsCollectionRequired(dbName, cmdObj)); diff --git a/src/mongo/s/commands/cluster_remove_shard_cmd.cpp b/src/mongo/s/commands/cluster_remove_shard_cmd.cpp index 20eb7f1c525..ef31d7dce15 100644 --- a/src/mongo/s/commands/cluster_remove_shard_cmd.cpp +++ b/src/mongo/s/commands/cluster_remove_shard_cmd.cpp @@ -72,7 +72,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { uassert(ErrorCodes::TypeMismatch, 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 74f4fadaea1..4b63870523a 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 @@ -113,7 +113,7 @@ public: } virtual bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { auto parsedRequest = diff --git a/src/mongo/s/commands/cluster_repair_sharded_collection_chunks_history_cmd.cpp b/src/mongo/s/commands/cluster_repair_sharded_collection_chunks_history_cmd.cpp index d78f985dad0..a3b154f0a1c 100644 --- a/src/mongo/s/commands/cluster_repair_sharded_collection_chunks_history_cmd.cpp +++ b/src/mongo/s/commands/cluster_repair_sharded_collection_chunks_history_cmd.cpp @@ -90,10 +90,10 @@ public: } bool run(OperationContext* opCtx, - const std::string& unusedDbName, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override { - const NamespaceString nss{parseNs({boost::none, unusedDbName}, cmdObj)}; + const NamespaceString nss{parseNs(dbName, cmdObj)}; BSONObjBuilder cmdBuilder( BSON("_configsvrRepairShardedCollectionChunksHistory" << nss.ns())); diff --git a/src/mongo/s/commands/cluster_rwc_defaults_commands.cpp b/src/mongo/s/commands/cluster_rwc_defaults_commands.cpp index 58d6c63891a..45b0652e37f 100644 --- a/src/mongo/s/commands/cluster_rwc_defaults_commands.cpp +++ b/src/mongo/s/commands/cluster_rwc_defaults_commands.cpp @@ -54,7 +54,7 @@ public: ClusterSetDefaultRWConcernCommand() : BasicCommand("setDefaultRWConcern") {} bool run(OperationContext* opCtx, - const std::string& dbName, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard(); diff --git a/src/mongo/s/commands/cluster_set_free_monitoring_cmd.cpp b/src/mongo/s/commands/cluster_set_free_monitoring_cmd.cpp index d54cd80b219..f6f8b03b61a 100644 --- a/src/mongo/s/commands/cluster_set_free_monitoring_cmd.cpp +++ b/src/mongo/s/commands/cluster_set_free_monitoring_cmd.cpp @@ -62,7 +62,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) final { uasserted(ErrorCodes::CommandFailed, help()); diff --git a/src/mongo/s/commands/cluster_set_index_commit_quorum_cmd.cpp b/src/mongo/s/commands/cluster_set_index_commit_quorum_cmd.cpp index 976bd8b6ba0..cd066471f04 100644 --- a/src/mongo/s/commands/cluster_set_index_commit_quorum_cmd.cpp +++ b/src/mongo/s/commands/cluster_set_index_commit_quorum_cmd.cpp @@ -98,7 +98,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbName, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override { const NamespaceString nss(CommandHelpers::parseNsCollectionRequired(dbName, cmdObj)); diff --git a/src/mongo/s/commands/cluster_shard_collection_cmd.cpp b/src/mongo/s/commands/cluster_shard_collection_cmd.cpp index f8cc1052dd9..86ccca809e8 100644 --- a/src/mongo/s/commands/cluster_shard_collection_cmd.cpp +++ b/src/mongo/s/commands/cluster_shard_collection_cmd.cpp @@ -83,10 +83,10 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override { - const NamespaceString nss(parseNs({boost::none, dbname}, cmdObj)); + const NamespaceString nss(parseNs(dbName, cmdObj)); uassert(5731501, "Sharding a buckets collection is not allowed", diff --git a/src/mongo/s/commands/cluster_split_vector_cmd.cpp b/src/mongo/s/commands/cluster_split_vector_cmd.cpp index 0e65f23ced6..4b0e66418b5 100644 --- a/src/mongo/s/commands/cluster_split_vector_cmd.cpp +++ b/src/mongo/s/commands/cluster_split_vector_cmd.cpp @@ -69,13 +69,13 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbName, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& result) override { - const NamespaceString nss(parseNs({boost::none, dbName}, cmdObj)); + const NamespaceString nss(parseNs(dbName, cmdObj)); uassert(ErrorCodes::IllegalOperation, "Performing splitVector across dbs isn't supported via mongos", - nss.db() == dbName); + nss.dbName() == dbName); const auto cm = uassertStatusOK(Grid::get(opCtx)->catalogCache()->getCollectionRoutingInfo(opCtx, nss)); @@ -95,7 +95,7 @@ public: auto commandResponse = uassertStatusOK(shard->runCommandWithFixedRetryAttempts( opCtx, ReadPreferenceSetting::get(opCtx), - dbName, + dbName.toStringWithTenantId(), cm.dbPrimary() == ShardId::kConfigServerId ? filteredCmdObj : filteredCmdObjWithVersion, Shard::RetryPolicy::kIdempotent)); 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 cdf546f7c70..197363e9173 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 @@ -126,7 +126,7 @@ public: } virtual bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { auto parsedRequest = diff --git a/src/mongo/s/commands/cluster_validate_cmd.cpp b/src/mongo/s/commands/cluster_validate_cmd.cpp index 7adec5863b5..e54997ace56 100644 --- a/src/mongo/s/commands/cluster_validate_cmd.cpp +++ b/src/mongo/s/commands/cluster_validate_cmd.cpp @@ -70,10 +70,10 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbName, + const DatabaseName& dbName, const BSONObj& cmdObj, BSONObjBuilder& output) override { - const NamespaceString nss(parseNs({boost::none, dbName}, cmdObj)); + const NamespaceString nss(parseNs(dbName, cmdObj)); const auto routingInfo = uassertStatusOK(Grid::get(opCtx)->catalogCache()->getCollectionRoutingInfo(opCtx, nss)); 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 1de8fc6f9c1..d8581f2706e 100644 --- a/src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp +++ b/src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp @@ -62,7 +62,7 @@ public: } virtual bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) { result << "you" << cc().getRemote().toString(); diff --git a/src/mongo/s/commands/flush_router_config_cmd.cpp b/src/mongo/s/commands/flush_router_config_cmd.cpp index a81f2832564..addbd88edfc 100644 --- a/src/mongo/s/commands/flush_router_config_cmd.cpp +++ b/src/mongo/s/commands/flush_router_config_cmd.cpp @@ -76,7 +76,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { auto const grid = Grid::get(opCtx); diff --git a/src/mongo/s/commands/get_shard_map_cmd.cpp b/src/mongo/s/commands/get_shard_map_cmd.cpp index 7a54d59fc75..bbdf20d5ff0 100644 --- a/src/mongo/s/commands/get_shard_map_cmd.cpp +++ b/src/mongo/s/commands/get_shard_map_cmd.cpp @@ -67,7 +67,7 @@ public: } bool run(OperationContext* opCtx, - const std::string& dbname, + const DatabaseName&, const BSONObj& cmdObj, BSONObjBuilder& result) override { auto const grid = Grid::get(opCtx); |