diff options
author | Benety Goh <benety@mongodb.com> | 2020-11-20 21:55:40 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-11-21 03:13:15 +0000 |
commit | 642e1e7abbe202d8f3c7425843e0e0a4953d893b (patch) | |
tree | dd34ed32e6f229b0b51ee204360ff23bf36ba9d8 | |
parent | dfc74795b2ddd2ea75b94f5845fef965b5e5f005 (diff) | |
download | mongo-642e1e7abbe202d8f3c7425843e0e0a4953d893b.tar.gz |
SERVER-52525 validate expireAfterSeconds time-series option
-rw-r--r-- | jstests/noPassthroughWithMongod/time_series_create.js | 2 | ||||
-rw-r--r-- | src/mongo/db/catalog/create_collection.cpp | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/jstests/noPassthroughWithMongod/time_series_create.js b/jstests/noPassthroughWithMongod/time_series_create.js index d3c6020ccb6..bcb98991bfb 100644 --- a/jstests/noPassthroughWithMongod/time_series_create.js +++ b/jstests/noPassthroughWithMongod/time_series_create.js @@ -95,7 +95,7 @@ testInvalidTimeseriesOptions({timeField: 100}, ErrorCodes.TypeMismatch); testInvalidTimeseriesOptions({timeField: "time", metaField: 100}, ErrorCodes.TypeMismatch); testInvalidTimeseriesOptions({timeField: "time", expireAfterSeconds: ""}, ErrorCodes.TypeMismatch); testInvalidTimeseriesOptions({timeField: "time", expireAfterSeconds: NumberLong(-10)}, - ErrorCodes.TypeMismatch); + ErrorCodes.CannotCreateIndex); testInvalidTimeseriesOptions({timeField: "time", invalidOption: {}}, 40415); testCompatibleCreateOptions({storageEngine: {}}); diff --git a/src/mongo/db/catalog/create_collection.cpp b/src/mongo/db/catalog/create_collection.cpp index 5fa4c5efbce..ede682382e9 100644 --- a/src/mongo/db/catalog/create_collection.cpp +++ b/src/mongo/db/catalog/create_collection.cpp @@ -36,6 +36,7 @@ #include "mongo/bson/bsonobj.h" #include "mongo/db/catalog/collection_catalog.h" #include "mongo/db/catalog/database_holder.h" +#include "mongo/db/catalog/index_key_validate.h" #include "mongo/db/commands.h" #include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/curop.h" @@ -227,6 +228,7 @@ Status _createTimeseries(OperationContext* opCtx, << IndexDescriptor::kExpireAfterSecondsFieldName << *expireAfterSeconds); auto fromMigrate = false; try { + uassertStatusOK(index_key_validate::validateIndexSpecTTL(indexSpec)); indexBuildCoord->createIndexesOnEmptyCollection( opCtx, collectionWriter, {indexSpec}, fromMigrate); } catch (DBException& ex) { |