Example #1
0
    UpdateResult updateObjects( const char* ns,
                                const BSONObj& updateobj,
                                const BSONObj& patternOrig,
                                bool upsert,
                                bool multi,
                                bool logop ,
                                OpDebug& debug,
                                bool fromMigrate,
                                const QueryPlanSelectionPolicy& planPolicy ) {

        validateUpdate( ns , updateobj , patternOrig );

        if ( isNewUpdateFrameworkEnabled() ) {

            UpdateResult ur = _updateObjectsNEW(false, ns, updateobj, patternOrig,
                                                upsert, multi, logop,
                                                debug, NULL, fromMigrate, planPolicy );
            debug.nupdated = ur.num;
            return ur;
        }
        else {

            UpdateResult ur = _updateObjects(false, ns, updateobj, patternOrig,
                                             upsert, multi, logop,
                                             debug, NULL, fromMigrate, planPolicy );
            debug.nupdated = ur.num;
            return ur;
        }
    }
Example #2
0
    void Helpers::putSingletonGod(const char *ns, BSONObj obj, bool logTheOp) {
        OpDebug debug;
        Client::Context context(ns);

        if (isNewUpdateFrameworkEnabled()) {

            _updateObjectsNEW(/*god=*/true,
                              ns,
                              obj,
                              /*pattern=*/BSONObj(),
                              /*upsert=*/true,
                              /*multi=*/false,
                              logTheOp,
                              debug );

        }
        else {

            _updateObjects(/*god=*/true,
                           ns,
                           obj,
                           /*pattern=*/BSONObj(),
                           /*upsert=*/true,
                           /*multi=*/false,
                           logTheOp,
                           debug );

        }

        context.getClient()->curop()->done();
    }
Example #3
0
    BSONObj applyUpdateOperators( const BSONObj& from, const BSONObj& operators ) {
        if ( isNewUpdateFrameworkEnabled() ) {
            UpdateDriver::Options opts;
            opts.multi = false;
            opts.upsert = false;
            UpdateDriver driver( opts );
            Status status = driver.parse( IndexPathSet(), operators );
            if ( !status.isOK() ) {
                uasserted( 16838, status.reason() );
            }

            mutablebson::Document doc( from, mutablebson::Document::kInPlaceDisabled );
            status = driver.update( StringData(), &doc, NULL /* not oplogging */ );
            if ( !status.isOK() ) {
                uasserted( 16839, status.reason() );
            }

            return doc.getObject();
        }
        else {
            ModSet mods( operators );
            return mods.prepare( from, false /* not an insertion */ )->createNewFromMods();
        }
    }