diff options
author | Shin Yee Tan <shinyee.tan@mongodb.com> | 2022-01-24 17:59:08 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-01-24 19:16:56 +0000 |
commit | f395e9d34b413781bcfb67c2674378734223466c (patch) | |
tree | 7f8f430ad7daf05f44055ec86995feab18a95fcf /src/mongo/db/index | |
parent | 36da822b20fee2b73e65810c817fdc1e7fc2cd29 (diff) | |
download | mongo-f395e9d34b413781bcfb67c2674378734223466c.tar.gz |
SERVER-62209 Add 'comment' option to 'createIndex' command
Diffstat (limited to 'src/mongo/db/index')
-rw-r--r-- | src/mongo/db/index/index_descriptor.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/index/index_descriptor.h | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/db/index/index_descriptor.cpp b/src/mongo/db/index/index_descriptor.cpp index 69fac811cd6..07ae8f1cdc5 100644 --- a/src/mongo/db/index/index_descriptor.cpp +++ b/src/mongo/db/index/index_descriptor.cpp @@ -106,6 +106,7 @@ 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), @@ -133,6 +134,11 @@ 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 76e5dce4c91..5cc47c3564e 100644 --- a/src/mongo/db/index/index_descriptor.h +++ b/src/mongo/db/index/index_descriptor.h @@ -88,6 +88,7 @@ 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. @@ -226,6 +227,10 @@ 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}. @@ -275,6 +280,7 @@ 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. |