diff options
-rw-r--r-- | jstests/core/index_comment.js | 47 | ||||
-rw-r--r-- | src/mongo/db/catalog/index_key_validate.cpp | 10 | ||||
-rw-r--r-- | src/mongo/db/create_indexes.idl | 4 | ||||
-rw-r--r-- | src/mongo/db/index/index_descriptor.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/index/index_descriptor.h | 6 | ||||
-rw-r--r-- | src/mongo/db/list_indexes.idl | 4 |
6 files changed, 1 insertions, 76 deletions
diff --git a/jstests/core/index_comment.js b/jstests/core/index_comment.js deleted file mode 100644 index 713cd3f0cd8..00000000000 --- a/jstests/core/index_comment.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Tests that the createIndex command accepts a comment field with BSONObj and this comment is - * retrievable with listIndexes called by getIndexes. - * - * @tags: [cannot_create_unique_index_when_using_hashed_shard_key] - */ -(function() { -"use strict"; - -const t = db.index_comment; -t.drop(); - -const collModIndexUniqueEnabled = assert - .commandWorked(db.getMongo().adminCommand( - {getParameter: 1, featureFlagCollModIndexUnique: 1})) - .featureFlagCollModIndexUnique.value; - -if (!collModIndexUniqueEnabled) { - jsTestLog('Skipping test because the collMod unique index feature flag is disabled.'); - return; -} - -// Attempts to build an index with invalid comments fails. -['not an object', 1.0, [0, 1, 2], null, true].forEach(invalidObj => { - assert.commandFailedWithCode(t.createIndex({a: 1}, {comment: invalidObj}), - ErrorCodes.TypeMismatch); -}); - -const validComment = { - "key": "value" -}; - -// Check that adding a comment field on a regular index works. -assert.commandWorked(t.createIndex({a: 1}, {comment: validComment})); - -// Check that we are able to insert a document into that index. -assert.commandWorked(t.insert({a: "thing"})); - -// Check that adding a comment field on a unique index works. -assert.commandWorked(t.createIndex({b: 1}, {unique: true, comment: validComment})); - -// Check that the comment field exists on both indexes when getIndexes is called. -const indexesWithComments = t.getIndexes().filter(function(doc) { - return friendlyEqual(doc.comment, validComment); -}); -assert.eq(2, indexesWithComments.length); -})(); diff --git a/src/mongo/db/catalog/index_key_validate.cpp b/src/mongo/db/catalog/index_key_validate.cpp index dd34e285e51..caa209fd3c3 100644 --- a/src/mongo/db/catalog/index_key_validate.cpp +++ b/src/mongo/db/catalog/index_key_validate.cpp @@ -94,7 +94,6 @@ static std::set<StringData> allowedFieldNames = { IndexDescriptor::kUniqueFieldName, IndexDescriptor::kWeightsFieldName, IndexDescriptor::kOriginalSpecFieldName, - IndexDescriptor::kCommentFieldName, // Index creation under legacy writeMode can result in an index spec with an _id field. "_id"}; @@ -501,7 +500,7 @@ StatusWith<BSONObj> validateIndexSpec(OperationContext* opCtx, const BSONObj& in "clustered" == indexSpecElemFieldName) && !indexSpecElem.isNumber() && !indexSpecElem.isBoolean()) { return {ErrorCodes::TypeMismatch, - str::stream() << "The field '" << indexSpecElemFieldName << "' has value " + str::stream() << "The field '" << indexSpecElemFieldName << " has value " << indexSpecElem.toString() << ", which is not convertible to bool"}; } else if ((IndexDescriptor::kDefaultLanguageFieldName == indexSpecElemFieldName || @@ -521,13 +520,6 @@ StatusWith<BSONObj> validateIndexSpec(OperationContext* opCtx, const BSONObj& in str::stream() << "The field '" << indexSpecElemFieldName << "' must be a number, but got " << typeName(indexSpecElem.type())}; - } else if (IndexDescriptor::kCommentFieldName == indexSpecElemFieldName) { - if (indexSpecElem.type() != BSONType::Object) { - return {ErrorCodes::TypeMismatch, - str::stream() - << "The field '" << IndexDescriptor::kCommentFieldName - << "' must be an object, but got " << typeName(indexSpecElem.type())}; - } } else { // We can assume field name is valid at this point. Validation of fieldname is handled // prior to this in validateIndexSpecFieldNames(). diff --git a/src/mongo/db/create_indexes.idl b/src/mongo/db/create_indexes.idl index d00b8f75801..812b0e3a40f 100644 --- a/src/mongo/db/create_indexes.idl +++ b/src/mongo/db/create_indexes.idl @@ -180,10 +180,6 @@ structs: type: safeBool optional: true unstable: false - comment: - type: object_owned - optional: true - unstable: true commands: createIndexes: description: "Command for creating indexes on a collection" diff --git a/src/mongo/db/index/index_descriptor.cpp b/src/mongo/db/index/index_descriptor.cpp index 07ae8f1cdc5..69fac811cd6 100644 --- a/src/mongo/db/index/index_descriptor.cpp +++ b/src/mongo/db/index/index_descriptor.cpp @@ -106,7 +106,6 @@ constexpr StringData IndexDescriptor::kTextVersionFieldName; constexpr StringData IndexDescriptor::kUniqueFieldName; constexpr StringData IndexDescriptor::kHiddenFieldName; constexpr StringData IndexDescriptor::kWeightsFieldName; -constexpr StringData IndexDescriptor::kCommentFieldName; IndexDescriptor::IndexDescriptor(const std::string& accessMethodName, BSONObj infoObj) : _accessMethodName(accessMethodName), @@ -134,11 +133,6 @@ IndexDescriptor::IndexDescriptor(const std::string& accessMethodName, BSONObj in invariant(collationElement.isABSONObj()); _collation = collationElement.Obj().getOwned(); } - - if (BSONElement commentElement = _infoObj[kCommentFieldName]) { - invariant(commentElement.isABSONObj()); - _comment = commentElement.Obj().getOwned(); - } } bool IndexDescriptor::isIndexVersionSupported(IndexVersion indexVersion) { diff --git a/src/mongo/db/index/index_descriptor.h b/src/mongo/db/index/index_descriptor.h index 5cc47c3564e..76e5dce4c91 100644 --- a/src/mongo/db/index/index_descriptor.h +++ b/src/mongo/db/index/index_descriptor.h @@ -88,7 +88,6 @@ public: static constexpr StringData kUniqueFieldName = "unique"_sd; static constexpr StringData kWeightsFieldName = "weights"_sd; static constexpr StringData kOriginalSpecFieldName = "originalSpec"_sd; - static constexpr StringData kCommentFieldName = "comment"_sd; /** * infoObj is a copy of the index-describing BSONObj contained in the catalog. @@ -227,10 +226,6 @@ public: return _partialFilterExpression; } - const BSONObj& comment() const { - return _comment; - } - /** * Returns true if the key pattern is for the _id index. * The _id index must have form exactly {_id : 1} or {_id : -1}. @@ -280,7 +275,6 @@ private: IndexVersion _version; BSONObj _collation; BSONObj _partialFilterExpression; - BSONObj _comment; // Many query stages require going from an IndexDescriptor to its IndexCatalogEntry, so for // now we need this. diff --git a/src/mongo/db/list_indexes.idl b/src/mongo/db/list_indexes.idl index c577fcb7945..10d78a0479d 100644 --- a/src/mongo/db/list_indexes.idl +++ b/src/mongo/db/list_indexes.idl @@ -156,10 +156,6 @@ structs: type: safeBool optional: true unstable: false - comment: - type: object_owned - optional: true - unstable: true # # Depending on the values of includeIndexBuildInfo and includeBuildUUIDs, indexes may # appear with a combination of these three fields. Specifically, if includeIndexBuildInfo |