summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/index_catalog.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2014-10-16 09:08:28 -0400
committerEliot Horowitz <eliot@10gen.com>2014-10-16 17:56:42 -0400
commit34cfe32ab4c0751ceb55b607c05dc593c3dd901c (patch)
tree708e7fa2ba33df6a195bbae6d957308c07bbf28d /src/mongo/db/catalog/index_catalog.cpp
parent5af2cac9e0de1bf20eba4790ecc3547c679dfd13 (diff)
downloadmongo-34cfe32ab4c0751ceb55b607c05dc593c3dd901c.tar.gz
SERVER-13635: pass whether an index is unique or not down through SortedDataInterface
Diffstat (limited to 'src/mongo/db/catalog/index_catalog.cpp')
-rw-r--r--src/mongo/db/catalog/index_catalog.cpp21
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);