diff options
author | Eliot Horowitz <eliot@10gen.com> | 2015-03-11 16:18:42 -0400 |
---|---|---|
committer | Ramon Fernandez <ramon.fernandez@mongodb.com> | 2015-03-25 18:44:03 -0400 |
commit | ff7ae37d3f16a73e9ee956c31d6938f4768000dd (patch) | |
tree | f739fa184872e02e9db839b3ec3b140d046d3199 | |
parent | d9a3c65f642ce90b1cf6f725786654998676cd20 (diff) | |
download | mongo-ff7ae37d3f16a73e9ee956c31d6938f4768000dd.tar.gz |
SERVER-17532: fix dup key error message in wiredtiger index
(cherry picked from commit 5fd3dfce18655932165ebadef0bbe5ed58f678de)
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp | 23 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_index.h | 4 |
2 files changed, 17 insertions, 10 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp index a18f88b0b07..649350cb7de 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp @@ -94,14 +94,6 @@ namespace { return bb.obj(); } - // taken from btree_logic.cpp - Status dupKeyError(const BSONObj& key) { - StringBuilder sb; - sb << "E11000 duplicate key error "; - sb << "dup key: " << key; - return Status(ErrorCodes::DuplicateKey, sb.str()); - } - Status checkKeySize(const BSONObj& key) { if ( key.objsize() >= TempKeyMaxSize ) { string msg = mongoutils::str::stream() @@ -114,6 +106,15 @@ namespace { } // namespace + Status WiredTigerIndex::dupKeyError(const BSONObj& key) { + StringBuilder sb; + sb << "E11000 duplicate key error"; + sb << " collection: " << _collectionNamespace; + sb << " index: " << _indexName; + sb << " dup key: " << key; + return Status(ErrorCodes::DuplicateKey, sb.str()); + } + // static StatusWith<std::string> WiredTigerIndex::parseIndexOptions(const BSONObj& options) { BSONForEach(elem, options) { @@ -203,7 +204,9 @@ namespace { const IndexDescriptor* desc) : _ordering(Ordering::make(desc->keyPattern())), _uri( uri ), - _instanceId( WiredTigerSession::genCursorId() ) { + _instanceId( WiredTigerSession::genCursorId() ), + _collectionNamespace( desc->parentNS() ), + _indexName( desc->indexName() ){ Status versionStatus = WiredTigerUtil::checkApplicationMetadataFormatVersion(ctx, @@ -531,7 +534,7 @@ namespace { else { // Dup found! if (!_dupsAllowed) { - return dupKeyError(newKey); + return _idx->dupKeyError(newKey); } // If we get here, we are in the weird mode where dups are allowed on a unique diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.h b/src/mongo/db/storage/wiredtiger/wiredtiger_index.h index 81f6aa57c1f..169c3789471 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.h @@ -113,6 +113,8 @@ namespace mongo { virtual bool unique() const = 0; + Status dupKeyError(const BSONObj& key); + protected: virtual Status _insert( WT_CURSOR* c, @@ -132,6 +134,8 @@ namespace mongo { const Ordering _ordering; std::string _uri; uint64_t _instanceId; + std::string _collectionNamespace; + std::string _indexName; }; |