summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
authorPV99 <pridhvi.vegesna@mongodb.com>2020-07-15 23:13:33 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-28 23:56:02 +0000
commit4e0f81726fc11becd9c22d701e80ba2c8d988bb0 (patch)
tree620edb4e906caa933c4f6cd1d04bce42b290be98 /src/mongo/db/commands
parent165dfb50f7693cadb80e988d08222700b1cc6b5c (diff)
downloadmongo-4e0f81726fc11becd9c22d701e80ba2c8d988bb0.tar.gz
SERVER-49065 Mark API Version 1 commands
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r--src/mongo/db/commands/SConscript2
-rw-r--r--src/mongo/db/commands/authentication_commands.cpp4
-rw-r--r--src/mongo/db/commands/count_cmd.cpp4
-rw-r--r--src/mongo/db/commands/create_indexes.cpp4
-rw-r--r--src/mongo/db/commands/dbcommands.cpp17
-rw-r--r--src/mongo/db/commands/drop_indexes.cpp5
-rw-r--r--src/mongo/db/commands/end_sessions_command.cpp4
-rw-r--r--src/mongo/db/commands/explain_cmd.cpp4
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp4
-rw-r--r--src/mongo/db/commands/find_cmd.cpp4
-rw-r--r--src/mongo/db/commands/generic.cpp4
-rw-r--r--src/mongo/db/commands/getmore_cmd.cpp6
-rw-r--r--src/mongo/db/commands/killcursors_cmd.cpp4
-rw-r--r--src/mongo/db/commands/list_collections.cpp3
-rw-r--r--src/mongo/db/commands/list_databases.cpp4
-rw-r--r--src/mongo/db/commands/list_indexes.cpp4
-rw-r--r--src/mongo/db/commands/pipeline_command.cpp4
-rw-r--r--src/mongo/db/commands/refresh_sessions_command.cpp4
-rw-r--r--src/mongo/db/commands/test_deprecation_command.cpp85
-rw-r--r--src/mongo/db/commands/txn_cmds.cpp8
-rw-r--r--src/mongo/db/commands/write_commands/write_commands.cpp13
21 files changed, 191 insertions, 0 deletions
diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript
index 910b0d7b88c..a4a1ebdc4ca 100644
--- a/src/mongo/db/commands/SConscript
+++ b/src/mongo/db/commands/SConscript
@@ -148,6 +148,7 @@ env.Library(
'logical_session_server_status_section.cpp',
'mr_common.cpp',
'reap_logical_session_cache_now.cpp',
+ 'test_deprecation_command.cpp',
'traffic_recording_cmds.cpp',
'user_management_commands_common.cpp',
env.Idlc('drop_connections.idl')[0],
@@ -171,6 +172,7 @@ env.Library(
'$BUILD_DIR/mongo/db/repl/isself',
'$BUILD_DIR/mongo/db/repl/repl_coordinator_interface',
'$BUILD_DIR/mongo/db/session_catalog',
+ '$BUILD_DIR/mongo/db/shared_request_handling',
'$BUILD_DIR/mongo/db/traffic_recorder',
'$BUILD_DIR/mongo/executor/egress_tag_closer_manager',
'$BUILD_DIR/mongo/executor/task_executor_pool',
diff --git a/src/mongo/db/commands/authentication_commands.cpp b/src/mongo/db/commands/authentication_commands.cpp
index f146e0c8742..77f014207fb 100644
--- a/src/mongo/db/commands/authentication_commands.cpp
+++ b/src/mongo/db/commands/authentication_commands.cpp
@@ -144,6 +144,10 @@ Status _authenticateX509(OperationContext* opCtx, const UserName& user, const BS
class CmdAuthenticate : public BasicCommand {
public:
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kAlways;
}
diff --git a/src/mongo/db/commands/count_cmd.cpp b/src/mongo/db/commands/count_cmd.cpp
index 6165ef9cdb5..fe8c4af8198 100644
--- a/src/mongo/db/commands/count_cmd.cpp
+++ b/src/mongo/db/commands/count_cmd.cpp
@@ -63,6 +63,10 @@ class CmdCount : public BasicCommand {
public:
CmdCount() : BasicCommand("count") {}
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
std::string help() const override {
return "count objects in collection";
}
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp
index 5794fb26436..0a9e6c50e56 100644
--- a/src/mongo/db/commands/create_indexes.cpp
+++ b/src/mongo/db/commands/create_indexes.cpp
@@ -711,6 +711,10 @@ class CmdCreateIndex : public ErrmsgCommandDeprecated {
public:
CmdCreateIndex() : ErrmsgCommandDeprecated(kCommandName) {}
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
bool supportsWriteConcern(const BSONObj& cmd) const override {
return true;
}
diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp
index 1fc8ae226a7..d1addd57762 100644
--- a/src/mongo/db/commands/dbcommands.cpp
+++ b/src/mongo/db/commands/dbcommands.cpp
@@ -105,6 +105,10 @@ namespace {
class CmdDropDatabase : public BasicCommand {
public:
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
std::string help() const override {
return "drop (delete) this database";
}
@@ -204,6 +208,11 @@ public:
class CmdDrop : public ErrmsgCommandDeprecated {
public:
CmdDrop() : ErrmsgCommandDeprecated("drop") {}
+
+ virtual const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
@@ -266,6 +275,10 @@ class CmdCreate : public BasicCommand {
public:
CmdCreate() : BasicCommand("create") {}
+ virtual const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
@@ -635,6 +648,10 @@ class CollectionModCommand : public BasicCommand {
public:
CollectionModCommand() : BasicCommand("collMod") {}
+ virtual const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp
index 19eb43b32fa..cb6cc68f5f5 100644
--- a/src/mongo/db/commands/drop_indexes.cpp
+++ b/src/mongo/db/commands/drop_indexes.cpp
@@ -68,9 +68,14 @@ MONGO_FAIL_POINT_DEFINE(reIndexCrashAfterDrop);
/* "dropIndexes" is now the preferred form - "deleteIndexes" deprecated */
class CmdDropIndexes : public BasicCommand {
public:
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
+
virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
return true;
}
diff --git a/src/mongo/db/commands/end_sessions_command.cpp b/src/mongo/db/commands/end_sessions_command.cpp
index 15c19f907d8..d081c6d9874 100644
--- a/src/mongo/db/commands/end_sessions_command.cpp
+++ b/src/mongo/db/commands/end_sessions_command.cpp
@@ -48,6 +48,10 @@ class EndSessionsCommand final : public BasicCommand {
public:
EndSessionsCommand() : BasicCommand("endSessions") {}
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kAlways;
}
diff --git a/src/mongo/db/commands/explain_cmd.cpp b/src/mongo/db/commands/explain_cmd.cpp
index 5cc8bc330c8..c3e1dff02e4 100644
--- a/src/mongo/db/commands/explain_cmd.cpp
+++ b/src/mongo/db/commands/explain_cmd.cpp
@@ -53,6 +53,10 @@ class CmdExplain final : public Command {
public:
CmdExplain() : Command("explain") {}
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
std::unique_ptr<CommandInvocation> parse(OperationContext* opCtx,
const OpMsgRequest& request) override;
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index 143a0d4f593..9785b5b51e2 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -216,6 +216,10 @@ public:
CmdFindAndModify()
: BasicCommand("findAndModify", "findandmodify"), _updateMetrics{"findAndModify"} {}
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
std::string help() const override {
return "{ findAndModify: \"collection\", query: {processed:false}, update: {$set: "
"{processed:true}}, new: true}\n"
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp
index 84501a9cbb7..517fb24bd54 100644
--- a/src/mongo/db/commands/find_cmd.cpp
+++ b/src/mongo/db/commands/find_cmd.cpp
@@ -128,6 +128,10 @@ class FindCmd final : public Command {
public:
FindCmd() : Command("find") {}
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
std::unique_ptr<CommandInvocation> parse(OperationContext* opCtx,
const OpMsgRequest& opMsgRequest) override {
// TODO: Parse into a QueryRequest here.
diff --git a/src/mongo/db/commands/generic.cpp b/src/mongo/db/commands/generic.cpp
index 0296b180f05..1a52d0f7bfa 100644
--- a/src/mongo/db/commands/generic.cpp
+++ b/src/mongo/db/commands/generic.cpp
@@ -52,6 +52,10 @@ class PingCommand : public BasicCommand {
public:
PingCommand() : BasicCommand("ping") {}
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kAlways;
}
diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp
index 33f731e7cde..ba9947b3e7e 100644
--- a/src/mongo/db/commands/getmore_cmd.cpp
+++ b/src/mongo/db/commands/getmore_cmd.cpp
@@ -241,6 +241,12 @@ class GetMoreCmd final : public Command {
public:
GetMoreCmd() : Command("getMore") {}
+ // Do not currently use apiVersions because clients are prohibited from calling
+ // getMore with apiVersion.
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
std::unique_ptr<CommandInvocation> parse(OperationContext* opCtx,
const OpMsgRequest& opMsgRequest) override {
return std::make_unique<Invocation>(this, opMsgRequest);
diff --git a/src/mongo/db/commands/killcursors_cmd.cpp b/src/mongo/db/commands/killcursors_cmd.cpp
index 4604a83cfa2..9acf3b85b31 100644
--- a/src/mongo/db/commands/killcursors_cmd.cpp
+++ b/src/mongo/db/commands/killcursors_cmd.cpp
@@ -48,6 +48,10 @@ class KillCursorsCmd final : public KillCursorsCmdBase {
public:
KillCursorsCmd() = default;
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
bool run(OperationContext* opCtx,
const std::string& dbname,
const BSONObj& cmdObj,
diff --git a/src/mongo/db/commands/list_collections.cpp b/src/mongo/db/commands/list_collections.cpp
index ffe9956f205..e90b0eeed4d 100644
--- a/src/mongo/db/commands/list_collections.cpp
+++ b/src/mongo/db/commands/list_collections.cpp
@@ -212,6 +212,9 @@ BSONObj buildCollectionBson(OperationContext* opCtx,
class CmdListCollections : public BasicCommand {
public:
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
AllowedOnSecondary secondaryAllowed(ServiceContext*) const final {
return AllowedOnSecondary::kOptIn;
}
diff --git a/src/mongo/db/commands/list_databases.cpp b/src/mongo/db/commands/list_databases.cpp
index c656355ec06..9da849e8cae 100644
--- a/src/mongo/db/commands/list_databases.cpp
+++ b/src/mongo/db/commands/list_databases.cpp
@@ -62,6 +62,10 @@ intmax_t dbSize(const string& database);
class CmdListDatabases : public BasicCommand {
public:
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const final {
return AllowedOnSecondary::kOptIn;
}
diff --git a/src/mongo/db/commands/list_indexes.cpp b/src/mongo/db/commands/list_indexes.cpp
index 219cd2926f6..15e8bb52420 100644
--- a/src/mongo/db/commands/list_indexes.cpp
+++ b/src/mongo/db/commands/list_indexes.cpp
@@ -93,6 +93,10 @@ class CmdListIndexes : public BasicCommand {
public:
CmdListIndexes() : BasicCommand("listIndexes") {}
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kOptIn;
}
diff --git a/src/mongo/db/commands/pipeline_command.cpp b/src/mongo/db/commands/pipeline_command.cpp
index 915457281fe..6b542b421ae 100644
--- a/src/mongo/db/commands/pipeline_command.cpp
+++ b/src/mongo/db/commands/pipeline_command.cpp
@@ -43,6 +43,10 @@ class PipelineCommand final : public Command {
public:
PipelineCommand() : Command("aggregate") {}
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
/**
* It's not known until after parsing whether or not an aggregation command is an explain
* request, because it might include the `explain: true` field (ie. aggregation explains do not
diff --git a/src/mongo/db/commands/refresh_sessions_command.cpp b/src/mongo/db/commands/refresh_sessions_command.cpp
index 6c177f743f1..0d8a96d4358 100644
--- a/src/mongo/db/commands/refresh_sessions_command.cpp
+++ b/src/mongo/db/commands/refresh_sessions_command.cpp
@@ -45,6 +45,10 @@ class RefreshSessionsCommand final : public BasicCommand {
public:
RefreshSessionsCommand() : BasicCommand("refreshSessions") {}
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kAlways;
}
diff --git a/src/mongo/db/commands/test_deprecation_command.cpp b/src/mongo/db/commands/test_deprecation_command.cpp
new file mode 100644
index 00000000000..2ec6060bbe3
--- /dev/null
+++ b/src/mongo/db/commands/test_deprecation_command.cpp
@@ -0,0 +1,85 @@
+/**
+ * Copyright (C) 2020-present MongoDB, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the Server Side Public License, version 1,
+ * as published by MongoDB, Inc.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Server Side Public License for more details.
+ *
+ * You should have received a copy of the Server Side Public License
+ * along with this program. If not, see
+ * <http://www.mongodb.com/licensing/server-side-public-license>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the Server Side Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/db/commands.h"
+#include "mongo/db/initialize_api_parameters.h"
+
+namespace mongo {
+
+/**
+ * Command for testing API Version deprecation logic. The command replies with the values of the
+ * OperationContext's API parameters.
+ */
+class TestDeprecationCmd : public BasicCommand {
+public:
+ TestDeprecationCmd() : BasicCommand("testDeprecation") {}
+
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
+ const std::set<std::string>& deprecatedApiVersions() const {
+ return kApiVersions1;
+ }
+
+ AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
+ return AllowedOnSecondary::kAlways;
+ }
+
+ bool supportsWriteConcern(const BSONObj& cmd) const override {
+ return false;
+ }
+
+ bool requiresAuth() const override {
+ return false;
+ }
+
+ void addRequiredPrivileges(const std::string& dbname,
+ const BSONObj& cmdObj,
+ std::vector<Privilege>* out) const override {}
+
+ std::string help() const override {
+ return "replies with the values of the OperationContext's API parameters";
+ }
+
+ bool run(OperationContext* opCtx,
+ const std::string& dbname,
+ const BSONObj& cmdObj,
+ BSONObjBuilder& result) override {
+ result.append("apiVersion", APIParameters::get(opCtx).getAPIVersion());
+ result.append("apiStrict", APIParameters::get(opCtx).getAPIStrict());
+ result.append("apiDeprecationErrors", APIParameters::get(opCtx).getAPIDeprecationErrors());
+ return true;
+ }
+};
+
+MONGO_REGISTER_TEST_COMMAND(TestDeprecationCmd);
+
+
+} // namespace mongo \ No newline at end of file
diff --git a/src/mongo/db/commands/txn_cmds.cpp b/src/mongo/db/commands/txn_cmds.cpp
index 29e76b6ffce..df7aa9787dc 100644
--- a/src/mongo/db/commands/txn_cmds.cpp
+++ b/src/mongo/db/commands/txn_cmds.cpp
@@ -61,6 +61,10 @@ class CmdCommitTxn : public BasicCommand {
public:
CmdCommitTxn() : BasicCommand("commitTransaction") {}
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
@@ -161,6 +165,10 @@ class CmdAbortTxn : public BasicCommand {
public:
CmdAbortTxn() : BasicCommand("abortTransaction") {}
+ virtual const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ };
+
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kNever;
}
diff --git a/src/mongo/db/commands/write_commands/write_commands.cpp b/src/mongo/db/commands/write_commands/write_commands.cpp
index a78a7318f60..8c0d4e0549d 100644
--- a/src/mongo/db/commands/write_commands/write_commands.cpp
+++ b/src/mongo/db/commands/write_commands/write_commands.cpp
@@ -286,6 +286,10 @@ class CmdInsert final : public WriteCommand {
public:
CmdInsert() : WriteCommand("insert") {}
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
private:
class Invocation final : public InvocationBase {
public:
@@ -332,6 +336,10 @@ class CmdUpdate final : public WriteCommand {
public:
CmdUpdate() : WriteCommand("update"), _updateMetrics{"update"} {}
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
private:
class Invocation final : public InvocationBase {
public:
@@ -486,12 +494,17 @@ class CmdDelete final : public WriteCommand {
public:
CmdDelete() : WriteCommand("delete") {}
+ const std::set<std::string>& apiVersions() const {
+ return kApiVersions1;
+ }
+
private:
class Invocation final : public InvocationBase {
public:
Invocation(const WriteCommand* cmd, const OpMsgRequest& request)
: InvocationBase(cmd, request), _batch(DeleteOp::parse(request)) {}
+
private:
NamespaceString ns() const override {
return _batch.getNamespace();