| update.h | | update.h | |
| | | | |
| skipping to change at line 329 | | skipping to change at line 329 | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * stores any information about a single Mod operating on a single Obje
ct | | * stores any information about a single Mod operating on a single Obje
ct | |
| */ | | */ | |
| class ModState { | | class ModState { | |
| public: | | public: | |
| const Mod * m; | | const Mod * m; | |
| BSONElement old; | | BSONElement old; | |
| | | | |
|
| const char * fixedName; | | const char * fixedOpName; | |
| BSONElement * fixed; | | BSONElement * fixed; | |
| int pushStartSize; | | int pushStartSize; | |
| | | | |
| BSONType incType; | | BSONType incType; | |
| int incint; | | int incint; | |
| double incdouble; | | double incdouble; | |
| long long inclong; | | long long inclong; | |
| | | | |
| ModState(){ | | ModState(){ | |
|
| fixedName = 0; | | fixedOpName = 0; | |
| fixed = 0; | | fixed = 0; | |
| pushStartSize = -1; | | pushStartSize = -1; | |
| incType = EOO; | | incType = EOO; | |
| } | | } | |
| | | | |
| Mod::Op op() const { | | Mod::Op op() const { | |
| return m->op; | | return m->op; | |
| } | | } | |
| | | | |
| const char * fieldName() const { | | const char * fieldName() const { | |
| return m->fieldName; | | return m->fieldName; | |
| } | | } | |
| | | | |
| bool needOpLogRewrite() const { | | bool needOpLogRewrite() const { | |
|
| if ( fixed || fixedName || incType ) | | if ( fixed || fixedOpName || incType ) | |
| return true; | | return true; | |
| | | | |
| switch( op() ){ | | switch( op() ){ | |
| case Mod::BIT: | | case Mod::BIT: | |
| case Mod::BITAND: | | case Mod::BITAND: | |
| case Mod::BITOR: | | case Mod::BITOR: | |
| // TODO: should we convert this to $set? | | // TODO: should we convert this to $set? | |
| return false; | | return false; | |
| default: | | default: | |
| return false; | | return false; | |
| | | | |
| skipping to change at line 376 | | skipping to change at line 376 | |
| } | | } | |
| | | | |
| void appendForOpLog( BSONObjBuilder& b ) const { | | void appendForOpLog( BSONObjBuilder& b ) const { | |
| if ( incType ){ | | if ( incType ){ | |
| BSONObjBuilder bb( b.subobjStart( "$set" ) ); | | BSONObjBuilder bb( b.subobjStart( "$set" ) ); | |
| appendIncValue( bb ); | | appendIncValue( bb ); | |
| bb.done(); | | bb.done(); | |
| return; | | return; | |
| } | | } | |
| | | | |
|
| const char * name = fixedName ? fixedName : Mod::modNames[op()]
; | | const char * name = fixedOpName ? fixedOpName : Mod::modNames[o
p()]; | |
| | | | |
| BSONObjBuilder bb( b.subobjStart( name ) ); | | BSONObjBuilder bb( b.subobjStart( name ) ); | |
| if ( fixed ) | | if ( fixed ) | |
| bb.appendAs( *fixed , m->fieldName ); | | bb.appendAs( *fixed , m->fieldName ); | |
| else | | else | |
|
| bb.append( m->elt ); | | bb.appendAs( m->elt , m->fieldName ); | |
| bb.done(); | | bb.done(); | |
| } | | } | |
| | | | |
| template< class Builder > | | template< class Builder > | |
| void apply( Builder& b , BSONElement in ){ | | void apply( Builder& b , BSONElement in ){ | |
| m->apply( b , in , *this ); | | m->apply( b , in , *this ); | |
| } | | } | |
| | | | |
| template< class Builder > | | template< class Builder > | |
| void appendIncValue( Builder& b ) const { | | void appendIncValue( Builder& b ) const { | |
| | | | |
| skipping to change at line 472 | | skipping to change at line 472 | |
| break; | | break; | |
| } | | } | |
| | | | |
| case Mod::UNSET: | | case Mod::UNSET: | |
| case Mod::PULL: | | case Mod::PULL: | |
| case Mod::PULL_ALL: | | case Mod::PULL_ALL: | |
| // no-op b/c unset/pull of nothing does nothing | | // no-op b/c unset/pull of nothing does nothing | |
| break; | | break; | |
| | | | |
| case Mod::INC: | | case Mod::INC: | |
|
| ms.fixedName = "$set"; | | ms.fixedOpName = "$set"; | |
| case Mod::SET: { | | case Mod::SET: { | |
| m._checkForAppending( m.elt ); | | m._checkForAppending( m.elt ); | |
| b.appendAs( m.elt, m.shortFieldName ); | | b.appendAs( m.elt, m.shortFieldName ); | |
| break; | | break; | |
| } | | } | |
| default: | | default: | |
| stringstream ss; | | stringstream ss; | |
| ss << "unknown mod in appendNewFromMod: " << m.op; | | ss << "unknown mod in appendNewFromMod: " << m.op; | |
| throw UserException( 9015, ss.str() ); | | throw UserException( 9015, ss.str() ); | |
| } | | } | |
| | | | |
End of changes. 6 change blocks. |
| 6 lines changed or deleted | | 6 lines changed or added | |
|