diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/field_parser.cpp | 27 | ||||
-rw-r--r-- | src/mongo/db/field_parser.h | 5 | ||||
-rw-r--r-- | src/mongo/s/write_ops/batched_command_response.cpp | 5 | ||||
-rw-r--r-- | src/mongo/s/write_ops/batched_command_response.h | 2 |
4 files changed, 34 insertions, 5 deletions
diff --git a/src/mongo/db/field_parser.cpp b/src/mongo/db/field_parser.cpp index 3d300db2ead..9328a3a9cac 100644 --- a/src/mongo/db/field_parser.cpp +++ b/src/mongo/db/field_parser.cpp @@ -129,7 +129,32 @@ namespace mongo { return FIELD_SET; } - _genFieldErrMsg(doc, field, "date or timestamp", errMsg); + _genFieldErrMsg(doc, field, "date", errMsg); + return FIELD_INVALID; + } + + FieldParser::FieldState FieldParser::extract(BSONObj doc, + const BSONField<OpTime>& field, + OpTime* out, + string* errMsg) + { + BSONElement elem = doc[field.name()]; + if (elem.eoo()) { + if (field.hasDefault()) { + *out = field.getDefault(); + return FIELD_DEFAULT; + } + else { + return FIELD_NONE; + } + } + + if (elem.type() == Timestamp) { + *out = elem._opTime(); + return FIELD_SET; + } + + _genFieldErrMsg(doc, field, "timestamp", errMsg); return FIELD_INVALID; } diff --git a/src/mongo/db/field_parser.h b/src/mongo/db/field_parser.h index 36a8776f529..53823278647 100644 --- a/src/mongo/db/field_parser.h +++ b/src/mongo/db/field_parser.h @@ -87,6 +87,11 @@ namespace mongo { string* errMsg = NULL); static FieldState extract(BSONObj doc, + const BSONField<OpTime>& field, + OpTime* out, + string* errMsg = NULL); + + static FieldState extract(BSONObj doc, const BSONField<string>& field, string* out, string* errMsg = NULL); diff --git a/src/mongo/s/write_ops/batched_command_response.cpp b/src/mongo/s/write_ops/batched_command_response.cpp index e8e4f7cf741..084956437ff 100644 --- a/src/mongo/s/write_ops/batched_command_response.cpp +++ b/src/mongo/s/write_ops/batched_command_response.cpp @@ -43,7 +43,7 @@ namespace mongo { const BSONField<long long> BatchedCommandResponse::nDocsModified("nDocsModified", 0); const BSONField<std::vector<BatchedUpsertDetail*> > BatchedCommandResponse::upsertDetails("upserted"); - const BSONField<Date_t> BatchedCommandResponse::lastOp("lastOp"); + const BSONField<OpTime> BatchedCommandResponse::lastOp("lastOp"); const BSONField<std::vector<WriteErrorDetail*> > BatchedCommandResponse::writeErrors("writeErrors"); const BSONField<BSONObj> BatchedCommandResponse::writeConcernError("writeConcernError"); @@ -176,8 +176,7 @@ namespace mongo { if ( fieldState == FieldParser::FIELD_INVALID ) return false; if ( fieldState == FieldParser::FIELD_SET ) _upsertDetails.reset( tempUpsertDetails ); - fieldState = FieldParser::extract(source, lastOp, - reinterpret_cast<Date_t*>(&_lastOp), errMsg); + fieldState = FieldParser::extract(source, lastOp, &_lastOp, errMsg); if (fieldState == FieldParser::FIELD_INVALID) return false; _isLastOpSet = fieldState == FieldParser::FIELD_SET; diff --git a/src/mongo/s/write_ops/batched_command_response.h b/src/mongo/s/write_ops/batched_command_response.h index 4f8e9db5a15..4119510f801 100644 --- a/src/mongo/s/write_ops/batched_command_response.h +++ b/src/mongo/s/write_ops/batched_command_response.h @@ -60,7 +60,7 @@ namespace mongo { static const BSONField<long long> n; static const BSONField<long long> nDocsModified; static const BSONField<std::vector<BatchedUpsertDetail*> > upsertDetails; - static const BSONField<Date_t> lastOp; + static const BSONField<OpTime> lastOp; static const BSONField<std::vector<WriteErrorDetail*> > writeErrors; static const BSONField<BSONObj> writeConcernError; |