summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Zolnierz <nicholas.zolnierz@mongodb.com>2022-02-22 20:14:54 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-22 21:01:26 +0000
commitc65aa01ff0a99d6bcbe44a4fef44a33e918d939d (patch)
tree0c816c3365f5ecacc314ed79f930c2d9c4233ab2
parent78f9cb8d421b97485a1be039e08e8c333393fef0 (diff)
downloadmongo-c65aa01ff0a99d6bcbe44a4fef44a33e918d939d.tar.gz
SERVER-63859 Disallow collMod with 'expireAfterSeconds' parameter over a view namespace
-rw-r--r--jstests/core/views/views_validation.js6
-rw-r--r--src/mongo/db/catalog/coll_mod.cpp2
2 files changed, 7 insertions, 1 deletions
diff --git a/jstests/core/views/views_validation.js b/jstests/core/views/views_validation.js
index 21b6ba15690..abd9736bc2d 100644
--- a/jstests/core/views/views_validation.js
+++ b/jstests/core/views/views_validation.js
@@ -166,6 +166,12 @@ assert.commandFailedWithCode(
"BSON field 'collMod.pipeline' is the wrong type 'object', expected type 'array'");
clear();
+// Check that collMod disallows the 'expireAfterSeconds' option over a view.
+makeView("a", "b");
+assert.commandFailedWithCode(viewsDb.runCommand({collMod: "a", expireAfterSeconds: 1}),
+ ErrorCodes.InvalidOptions);
+clear();
+
// Check that invalid pipelines are disallowed. The following $lookup is missing the 'as' field.
makeView("a",
"b",
diff --git a/src/mongo/db/catalog/coll_mod.cpp b/src/mongo/db/catalog/coll_mod.cpp
index 82a6020cd77..10847bfce86 100644
--- a/src/mongo/db/catalog/coll_mod.cpp
+++ b/src/mongo/db/catalog/coll_mod.cpp
@@ -415,7 +415,7 @@ StatusWith<ParsedCollModRequest> parseCollModRequest(OperationContext* opCtx,
} catch (const DBException& ex) {
return ex.toStatus();
}
- } else if (fieldName == "expireAfterSeconds") {
+ } else if (fieldName == "expireAfterSeconds" && !isView) {
cmr.numModifications++;
if (coll->getRecordStore()->keyFormat() != KeyFormat::String) {
return Status(ErrorCodes::InvalidOptions,