mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 01:21:03 +01:00
parent
e3a3919baa
commit
48a68868f2
12
db/btree.cpp
12
db/btree.cpp
@ -313,6 +313,14 @@ namespace mongo {
|
||||
return false;
|
||||
}
|
||||
|
||||
string BtreeBucket::dupKeyError( const IndexDetails& idx , const BSONObj& key ){
|
||||
stringstream ss;
|
||||
ss << "E11000 duplicate key error";
|
||||
ss << "index: " << idx.indexNamespace() << " ";
|
||||
ss << "dup key: " << key;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
/* Find a key withing this btree bucket.
|
||||
|
||||
When duplicate keys are allowed, we use the DiskLoc of the record as if it were part of the
|
||||
@ -357,11 +365,11 @@ namespace mongo {
|
||||
if( !dupsChecked ) {
|
||||
dupsChecked = true;
|
||||
if( idx.head.btree()->exists(idx, idx.head, key, order) )
|
||||
uasserted("E11000 duplicate key error");
|
||||
uasserted( dupKeyError( idx , key ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
uasserted("E11000 duplicate key error");
|
||||
uasserted( dupKeyError( idx , key ) );
|
||||
}
|
||||
|
||||
// dup keys allowed. use recordLoc as if it is part of the key
|
||||
|
@ -203,6 +203,7 @@ namespace mongo {
|
||||
DiskLoc lChild, DiskLoc rChild, IndexDetails&);
|
||||
bool find(const IndexDetails& idx, const BSONObj& key, DiskLoc recordLoc, const BSONObj &order, int& pos, bool assertIfDup);
|
||||
static void findLargestKey(const DiskLoc& thisLoc, DiskLoc& largestLoc, int& largestKey);
|
||||
string dupKeyError( const IndexDetails& idx , const BSONObj& key );
|
||||
};
|
||||
|
||||
class BtreeCursor : public Cursor {
|
||||
|
@ -164,7 +164,7 @@ namespace mongo {
|
||||
|
||||
// returns name of this index's storage area
|
||||
// database.table.$index
|
||||
string indexNamespace() {
|
||||
string indexNamespace() const {
|
||||
BSONObj io = info.obj();
|
||||
string s;
|
||||
s.reserve(Namespace::MaxNsLen);
|
||||
|
Loading…
Reference in New Issue
Block a user