summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2021-06-16 07:07:12 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-16 11:57:15 +0000
commite5f51a656326c725a05b113bcf263b2dd6364ef5 (patch)
treeda82d0c95f92b9f17bcd3d667d6b4b94692fc371
parentdb7a7a0f167e97ac43415265f0f4bcec07dd2ca6 (diff)
downloadmongo-e5f51a656326c725a05b113bcf263b2dd6364ef5.tar.gz
SERVER-57385 Collection::checkMetaDataForIndex() returns offset on success
-rw-r--r--src/mongo/db/catalog/collection.h5
-rw-r--r--src/mongo/db/catalog/collection_impl.cpp6
-rw-r--r--src/mongo/db/catalog/collection_impl.h3
-rw-r--r--src/mongo/db/catalog/collection_mock.h2
4 files changed, 9 insertions, 7 deletions
diff --git a/src/mongo/db/catalog/collection.h b/src/mongo/db/catalog/collection.h
index e2f487df323..84fbb16a809 100644
--- a/src/mongo/db/catalog/collection.h
+++ b/src/mongo/db/catalog/collection.h
@@ -540,9 +540,10 @@ public:
/**
* Checks that the metadata for the index exists and matches the given spec.
+ * Returns offset in metadata on success.
*/
- virtual Status checkMetaDataForIndex(const std::string& indexName,
- const BSONObj& spec) const = 0;
+ virtual StatusWith<int> checkMetaDataForIndex(const std::string& indexName,
+ const BSONObj& spec) const = 0;
/*
* Updates the expireAfterSeconds field of the given index to the value in newExpireSecs.
diff --git a/src/mongo/db/catalog/collection_impl.cpp b/src/mongo/db/catalog/collection_impl.cpp
index 80a7d913351..4138de412e7 100644
--- a/src/mongo/db/catalog/collection_impl.cpp
+++ b/src/mongo/db/catalog/collection_impl.cpp
@@ -1677,8 +1677,8 @@ void CollectionImpl::establishOplogCollectionForLogging(OperationContext* opCtx)
repl::establishOplogCollectionForLogging(opCtx, this);
}
-Status CollectionImpl::checkMetaDataForIndex(const std::string& indexName,
- const BSONObj& spec) const {
+StatusWith<int> CollectionImpl::checkMetaDataForIndex(const std::string& indexName,
+ const BSONObj& spec) const {
int offset = _metadata->findIndexOffset(indexName);
if (offset < 0) {
return {ErrorCodes::IndexNotFound,
@@ -1694,7 +1694,7 @@ Status CollectionImpl::checkMetaDataForIndex(const std::string& indexName,
<< " metadata's spec: " << _metadata->indexes[offset].spec};
}
- return Status::OK();
+ return offset;
}
void CollectionImpl::updateTTLSetting(OperationContext* opCtx,
diff --git a/src/mongo/db/catalog/collection_impl.h b/src/mongo/db/catalog/collection_impl.h
index a16d0938310..ec6c8e32446 100644
--- a/src/mongo/db/catalog/collection_impl.h
+++ b/src/mongo/db/catalog/collection_impl.h
@@ -410,7 +410,8 @@ public:
void establishOplogCollectionForLogging(OperationContext* opCtx) final;
void onDeregisterFromCatalog(OperationContext* opCtx) final;
- Status checkMetaDataForIndex(const std::string& indexName, const BSONObj& spec) const final;
+ StatusWith<int> checkMetaDataForIndex(const std::string& indexName,
+ const BSONObj& spec) const final;
void updateTTLSetting(OperationContext* opCtx,
StringData idxName,
diff --git a/src/mongo/db/catalog/collection_mock.h b/src/mongo/db/catalog/collection_mock.h
index 8d7ed7e6f06..0d609ff7c91 100644
--- a/src/mongo/db/catalog/collection_mock.h
+++ b/src/mongo/db/catalog/collection_mock.h
@@ -365,7 +365,7 @@ public:
std::abort();
}
- Status checkMetaDataForIndex(const std::string& indexName, const BSONObj& spec) const {
+ StatusWith<int> checkMetaDataForIndex(const std::string& indexName, const BSONObj& spec) const {
std::abort();
}