0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00

better error message on dup key SERVER-81

added some const
This commit is contained in:
Eliot Horowitz 2009-06-01 14:17:44 -04:00
parent e3a3919baa
commit 48a68868f2
3 changed files with 12 additions and 3 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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);