void DatabaseCommand_DirMtimes::exec( DatabaseImpl* dbi ) { if( m_update ) execUpdate( dbi ); else execSelect( dbi ); }
void WriteBatchExecutor::bulkExecute( const BatchedCommandRequest& request, std::vector<BatchedUpsertDetail*>* upsertedIds, std::vector<WriteErrorDetail*>* errors ) { if ( request.getBatchType() == BatchedCommandRequest::BatchType_Insert ) { execInserts( request, errors ); } else if ( request.getBatchType() == BatchedCommandRequest::BatchType_Update ) { for ( size_t i = 0; i < request.sizeWriteOps(); i++ ) { WriteErrorDetail* error = NULL; BSONObj upsertedId; execUpdate( BatchItemRef( &request, i ), &upsertedId, &error ); if ( !upsertedId.isEmpty() ) { BatchedUpsertDetail* batchUpsertedId = new BatchedUpsertDetail; batchUpsertedId->setIndex( i ); batchUpsertedId->setUpsertedID( upsertedId ); upsertedIds->push_back( batchUpsertedId ); } if ( error ) { errors->push_back( error ); if ( request.getOrdered() ) break; } } } else { dassert( request.getBatchType() == BatchedCommandRequest::BatchType_Delete ); for ( size_t i = 0; i < request.sizeWriteOps(); i++ ) { WriteErrorDetail* error = NULL; execRemove( BatchItemRef( &request, i ), &error ); if ( error ) { errors->push_back( error ); if ( request.getOrdered() ) break; } } } // Fill in stale version errors for unordered batches (update/delete can't do this on own) if ( !errors->empty() && !request.getOrdered() ) { const WriteErrorDetail* finalError = errors->back(); if ( finalError->getErrCode() == ErrorCodes::StaleShardVersion ) { for ( size_t i = finalError->getIndex() + 1; i < request.sizeWriteOps(); i++ ) { WriteErrorDetail* dupStaleError = new WriteErrorDetail; finalError->cloneTo( dupStaleError ); errors->push_back( dupStaleError ); } } } }