diff options
author | Aaron <aaron@10gen.com> | 2011-06-06 10:34:20 -0400 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2011-06-09 11:45:20 -0400 |
commit | c79ca08c9d3ca006377de654407477881dfc8c82 (patch) | |
tree | 4cd47f1a327bde76c3645f29adf60c699b1b1e5a /dbtests | |
parent | ead33091f0726dc6304304956d461ece816666a8 (diff) | |
download | mongo-c79ca08c9d3ca006377de654407477881dfc8c82.tar.gz |
SERVER-2977 fix qo cursor bug when yielding a basic cursor
Diffstat (limited to 'dbtests')
-rw-r--r-- | dbtests/queryoptimizertests.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/dbtests/queryoptimizertests.cpp b/dbtests/queryoptimizertests.cpp index 44007acbf4c..89904a35ef7 100644 --- a/dbtests/queryoptimizertests.cpp +++ b/dbtests/queryoptimizertests.cpp @@ -2211,6 +2211,43 @@ namespace QueryOptimizerTests { } } }; + + /** Yield with BacicCursor takeover cursor. */ + class YieldTakeoverBasic : public Base { + public: + void run() { + for( int i = 0; i < 150; ++i ) { + _cli.insert( ns(), BSON( "_id" << i << "a" << BSON_ARRAY( i << i+1 ) ) ); + } + _cli.ensureIndex( ns(), BSON( "a" << 1 ) ); + + auto_ptr<ClientCursor> cc; + auto_ptr<ClientCursor::YieldData> data( new ClientCursor::YieldData() ); + { + dblock lk; + Client::Context ctx( ns() ); + setQueryOptimizerCursor( BSON( "b" << NE << 0 << "a" << GTE << 0 ) ); + cc.reset( new ClientCursor( QueryOption_NoCursorTimeout, c(), ns() ) ); + for( int i = 0; i < 120; ++i ) { + ASSERT( advance() ); + } + ASSERT( ok() ); + ASSERT_EQUALS( 120, current().getIntField( "_id" ) ); + cc->prepareToYield( *data ); + } + _cli.remove( ns(), BSON( "_id" << 120 ) ); + + { + dblock lk; + Client::Context ctx( ns() ); + ASSERT( ClientCursor::recoverFromYield( *data ) ); + ASSERT( ok() ); + ASSERT_EQUALS( 121, current().getIntField( "_id" ) ); + ASSERT( advance() ); + ASSERT_EQUALS( 122, current().getIntField( "_id" ) ); + } + } + }; /** Yield with advance of inactive cursor. */ class YieldInactiveCursorAdvance : public Base { @@ -2637,6 +2674,7 @@ namespace QueryOptimizerTests { add<QueryOptimizerCursorTests::YieldMultiplePlansCappedOverwriteManual2>(); add<QueryOptimizerCursorTests::TryYieldGeo>(); add<QueryOptimizerCursorTests::YieldTakeover>(); + add<QueryOptimizerCursorTests::YieldTakeoverBasic>(); add<QueryOptimizerCursorTests::YieldInactiveCursorAdvance>(); add<QueryOptimizerCursorTests::OrderId>(); add<QueryOptimizerCursorTests::OrderMultiIndex>(); |