diff --git a/db/cloner.cpp b/db/cloner.cpp index aec79efda9a..63617f6b074 100644 --- a/db/cloner.cpp +++ b/db/cloner.cpp @@ -147,7 +147,7 @@ namespace mongo { } try { - theDataFileMgr.insertWithObjModNoRet(to_collection, js); + theDataFileMgr.insertWithObjMod(to_collection, js); if ( logForRepl ) logOp("i", to_collection, js); @@ -216,7 +216,7 @@ namespace mongo { for ( list::iterator i = storedForLater.begin(); i!=storedForLater.end(); i++ ) { BSONObj js = *i; try { - theDataFileMgr.insertWithObjModNoRet(to_collection, js); + theDataFileMgr.insertWithObjMod(to_collection, js); if ( logForRepl ) logOp("i", to_collection, js); @@ -686,7 +686,7 @@ namespace mongo { break; } BSONObj o = c->next(); - theDataFileMgr.insertWithObjModNoRet( target.c_str(), o ); + theDataFileMgr.insertWithObjMod( target.c_str(), o ); } char cl[256]; @@ -717,7 +717,7 @@ namespace mongo { } } BSONObj n = b.done(); - theDataFileMgr.insertWithObjModNoRet( targetIndexes.c_str(), n ); + theDataFileMgr.insertWithObjMod( targetIndexes.c_str(), n ); } { diff --git a/db/commands/mr.cpp b/db/commands/mr.cpp index 5ff3bd07323..bf52f46176f 100644 --- a/db/commands/mr.cpp +++ b/db/commands/mr.cpp @@ -483,7 +483,7 @@ namespace mongo { */ void State::_insertToInc( BSONObj& o ) { assert( _onDisk ); - theDataFileMgr.insertWithObjModNoRet( _config.incLong.c_str() , o , true ); + theDataFileMgr.insertWithObjMod( _config.incLong.c_str() , o , true ); getDur().commitIfNeeded(); } diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp index 27d8a0539f7..e763c984de9 100644 --- a/db/dbcommands.cpp +++ b/db/dbcommands.cpp @@ -871,7 +871,7 @@ namespace mongo { for ( list::iterator i=all.begin(); i!=all.end(); i++ ) { BSONObj o = *i; - theDataFileMgr.insertWithObjModNoRet( Namespace( toDeleteNs.c_str() ).getSisterNS( "system.indexes" ).c_str() , o , true ); + theDataFileMgr.insertWithObjMod( Namespace( toDeleteNs.c_str() ).getSisterNS( "system.indexes" ).c_str() , o , true ); } result.append( "nIndexes" , (int)all.size() ); @@ -1483,7 +1483,7 @@ namespace mongo { uassert( 13049, "godinsert must specify a collection", !coll.empty() ); string ns = dbname + "." + coll; BSONObj obj = cmdObj[ "obj" ].embeddedObjectUserCheck(); - theDataFileMgr.insertWithObjModNoRet( ns.c_str(), obj, true ); + theDataFileMgr.insertWithObjMod( ns.c_str(), obj, true ); return true; } } cmdGodInsert; diff --git a/db/dbhelpers.cpp b/db/dbhelpers.cpp index 38a3b7ef3b7..ffdcb62e248 100644 --- a/db/dbhelpers.cpp +++ b/db/dbhelpers.cpp @@ -332,7 +332,7 @@ namespace mongo { if ( val ) { try { BSONObj k = obj; - theDataFileMgr.insertWithObjModNoRet( name_.c_str(), k, false ); + theDataFileMgr.insertWithObjMod( name_.c_str(), k, false ); } catch ( DBException& ) { // dup key - already in set diff --git a/db/instance.cpp b/db/instance.cpp index 2a97c60e57c..3ec07428c56 100644 --- a/db/instance.cpp +++ b/db/instance.cpp @@ -580,7 +580,7 @@ namespace mongo { uassert( 13511 , "document to insert can't have $ fields" , e.fieldName()[0] != '$' ); } } - theDataFileMgr.insertWithObjModNoRet(ns, js, false); // js may be modified in the call to add an _id field. + theDataFileMgr.insertWithObjMod(ns, js, false); // js may be modified in the call to add an _id field. logOp("i", ns, js); } diff --git a/db/pdfile.cpp b/db/pdfile.cpp index b830915b161..226b85f268b 100644 --- a/db/pdfile.cpp +++ b/db/pdfile.cpp @@ -1517,23 +1517,20 @@ namespace mongo { void DataFileMgr::insertAndLog( const char *ns, const BSONObj &o, bool god ) { BSONObj tmp = o; - insertWithObjModNoRet( ns, tmp, god ); + insertWithObjMod( ns, tmp, god ); logOp( "i", ns, tmp ); } /** @param o the object to insert. can be modified to add _id and thus be an in/out param */ DiskLoc DataFileMgr::insertWithObjMod(const char *ns, BSONObj &o, bool god) { - DiskLoc loc = insert( ns, o.objdata(), o.objsize(), god ); - if ( !loc.isNull() ) + bool addedID = false; + DiskLoc loc = insert( ns, o.objdata(), o.objsize(), god, true, &addedID ); + if( addedID && !loc.isNull() ) o = BSONObj( loc.rec() ); return loc; } - void DataFileMgr::insertNoReturnVal(const char *ns, BSONObj o, bool god) { - insert( ns, o.objdata(), o.objsize(), god ); - } - bool prepareToBuildIndex(const BSONObj& io, bool god, string& sourceNS, NamespaceDetails *&sourceCollection, BSONObj& fixedIndexObject ); // We are now doing two btree scans for all unique indexes (one here, and one when we've diff --git a/db/pdfile.h b/db/pdfile.h index f44c6657a33..049f6bfddba 100644 --- a/db/pdfile.h +++ b/db/pdfile.h @@ -120,14 +120,12 @@ namespace mongo { // The object o may be updated if modified on insert. void insertAndLog( const char *ns, const BSONObj &o, bool god = false ); - /** @param o both and in and out param -- insert can sometimes modify an object (such as add _id). */ + /** insert will add an _id to the object if not present. if you would like to see the final object + after such an addition, use this method. + @param o both and in and out param + */ DiskLoc insertWithObjMod(const char *ns, BSONObj & /*out*/o, bool god = false); - // todo eliminate - void insertWithObjModNoRet(const char *ns, BSONObj &o, bool god = false) { - insertWithObjMod(ns, o, god); - } - /** @param obj in value only for this version. */ void insertNoReturnVal(const char *ns, BSONObj o, bool god = false); diff --git a/db/update.cpp b/db/update.cpp index 3be64635208..c1bfae2f950 100644 --- a/db/update.cpp +++ b/db/update.cpp @@ -1255,7 +1255,7 @@ namespace mongo { /* upsert of an $inc. build a default */ BSONObj newObj = mods->createNewFromQuery( patternOrig ); debug.fastmodinsert = true; - theDataFileMgr.insertWithObjModNoRet(ns, newObj, god); + theDataFileMgr.insertWithObjMod(ns, newObj, god); if ( logop ) logOp( "i", ns, newObj ); @@ -1265,7 +1265,7 @@ namespace mongo { checkNoMods( updateobj ); debug.upsert = true; BSONObj no = updateobj; - theDataFileMgr.insertWithObjModNoRet(ns, no, god); + theDataFileMgr.insertWithObjMod(ns, no, god); if ( logop ) logOp( "i", ns, no ); return UpdateResult( 0 , 0 , 1 , no ); diff --git a/dbtests/framework.cpp b/dbtests/framework.cpp index f8d725b7602..6e85521f7ab 100644 --- a/dbtests/framework.cpp +++ b/dbtests/framework.cpp @@ -292,6 +292,9 @@ namespace mongo { srand( (unsigned) seed ); printGitVersion(); printSysInfo(); + DEV log() << "_DEBUG build" << endl; + if( sizeof(void*)==4 ) + log() << "32bit" << endl; log() << "random seed: " << seed << endl; FileAllocator::get()->start();