Common subdirectories: mongodb-src-r2.0.3/db/commands and mongo-2.0.3-thumb/db/commands diff -c mongodb-src-r2.0.3/db/dbhelpers.cpp mongo-2.0.3-thumb/db/dbhelpers.cpp *** mongodb-src-r2.0.3/db/dbhelpers.cpp Mon Feb 27 00:44:09 2012 --- mongo-2.0.3-thumb/db/dbhelpers.cpp Mon Mar 12 15:59:03 2012 *************** *** 199,212 **** return true; } ! void Helpers::upsert( const string& ns , const BSONObj& o ) { BSONElement e = o["_id"]; assert( e.type() ); BSONObj id = e.wrap(); OpDebug debug; Client::Context context(ns); ! updateObjects(ns.c_str(), o, /*pattern=*/id, /*upsert=*/true, /*multi=*/false , /*logtheop=*/true , debug ); } void Helpers::putSingleton(const char *ns, BSONObj obj) { --- 199,212 ---- return true; } ! void Helpers::upsert( const string& ns , const BSONObj& o, bool fromMigrate ) { BSONElement e = o["_id"]; assert( e.type() ); BSONObj id = e.wrap(); OpDebug debug; Client::Context context(ns); ! updateObjects(ns.c_str(), o, /*pattern=*/id, /*upsert=*/true, /*multi=*/false , /*logtheop=*/true , debug, fromMigrate ); } void Helpers::putSingleton(const char *ns, BSONObj obj) { *************** *** 237,243 **** return me.obj(); } ! long long Helpers::removeRange( const string& ns , const BSONObj& min , const BSONObj& max , bool yield , bool maxInclusive , RemoveCallback * callback ) { BSONObj keya , keyb; BSONObj minClean = toKeyFormat( min , keya ); BSONObj maxClean = toKeyFormat( max , keyb ); --- 237,243 ---- return me.obj(); } ! long long Helpers::removeRange( const string& ns , const BSONObj& min , const BSONObj& max , bool yield , bool maxInclusive , RemoveCallback * callback, bool fromMigrate ) { BSONObj keya , keyb; BSONObj minClean = toKeyFormat( min , keya ); BSONObj maxClean = toKeyFormat( max , keyb ); *************** *** 278,284 **** c->advance(); c->noteLocation(); ! logOp( "d" , ns.c_str() , rloc.obj()["_id"].wrap() ); theDataFileMgr.deleteRecord(ns.c_str() , rloc.rec(), rloc); num++; --- 278,284 ---- c->advance(); c->noteLocation(); ! logOp( "d" , ns.c_str() , rloc.obj()["_id"].wrap(), 0, 0, fromMigrate ); theDataFileMgr.deleteRecord(ns.c_str() , rloc.rec(), rloc); num++; diff -c mongodb-src-r2.0.3/db/dbhelpers.h mongo-2.0.3-thumb/db/dbhelpers.h *** mongodb-src-r2.0.3/db/dbhelpers.h Mon Feb 27 00:44:09 2012 --- mongo-2.0.3-thumb/db/dbhelpers.h Mon Mar 12 15:59:46 2012 *************** *** 94,100 **** * you do not have to have Context set * o has to have an _id field or will assert */ ! static void upsert( const string& ns , const BSONObj& o ); /** You do not need to set the database before calling. @return true if collection is empty. --- 94,100 ---- * you do not have to have Context set * o has to have an _id field or will assert */ ! static void upsert( const string& ns , const BSONObj& o, bool fromMigrate = false ); /** You do not need to set the database before calling. @return true if collection is empty. *************** *** 110,116 **** virtual void goingToDelete( const BSONObj& o ) = 0; }; /* removeRange: operation is oplog'd */ ! static long long removeRange( const string& ns , const BSONObj& min , const BSONObj& max , bool yield = false , bool maxInclusive = false , RemoveCallback * callback = 0 ); /* Remove all objects from a collection. You do not need to set the database before calling. --- 110,116 ---- virtual void goingToDelete( const BSONObj& o ) = 0; }; /* removeRange: operation is oplog'd */ ! static long long removeRange( const string& ns , const BSONObj& min , const BSONObj& max , bool yield = false , bool maxInclusive = false , RemoveCallback * callback = 0, bool fromMigrate = false ); /* Remove all objects from a collection. You do not need to set the database before calling. Common subdirectories: mongodb-src-r2.0.3/db/geo and mongo-2.0.3-thumb/db/geo Common subdirectories: mongodb-src-r2.0.3/db/helpers and mongo-2.0.3-thumb/db/helpers Common subdirectories: mongodb-src-r2.0.3/db/modules and mongo-2.0.3-thumb/db/modules diff -c mongodb-src-r2.0.3/db/oplog.cpp mongo-2.0.3-thumb/db/oplog.cpp *** mongodb-src-r2.0.3/db/oplog.cpp Mon Feb 27 00:44:09 2012 --- mongo-2.0.3-thumb/db/oplog.cpp Mon Mar 12 16:07:33 2012 *************** *** 47,53 **** resetSlaveCache(); } ! static void _logOpUninitialized(const char *opstr, const char *ns, const char *logNS, const BSONObj& obj, BSONObj *o2, bool *bb ) { uassert(13288, "replSet error write op to db before replSet initialized", str::startsWith(ns, "local.") || *opstr == 'n'); } --- 47,53 ---- resetSlaveCache(); } ! static void _logOpUninitialized(const char *opstr, const char *ns, const char *logNS, const BSONObj& obj, BSONObj *o2, bool *bb, bool fromMigrate ) { uassert(13288, "replSet error write op to db before replSet initialized", str::startsWith(ns, "local.") || *opstr == 'n'); } *************** *** 123,129 **** // the compiler would use if inside the function. the reason this is static is to avoid a malloc/free for this // on every logop call. static BufBuilder logopbufbuilder(8*1024); ! static void _logOpRS(const char *opstr, const char *ns, const char *logNS, const BSONObj& obj, BSONObj *o2, bool *bb ) { DEV assertInWriteLock(); if ( strncmp(ns, "local.", 6) == 0 ) { --- 123,129 ---- // the compiler would use if inside the function. the reason this is static is to avoid a malloc/free for this // on every logop call. static BufBuilder logopbufbuilder(8*1024); ! static void _logOpRS(const char *opstr, const char *ns, const char *logNS, const BSONObj& obj, BSONObj *o2, bool *bb, bool fromMigrate ) { DEV assertInWriteLock(); if ( strncmp(ns, "local.", 6) == 0 ) { *************** *** 154,159 **** --- 154,161 ---- b.append("h", hashNew); b.append("op", opstr); b.append("ns", ns); + if (fromMigrate) + b.appendBool("fromMigrate", true); if ( bb ) b.appendBool("b", *bb); if ( o2 ) *************** *** 217,223 **** note this is used for single collection logging even when --replSet is enabled. */ ! static void _logOpOld(const char *opstr, const char *ns, const char *logNS, const BSONObj& obj, BSONObj *o2, bool *bb ) { DEV assertInWriteLock(); static BufBuilder bufbuilder(8*1024); --- 219,225 ---- note this is used for single collection logging even when --replSet is enabled. */ ! static void _logOpOld(const char *opstr, const char *ns, const char *logNS, const BSONObj& obj, BSONObj *o2, bool *bb, bool fromMigrate ) { DEV assertInWriteLock(); static BufBuilder bufbuilder(8*1024); *************** *** 240,246 **** b.appendTimestamp("ts", ts.asDate()); b.append("op", opstr); b.append("ns", ns); ! if ( bb ) b.appendBool("b", *bb); if ( o2 ) b.append("o2", *o2); --- 242,250 ---- b.appendTimestamp("ts", ts.asDate()); b.append("op", opstr); b.append("ns", ns); ! if (fromMigrate) ! b.appendBool("fromMigrate", true); ! if ( bb ) b.appendBool("b", *bb); if ( o2 ) b.append("o2", *o2); *************** *** 280,286 **** } ! static void (*_logOp)(const char *opstr, const char *ns, const char *logNS, const BSONObj& obj, BSONObj *o2, bool *bb ) = _logOpOld; void newReplUp() { replSettings.master = true; _logOp = _logOpRS; --- 284,290 ---- } ! static void (*_logOp)(const char *opstr, const char *ns, const char *logNS, const BSONObj& obj, BSONObj *o2, bool *bb, bool fromMigrate ) = _logOpOld; void newReplUp() { replSettings.master = true; _logOp = _logOpRS; *************** *** 292,304 **** void oldRepl() { _logOp = _logOpOld; } void logKeepalive() { ! _logOp("n", "", 0, BSONObj(), 0, 0); } void logOpComment(const BSONObj& obj) { ! _logOp("n", "", 0, obj, 0, 0); } void logOpInitiate(const BSONObj& obj) { ! _logOpRS("n", "", 0, obj, 0, 0); } /*@ @param opstr: --- 296,308 ---- void oldRepl() { _logOp = _logOpOld; } void logKeepalive() { ! _logOp("n", "", 0, BSONObj(), 0, 0, false); } void logOpComment(const BSONObj& obj) { ! _logOp("n", "", 0, obj, 0, 0, false); } void logOpInitiate(const BSONObj& obj) { ! _logOpRS("n", "", 0, obj, 0, 0, false); } /*@ @param opstr: *************** *** 308,316 **** d delete / remove u update */ ! void logOp(const char *opstr, const char *ns, const BSONObj& obj, BSONObj *patt, bool *b) { if ( replSettings.master ) { ! _logOp(opstr, ns, 0, obj, patt, b); } logOpForSharding( opstr , ns , obj , patt ); --- 312,320 ---- d delete / remove u update */ ! void logOp(const char *opstr, const char *ns, const BSONObj& obj, BSONObj *patt, bool *b, bool fromMigrate) { if ( replSettings.master ) { ! _logOp(opstr, ns, 0, obj, patt, b, fromMigrate); } logOpForSharding( opstr , ns , obj , patt ); diff -c mongodb-src-r2.0.3/db/oplog.h mongo-2.0.3-thumb/db/oplog.h *** mongodb-src-r2.0.3/db/oplog.h Mon Feb 27 00:44:09 2012 --- mongo-2.0.3-thumb/db/oplog.h Mon Mar 12 16:18:48 2012 *************** *** 49,55 **** See _logOp() in oplog.cpp for more details. */ ! void logOp(const char *opstr, const char *ns, const BSONObj& obj, BSONObj *patt = 0, bool *b = 0); void logKeepalive(); --- 49,55 ---- See _logOp() in oplog.cpp for more details. */ ! void logOp(const char *opstr, const char *ns, const BSONObj& obj, BSONObj *patt = 0, bool *b = 0, bool fromMigrate = false); void logKeepalive(); Common subdirectories: mongodb-src-r2.0.3/db/ops and mongo-2.0.3-thumb/db/ops diff -c mongodb-src-r2.0.3/db/pdfile.cpp mongo-2.0.3-thumb/db/pdfile.cpp *** mongodb-src-r2.0.3/db/pdfile.cpp Mon Feb 27 00:44:09 2012 --- mongo-2.0.3-thumb/db/pdfile.cpp Mon Mar 12 16:35:04 2012 *************** *** 1539,1548 **** } idToInsert; #pragma pack() ! void DataFileMgr::insertAndLog( const char *ns, const BSONObj &o, bool god ) { BSONObj tmp = o; 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 --- 1539,1548 ---- } idToInsert; #pragma pack() ! void DataFileMgr::insertAndLog( const char *ns, const BSONObj &o, bool god, bool fromMigrate) { BSONObj tmp = o; insertWithObjMod( ns, tmp, god ); ! logOp( "i", ns, tmp, 0, 0, fromMigrate ); } /** @param o the object to insert. can be modified to add _id and thus be an in/out param diff -c mongodb-src-r2.0.3/db/pdfile.h mongo-2.0.3-thumb/db/pdfile.h *** mongodb-src-r2.0.3/db/pdfile.h Mon Feb 27 00:44:09 2012 --- mongo-2.0.3-thumb/db/pdfile.h Mon Mar 12 16:13:19 2012 *************** *** 118,124 **** const char *buf, int len, OpDebug& debug, bool god=false); // The object o may be updated if modified on insert. ! void insertAndLog( const char *ns, const BSONObj &o, bool god = false ); /** 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. --- 118,124 ---- const char *buf, int len, OpDebug& debug, bool god=false); // The object o may be updated if modified on insert. ! void insertAndLog( const char *ns, const BSONObj &o, bool god = false, bool fromMigrate = false ); /** 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. Common subdirectories: mongodb-src-r2.0.3/db/repl and mongo-2.0.3-thumb/db/repl Common subdirectories: mongodb-src-r2.0.3/db/stats and mongo-2.0.3-thumb/db/stats