summaryrefslogtreecommitdiff
path: root/src/mongo/s/cluster_write.cpp
diff options
context:
space:
mode:
authorGreg Studer <greg@10gen.com>2014-04-09 10:28:13 -0400
committerGreg Studer <greg@10gen.com>2014-04-11 17:01:15 -0400
commit4b589d8aab1675e03dc7efafc32239bda660fe96 (patch)
tree590369c2e90869427398acb1302c8e077178602f /src/mongo/s/cluster_write.cpp
parent225d63787821ddf35a5c04b7f22ed17da7042210 (diff)
downloadmongo-4b589d8aab1675e03dc7efafc32239bda660fe96.tar.gz
SERVER-13518 generate _ids in write batches if not set in mongos
Diffstat (limited to 'src/mongo/s/cluster_write.cpp')
-rw-r--r--src/mongo/s/cluster_write.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mongo/s/cluster_write.cpp b/src/mongo/s/cluster_write.cpp
index 8b2008f02b8..15cd83c2be0 100644
--- a/src/mongo/s/cluster_write.cpp
+++ b/src/mongo/s/cluster_write.cpp
@@ -315,9 +315,13 @@ namespace mongo {
dassert( response->isValid(NULL) );
}
- void ClusterWriter::write( const BatchedCommandRequest& request,
+ void ClusterWriter::write( const BatchedCommandRequest& origRequest,
BatchedCommandResponse* response ) {
+ // Add _ids to insert request if req'd
+ auto_ptr<BatchedCommandRequest> idRequest(BatchedCommandRequest::cloneWithIds(origRequest));
+ const BatchedCommandRequest& request = NULL != idRequest.get() ? *idRequest : origRequest;
+
const NamespaceString nss = NamespaceString( request.getNS() );
if ( !nss.isValid() ) {
toBatchError( Status( ErrorCodes::InvalidNamespace,