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-24 19:30:00 +0000
commit43b5b9e01ee0666e7ea2eb7d3bedfdbaa32e9676 (patch)
treeb2c1bd55d71b1ae12e1fa586422324ccfe4f04d3
parent3080405bc62db70605ba63e90929efe3b1d5b052 (diff)
downloadmongo-43b5b9e01ee0666e7ea2eb7d3bedfdbaa32e9676.tar.gz
SERVER-63859 Disallow collMod with 'expireAfterSeconds' parameter over a view namespace
(cherry picked from commit c65aa01ff0a99d6bcbe44a4fef44a33e918d939d)
-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 48194767c48..f0ddd274da3 100644
--- a/src/mongo/db/catalog/coll_mod.cpp
+++ b/src/mongo/db/catalog/coll_mod.cpp
@@ -407,7 +407,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,