summaryrefslogtreecommitdiff
path: root/src/mongo/db/system_index.cpp
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2020-08-14 10:23:04 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-02 23:53:39 +0000
commitbf5914a20b596ba3bde772b42e579e028f733bac (patch)
tree2b26469571786d9adb5e95c47990c2416bfab9c4 /src/mongo/db/system_index.cpp
parent6b3e341703b781bb1ff7b1263406a0f1d28dd77c (diff)
downloadmongo-bf5914a20b596ba3bde772b42e579e028f733bac.tar.gz
SERVER-50317 Const correct uses of Collection
Most of the code should only need a const Collection now. AutoGetCollection returns a const Collection by default. There is a placeholder getWritableCollection() interface that will handle the necessary steps we need for lock free reads in the future. Added some operators to AutoGetCollection so it behaves more like a smart pointer.
Diffstat (limited to 'src/mongo/db/system_index.cpp')
-rw-r--r--src/mongo/db/system_index.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/mongo/db/system_index.cpp b/src/mongo/db/system_index.cpp
index 0b3c022dba4..9234ad7769b 100644
--- a/src/mongo/db/system_index.cpp
+++ b/src/mongo/db/system_index.cpp
@@ -143,10 +143,10 @@ Status verifySystemIndexes(OperationContext* opCtx) {
// Create indexes for the admin.system.users collection.
{
- AutoGetCollection autoColl(opCtx, systemUsers, MODE_X);
+ AutoGetCollection collection(opCtx, systemUsers, MODE_X);
- if (Collection* collection = autoColl.getCollection()) {
- IndexCatalog* indexCatalog = collection->getIndexCatalog();
+ if (collection) {
+ const IndexCatalog* indexCatalog = collection->getIndexCatalog();
invariant(indexCatalog);
// Make sure the old unique index from v2.4 on system.users doesn't exist.
@@ -176,11 +176,11 @@ Status verifySystemIndexes(OperationContext* opCtx) {
// Create indexes for the admin.system.roles collection.
{
- AutoGetCollection autoColl(opCtx, systemRoles, MODE_X);
+ AutoGetCollection collection(opCtx, systemRoles, MODE_X);
// Ensure that system indexes exist for the roles collection, if it exists.
- if (Collection* collection = autoColl.getCollection()) {
- IndexCatalog* indexCatalog = collection->getIndexCatalog();
+ if (collection) {
+ const IndexCatalog* indexCatalog = collection->getIndexCatalog();
invariant(indexCatalog);
std::vector<const IndexDescriptor*> indexes;
@@ -199,7 +199,7 @@ Status verifySystemIndexes(OperationContext* opCtx) {
return Status::OK();
}
-void createSystemIndexes(OperationContext* opCtx, Collection* collection) {
+void createSystemIndexes(OperationContext* opCtx, const Collection* collection) {
invariant(collection);
const NamespaceString& ns = collection->ns();
BSONObj indexSpec;