summaryrefslogtreecommitdiff
path: root/src/mongo/db/lasterror.h
diff options
context:
space:
mode:
authorScott Hernandez <scotthernandez@gmail.com>2013-10-08 12:06:00 -0400
committerScott Hernandez <scotthernandez@gmail.com>2013-10-10 21:51:57 -0400
commit80c79f8464d26ca128b2455a8e02c9882f8c4640 (patch)
tree4868936fefef2bcd3694bf6fb5ff2a5fd0c662ea /src/mongo/db/lasterror.h
parentc1ab952e098b24f691f2fd5e6bf162a972b9c5f9 (diff)
downloadmongo-80c79f8464d26ca128b2455a8e02c9882f8c4640.tar.gz
SERVER-1351: return new _id from inserted doc from update
Diffstat (limited to 'src/mongo/db/lasterror.h')
-rw-r--r--src/mongo/db/lasterror.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/mongo/db/lasterror.h b/src/mongo/db/lasterror.h
index 65c1a723be1..4a4e7b1ae78 100644
--- a/src/mongo/db/lasterror.h
+++ b/src/mongo/db/lasterror.h
@@ -20,6 +20,7 @@
#include <boost/thread/tss.hpp>
#include <string>
+#include "mongo/db/jsobj.h"
#include "mongo/bson/oid.h"
#include "mongo/util/log.h"
@@ -27,11 +28,14 @@ namespace mongo {
class BSONObjBuilder;
class Message;
+ static const char kUpsertedFieldName[] = "upserted";
+
struct LastError {
int code;
std::string msg;
enum UpdatedExistingType { NotUpdate, True, False } updatedExisting;
- OID upsertedId;
+ // _id field value from inserted doc, returned as kUpsertedFieldName (above)
+ BSONObj upsertedId;
OID writebackId; // this shouldn't get reset so that old GLE are handled
int writebackSince;
long long nObjects;
@@ -48,11 +52,11 @@ namespace mongo {
code = _code;
msg = _msg;
}
- void recordUpdate( bool _updateObjects , long long _nObjects , OID _upsertedId ) {
+ void recordUpdate( bool _updateObjects , long long _nObjects , BSONObj _upsertedId ) {
reset( true );
nObjects = _nObjects;
updatedExisting = _updateObjects ? True : False;
- if ( _upsertedId.isSet() )
+ if ( _upsertedId.valid() && _upsertedId.hasField(kUpsertedFieldName) )
upsertedId = _upsertedId;
}
@@ -72,7 +76,7 @@ namespace mongo {
nPrev = 1;
valid = _valid;
disabled = false;
- upsertedId.clear();
+ upsertedId = BSONObj();
}
/**