diff options
author | Eliot Horowitz <eliot@10gen.com> | 2012-01-17 12:04:55 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2012-01-17 12:04:55 -0500 |
commit | 2f94dce03fe1543bbf2af3d3af3668d58bb8ba7e (patch) | |
tree | 64e3c29a885635436b1618f61e865a8334e7d2a7 /src/mongo/db | |
parent | 524af38b3f62cf5b4e9a3feca2d422a0f4d4b3d6 (diff) | |
download | mongo-2f94dce03fe1543bbf2af3d3af3668d58bb8ba7e.tar.gz |
fix writebackId and getLastError integration
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/dbcommands.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/lasterror.cpp | 15 | ||||
-rw-r--r-- | src/mongo/db/lasterror.h | 7 |
3 files changed, 23 insertions, 6 deletions
diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp index 0491135b332..6561cf8ab9d 100644 --- a/src/mongo/db/dbcommands.cpp +++ b/src/mongo/db/dbcommands.cpp @@ -121,10 +121,13 @@ namespace mongo { bool err = false; - if ( le->nPrev != 1 ) + if ( le->nPrev != 1 ) { err = LastError::noError.appendSelf( result , false ); - else + le->appendSelfStatus( result ); + } + else { err = le->appendSelf( result , false ); + } Client& c = cc(); c.appendLastOp( result ); diff --git a/src/mongo/db/lasterror.cpp b/src/mongo/db/lasterror.cpp index 4ed4dfb0571..dbd3f1815d4 100644 --- a/src/mongo/db/lasterror.cpp +++ b/src/mongo/db/lasterror.cpp @@ -47,7 +47,17 @@ namespace mongo { } } + void LastError::appendSelfStatus( BSONObjBuilder &b ) { + if ( writebackId.isSet() ) { + b.append( "writeback" , writebackId ); + b.append( "instanceIdent" , prettyHostName() ); // this can be any unique string + } + } + bool LastError::appendSelf( BSONObjBuilder &b , bool blankErr ) { + + appendSelfStatus( b ); + if ( !valid ) { if ( blankErr ) b.appendNull( "err" ); @@ -70,10 +80,7 @@ namespace mongo { b.appendBool( "updatedExisting", updatedExisting == True ); if ( upsertedId.isSet() ) b.append( "upserted" , upsertedId ); - if ( writebackId.isSet() ) { - b.append( "writeback" , writebackId ); - b.append( "instanceIdent" , prettyHostName() ); // this can be any unique string - } + b.appendNumber( "n", nObjects ); return ! msg.empty(); diff --git a/src/mongo/db/lasterror.h b/src/mongo/db/lasterror.h index 1e7a60274b2..b47a936caeb 100644 --- a/src/mongo/db/lasterror.h +++ b/src/mongo/db/lasterror.h @@ -73,6 +73,13 @@ namespace mongo { */ bool appendSelf( BSONObjBuilder &b , bool blankErr = true ); + /** + * appends fields which are not "error" related + * this whole mechanism needs to be re-written + * but needs a lot of real thought + */ + void appendSelfStatus( BSONObjBuilder &b ); + struct Disabled : boost::noncopyable { Disabled( LastError * le ) { _le = le; |