0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

SERVER-54888 Prohibit partial index creation on time-series bucket collections

This commit is contained in:
Benety Goh 2021-03-03 13:54:35 -05:00 committed by Evergreen Agent
parent c50fe3dc97
commit 2f37d8438c
2 changed files with 15 additions and 1 deletions

View File

@ -121,7 +121,15 @@ assert.commandFailedWithCode(coll.dropIndex({not_metadata: 1}), ErrorCodes.Index
// which in this case does not possess the index by that name. // which in this case does not possess the index by that name.
assert.commandFailedWithCode(coll.dropIndex('mm_1'), ErrorCodes.IndexNotFound); assert.commandFailedWithCode(coll.dropIndex('mm_1'), ErrorCodes.IndexNotFound);
// Unique indexes are not supported // Partial indexes are not supported on time-series bucket collections.
assert.commandFailedWithCode(
coll.createIndex({[metaFieldName]: 1}, {partialFilterExpression: {meta: {$gt: 5}}}),
ErrorCodes.InvalidOptions);
assert.commandFailedWithCode(
coll.createIndex({[metaFieldName]: 1}, {partialFilterExpression: {[metaFieldName]: {$gt: 5}}}),
ErrorCodes.InvalidOptions);
// Unique indexes are not supported on time-series bucket collections.
assert.commandFailedWithCode(coll.createIndex({[metaFieldName]: 1}, {unique: true}), assert.commandFailedWithCode(coll.createIndex({[metaFieldName]: 1}, {unique: true}),
ErrorCodes.InvalidOptions); ErrorCodes.InvalidOptions);
})(); })();

View File

@ -140,6 +140,12 @@ std::vector<BSONObj> parseAndValidateIndexSpecs(OperationContext* opCtx,
!ns.isSystem() || indexSpec[IndexDescriptor::kHiddenFieldName].eoo()); !ns.isSystem() || indexSpec[IndexDescriptor::kHiddenFieldName].eoo());
} }
// TODO(SERVER-54917): Check for clustered index instead of inspecting namespace.
uassert(ErrorCodes::InvalidOptions,
"Partial indexes are not supported on time-series buckets collections",
!ns.isTimeseriesBucketsCollection() ||
!indexSpec[IndexDescriptor::kPartialFilterExprFieldName]);
uassert(ErrorCodes::InvalidOptions, uassert(ErrorCodes::InvalidOptions,
"Unique indexes are not supported on time-series buckets collections", "Unique indexes are not supported on time-series buckets collections",
!ns.isTimeseriesBucketsCollection() || !ns.isTimeseriesBucketsCollection() ||