summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuoxin Xu <ruoxin.xu@mongodb.com>2021-06-13 20:56:28 +0100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-16 21:44:21 +0000
commitdf3417f99795335167ed7251239ab3336b2dfc0c (patch)
tree676d5034aadebf995e3c499bf3f633e79da867a4
parente8f96019646425bc352f09b62d8e86b0e41f5d5b (diff)
downloadmongo-df3417f99795335167ed7251239ab3336b2dfc0c.tar.gz
SERVER-57561 Avoid setting default LegacyRuntimeConstants value when parsing FindCommandRequest
-rw-r--r--buildscripts/idl/idl_compatibility_errors.py2
-rw-r--r--jstests/core/api_version_test_expression.js2
-rw-r--r--jstests/sharding/api_version_test_expression.js8
-rw-r--r--jstests/sharding/libs/mongos_api_params_util.js24
-rw-r--r--src/mongo/db/commands/find_cmd.cpp3
-rw-r--r--src/mongo/db/query/find_command.idl1
-rw-r--r--src/mongo/s/commands/cluster_find_cmd.cpp1
7 files changed, 36 insertions, 5 deletions
diff --git a/buildscripts/idl/idl_compatibility_errors.py b/buildscripts/idl/idl_compatibility_errors.py
index edf869c180f..7f3a5a256b9 100644
--- a/buildscripts/idl/idl_compatibility_errors.py
+++ b/buildscripts/idl/idl_compatibility_errors.py
@@ -136,7 +136,7 @@ SKIPPED_COMMANDS = {
"dropIndexes": [ERROR_ID_ADDED_ACCESS_CHECK_FIELD],
"endSessions": [ERROR_ID_ADDED_ACCESS_CHECK_FIELD],
"explain": [ERROR_ID_ADDED_ACCESS_CHECK_FIELD],
- "find": [ERROR_ID_ADDED_ACCESS_CHECK_FIELD],
+ "find": [ERROR_ID_ADDED_ACCESS_CHECK_FIELD, ERROR_ID_COMMAND_PARAMETER_UNSTABLE],
"findAndModify": [ERROR_ID_ADDED_ACCESS_CHECK_FIELD],
"hello": [
ERROR_ID_ADDED_ACCESS_CHECK_FIELD,
diff --git a/jstests/core/api_version_test_expression.js b/jstests/core/api_version_test_expression.js
index 11d4dfaf71f..bdaed75e6b7 100644
--- a/jstests/core/api_version_test_expression.js
+++ b/jstests/core/api_version_test_expression.js
@@ -128,6 +128,8 @@ assert.commandWorked(db.runCommand({aggregate: collName, pipeline: pipeline, cur
db.view.drop();
assert.commandWorked(db.runCommand(
{create: "view", viewOn: collName, pipeline: [], apiStrict: true, apiVersion: "1"}));
+// find() on views should work normally if 'apiStrict' is true.
+assert.commandWorked(db.runCommand({find: "view", apiStrict: true, apiVersion: "1"}));
// This command will work because API parameters are not inherited from views.
assert.commandWorked(db.runCommand({aggregate: "view", pipeline: pipeline, cursor: {}}));
assert.commandFailedWithCode(
diff --git a/jstests/sharding/api_version_test_expression.js b/jstests/sharding/api_version_test_expression.js
index de6c83f68a4..bf5dffc7b6e 100644
--- a/jstests/sharding/api_version_test_expression.js
+++ b/jstests/sharding/api_version_test_expression.js
@@ -113,5 +113,13 @@ assert.commandWorked(db.runCommand({
apiDeprecationErrors: false,
apiVersion: "1"
}));
+
+// Create a view with {apiStrict: true}.
+db.view.drop();
+assert.commandWorked(db.runCommand(
+ {create: "view", viewOn: collName, pipeline: [], apiStrict: true, apiVersion: "1"}));
+// find() on views should work normally if 'apiStrict' is true.
+assert.commandWorked(db.runCommand({find: "view", apiStrict: true, apiVersion: "1"}));
+
st.stop();
})();
diff --git a/jstests/sharding/libs/mongos_api_params_util.js b/jstests/sharding/libs/mongos_api_params_util.js
index 6ec941b9266..fb2fe5b9231 100644
--- a/jstests/sharding/libs/mongos_api_params_util.js
+++ b/jstests/sharding/libs/mongos_api_params_util.js
@@ -525,6 +525,30 @@ let MongosAPIParametersUtil = (function() {
}
},
{
+ commandName: "find",
+ run: {
+ inAPIVersion1: true,
+ shardCommandName: "find",
+ setUp: function() {
+ st.s.getDB("db")["view"].drop();
+ assert.commandWorked(st.s.getDB("db").runCommand(
+ {create: "view", viewOn: "collection", pipeline: []}));
+ },
+ command: () => ({find: "view", filter: {x: 1}})
+ },
+ explain: {
+ inAPIVersion1: true,
+ shardCommandName: "explain",
+ permittedInTxn: false,
+ setUp: function() {
+ st.s.getDB("db")["view"].drop();
+ assert.commandWorked(st.s.getDB("db").runCommand(
+ {create: "view", viewOn: "collection", pipeline: []}));
+ },
+ command: () => ({explain: {find: "view", filter: {x: 1}}})
+ }
+ },
+ {
commandName: "findAndModify",
run: {
inAPIVersion1: true,
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp
index 00d5f57c803..c417a7473f1 100644
--- a/src/mongo/db/commands/find_cmd.cpp
+++ b/src/mongo/db/commands/find_cmd.cpp
@@ -74,9 +74,6 @@ std::unique_ptr<FindCommandRequest> parseCmdObjectToFindCommandRequest(Operation
std::move(cmdObj),
std::move(nss),
APIParameters::get(opCtx).getAPIStrict().value_or(false));
- if (!findCommand->getLegacyRuntimeConstants()) {
- findCommand->setLegacyRuntimeConstants(Variables::generateRuntimeConstants(opCtx));
- }
return findCommand;
}
diff --git a/src/mongo/db/query/find_command.idl b/src/mongo/db/query/find_command.idl
index af76c9abde8..9523652c695 100644
--- a/src/mongo/db/query/find_command.idl
+++ b/src/mongo/db/query/find_command.idl
@@ -232,3 +232,4 @@ commands:
cpp_name: legacyRuntimeConstants
type: LegacyRuntimeConstants
optional: true
+ unstable: true
diff --git a/src/mongo/s/commands/cluster_find_cmd.cpp b/src/mongo/s/commands/cluster_find_cmd.cpp
index 797391c29fd..e4460b8c147 100644
--- a/src/mongo/s/commands/cluster_find_cmd.cpp
+++ b/src/mongo/s/commands/cluster_find_cmd.cpp
@@ -78,7 +78,6 @@ std::unique_ptr<FindCommandRequest> parseCmdObjectToFindCommandRequest(Operation
uassert(51202,
"Cannot specify runtime constants option to a mongos",
!findCommand->getLegacyRuntimeConstants());
- findCommand->setLegacyRuntimeConstants(Variables::generateRuntimeConstants(opCtx));
return findCommand;
}