diff options
Diffstat (limited to 'src/mongo/db/catalog/index_catalog.cpp')
-rw-r--r-- | src/mongo/db/catalog/index_catalog.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp index 5da12b6638c..9fe6288a8ea 100644 --- a/src/mongo/db/catalog/index_catalog.cpp +++ b/src/mongo/db/catalog/index_catalog.cpp @@ -970,20 +970,24 @@ namespace { // --------------------------- + namespace { + bool isDupsAllowed( IndexDescriptor* desc ) { + bool isUnique = desc->unique() || KeyPattern::isIdKeyPattern(desc->keyPattern()); + if ( !isUnique ) + return true; + + return repl::getGlobalReplicationCoordinator()->shouldIgnoreUniqueIndex(desc); + } + + } + Status IndexCatalog::_indexRecord(OperationContext* txn, IndexCatalogEntry* index, const BSONObj& obj, const DiskLoc &loc ) { InsertDeleteOptions options; options.logIfError = false; - - bool isUnique = - KeyPattern::isIdKeyPattern(index->descriptor()->keyPattern()) || - index->descriptor()->unique(); - - options.dupsAllowed = - repl::getGlobalReplicationCoordinator()->shouldIgnoreUniqueIndex(index->descriptor()) - || !isUnique; + options.dupsAllowed = isDupsAllowed( index->descriptor() ); int64_t inserted; return index->accessMethod()->insert(txn, obj, loc, options, &inserted); @@ -996,6 +1000,7 @@ namespace { bool logIfError) { InsertDeleteOptions options; options.logIfError = logIfError; + options.dupsAllowed = isDupsAllowed( index->descriptor() ); int64_t removed; Status status = index->accessMethod()->remove(txn, obj, loc, options, &removed); |