diff options
Diffstat (limited to 'src/mongo/db/commands')
46 files changed, 97 insertions, 92 deletions
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*/); |