diff options
author | Nicholas Zolnierz <nicholas.zolnierz@mongodb.com> | 2022-02-22 20:14:54 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-03-03 16:09:00 +0000 |
commit | 2041c2351fef9734e0b6452b1f459d590de9bc2d (patch) | |
tree | d1827ba8bcd474ccc7d64987c5de5c24abd7b000 | |
parent | 005efc15058f59fd9a667ba39761dd2487581352 (diff) | |
download | mongo-2041c2351fef9734e0b6452b1f459d590de9bc2d.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.js | 6 | ||||
-rw-r--r-- | src/mongo/db/catalog/coll_mod.cpp | 2 |
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 0b93d8e23a4..22a713bae98 100644 --- a/src/mongo/db/catalog/coll_mod.cpp +++ b/src/mongo/db/catalog/coll_mod.cpp @@ -390,7 +390,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, |