diff options
Diffstat (limited to 'src/mongo/db/timeseries/timeseries_index_schema_conversion_functions.cpp')
-rw-r--r-- | src/mongo/db/timeseries/timeseries_index_schema_conversion_functions.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/mongo/db/timeseries/timeseries_index_schema_conversion_functions.cpp b/src/mongo/db/timeseries/timeseries_index_schema_conversion_functions.cpp index 1dff8c06341..9338f2c237d 100644 --- a/src/mongo/db/timeseries/timeseries_index_schema_conversion_functions.cpp +++ b/src/mongo/db/timeseries/timeseries_index_schema_conversion_functions.cpp @@ -71,6 +71,14 @@ std::pair<std::string, std::string> extractControlPrefixAndKey(const StringData& StatusWith<BSONObj> createBucketsSpecFromTimeseriesSpec(const TimeseriesOptions& timeseriesOptions, const BSONObj& timeseriesIndexSpecBSON, bool isShardKeySpec) { + tassert(6390200, "Empty object is not a valid index spec", !timeseriesIndexSpecBSON.isEmpty()); + tassert(6390201, + str::stream() << "Invalid index spec (perhaps it's a valid hint, that was incorrectly " + << "passed to createBucketsSpecFromTimeseriesSpec): " + << timeseriesIndexSpecBSON, + timeseriesIndexSpecBSON.firstElement().fieldNameStringData() != "$hint"_sd && + timeseriesIndexSpecBSON.firstElement().fieldNameStringData() != "$natural"_sd); + auto timeField = timeseriesOptions.getTimeField(); auto metaField = timeseriesOptions.getMetaField(); @@ -474,4 +482,16 @@ bool doesBucketsIndexIncludeMeasurement(OperationContext* opCtx, return false; } +bool isHintIndexKey(const BSONObj& obj) { + if (obj.isEmpty()) + return false; + StringData fieldName = obj.firstElement().fieldNameStringData(); + if (fieldName == "$hint"_sd) + return false; + if (fieldName == "$natural"_sd) + return false; + + return true; +} + } // namespace mongo::timeseries |