@@ -3711,43 +3711,47 @@ namespace QueryOptimizerCursorTests {
37113711 }
37123712 };
37133713
3714+ // QUERY MIGRATION
3715+ // Cache is turned off
37143716 /* *
37153717 * If an optimal plan is cached, return a Cursor for it rather than a QueryOptimizerCursor.
37163718 */
3717- class BestSavedOptimal : public QueryOptimizerCursorTests ::Base {
3718- public:
3719- void run () {
3720- _cli.insert ( ns (), BSON ( " _id" << 1 ) );
3721- _cli.ensureIndex ( ns (), BSON ( " _id" << 1 << " q" << 1 ) );
3722- ASSERT ( _cli.query ( ns (), QUERY ( " _id" << GT << 0 ) )->more () );
3723- Lock::GlobalWrite lk;
3724- Client::Context ctx ( ns () );
3725- // Check the plan that was recorded for this query.
3726- ASSERT_EQUALS ( BSON ( " _id" << 1 ), cachedIndexForQuery ( BSON ( " _id" << GT << 0 ) ) );
3727- shared_ptr<Cursor> c = getOptimizedCursor ( ns (), BSON ( " _id" << GT << 0 ) );
3728- // No need for query optimizer cursor since the plan is optimal.
3729- ASSERT_EQUALS ( " BtreeCursor _id_" , c->toString () );
3730- }
3731- };
3732-
3719+ // class BestSavedOptimal : public QueryOptimizerCursorTests::Base {
3720+ // public:
3721+ // void run() {
3722+ // _cli.insert( ns(), BSON( "_id" << 1 ) );
3723+ // _cli.ensureIndex( ns(), BSON( "_id" << 1 << "q" << 1 ) );
3724+ // ASSERT( _cli.query( ns(), QUERY( "_id" << GT << 0 ) )->more() );
3725+ // Lock::GlobalWrite lk;
3726+ // Client::Context ctx( ns() );
3727+ // // Check the plan that was recorded for this query.
3728+ // ASSERT_EQUALS( BSON( "_id" << 1 ), cachedIndexForQuery( BSON( "_id" << GT << 0 ) ) );
3729+ // shared_ptr<Cursor> c = getOptimizedCursor( ns(), BSON( "_id" << GT << 0 ) );
3730+ // // No need for query optimizer cursor since the plan is optimal.
3731+ // ASSERT_EQUALS( "BtreeCursor _id_", c->toString() );
3732+ // }
3733+ // };
3734+
3735+ // QUERY MIGRATIOM
3736+ // Cache is turned off
37333737 /* * If a non optimal plan is a candidate a QueryOptimizerCursor should be returned, even if plan has been recorded. */
3734- class BestSavedNotOptimal : public QueryOptimizerCursorTests ::Base {
3735- public:
3736- void run () {
3737- _cli.insert ( ns (), BSON ( " _id" << 1 << " q" << 1 ) );
3738- _cli.ensureIndex ( ns (), BSON ( " q" << 1 ) );
3739- // Record {_id:1} index for this query
3740- ASSERT ( _cli.query ( ns (), QUERY ( " q" << 1 << " _id" << 1 ) )->more () );
3741- Lock::GlobalWrite lk;
3742- Client::Context ctx ( ns () );
3743- ASSERT_EQUALS ( BSON ( " _id" << 1 ),
3744- cachedIndexForQuery ( BSON ( " q" << 1 << " _id" << 1 ) ) );
3745- shared_ptr<Cursor> c = getOptimizedCursor ( ns (), BSON ( " q" << 1 << " _id" << 1 ) );
3746- // Need query optimizer cursor since the cached plan is not optimal.
3747- ASSERT_EQUALS ( " QueryOptimizerCursor" , c->toString () );
3748- }
3749- };
3750-
3738+ // class BestSavedNotOptimal : public QueryOptimizerCursorTests::Base {
3739+ // public:
3740+ // void run() {
3741+ // _cli.insert( ns(), BSON( "_id" << 1 << "q" << 1 ) );
3742+ // _cli.ensureIndex( ns(), BSON( "q" << 1 ) );
3743+ // // Record {_id:1} index for this query
3744+ // ASSERT( _cli.query( ns(), QUERY( "q" << 1 << "_id" << 1 ) )->more() );
3745+ // Lock::GlobalWrite lk;
3746+ // Client::Context ctx( ns() );
3747+ // ASSERT_EQUALS( BSON( "_id" << 1 ),
3748+ // cachedIndexForQuery( BSON( "q" << 1 << "_id" << 1 ) ) );
3749+ // shared_ptr<Cursor> c = getOptimizedCursor( ns(), BSON( "q" << 1 << "_id" << 1 ) );
3750+ // // Need query optimizer cursor since the cached plan is not optimal.
3751+ // ASSERT_EQUALS( "QueryOptimizerCursor", c->toString() );
3752+ // }
3753+ // };
3754+
37513755 class MultiIndex : public Base {
37523756 public:
37533757 MultiIndex () {
@@ -3903,28 +3907,30 @@ namespace QueryOptimizerCursorTests {
39033907 ASSERT_THROWS ( c->advance (), MsgAssertionException );
39043908 }
39053909 };
3906-
3907- class RecordedUnindexedPlan : public Base {
3908- public:
3909- RecordedUnindexedPlan () {
3910- _cli.ensureIndex ( ns (), BSON ( " a" << 1 ) );
3911- _cli.insert ( ns (), BSON ( " a" << BSON_ARRAY ( 1 << 2 << 3 ) << " b" << 1 ) );
3912- auto_ptr<DBClientCursor> cursor =
3913- _cli.query ( ns (), QUERY ( " a" << GT << 0 << " b" << 1 ).explain () );
3914- BSONObj explain = cursor->next ();
3915- ASSERT_EQUALS ( " BasicCursor" , explain[ " cursor" ].String () );
3916- }
3917- string expectedType () const { return " QueryOptimizerCursor" ; }
3918- BSONObj query () const { return BSON ( " a" << GT << 0 << " b" << 1 ); }
3919- void check ( const shared_ptr<Cursor> &c ) {
3920- ASSERT ( c->ok () );
3921- ASSERT_EQUALS ( BSON ( " a" << 1 ), c->indexKeyPattern () );
3922- while ( c->advance () ) {
3923- ASSERT_EQUALS ( BSON ( " a" << 1 ), c->indexKeyPattern () );
3924- }
3925- }
3926- };
3927-
3910+
3911+ // QUERY MIGRATION
3912+ // Cached is turned off
3913+ // class RecordedUnindexedPlan : public Base {
3914+ // public:
3915+ // RecordedUnindexedPlan() {
3916+ // _cli.ensureIndex( ns(), BSON( "a" << 1 ) );
3917+ // _cli.insert( ns(), BSON( "a" << BSON_ARRAY( 1 << 2 << 3 ) << "b" << 1 ) );
3918+ // auto_ptr<DBClientCursor> cursor =
3919+ // _cli.query( ns(), QUERY( "a" << GT << 0 << "b" << 1 ).explain() );
3920+ // BSONObj explain = cursor->next();
3921+ // ASSERT_EQUALS( "BasicCursor", explain[ "cursor" ].String() );
3922+ // }
3923+ // string expectedType() const { return "QueryOptimizerCursor"; }
3924+ // BSONObj query() const { return BSON( "a" << GT << 0 << "b" << 1 ); }
3925+ // void check( const shared_ptr<Cursor> &c ) {
3926+ // ASSERT( c->ok() );
3927+ // ASSERT_EQUALS( BSON( "a" << 1 ), c->indexKeyPattern() );
3928+ // while( c->advance() ) {
3929+ // ASSERT_EQUALS( BSON( "a" << 1 ), c->indexKeyPattern() );
3930+ // }
3931+ // }
3932+ // };
3933+
39283934 } // namespace RequireIndex
39293935
39303936 namespace IdElseNatural {
@@ -4942,8 +4948,8 @@ namespace QueryOptimizerCursorTests {
49424948 add<GetCursor::PreventOutOfOrderPlan>();
49434949 add<GetCursor::AllowOutOfOrderPlan>();
49444950 add<GetCursor::BestSavedOutOfOrder>();
4945- add<GetCursor::BestSavedOptimal>();
4946- add<GetCursor::BestSavedNotOptimal>();
4951+ // add<GetCursor::BestSavedOptimal>();
4952+ // add<GetCursor::BestSavedNotOptimal>();
49474953 add<GetCursor::MultiIndex>();
49484954 add<GetCursor::Hint>();
49494955 add<GetCursor::Snapshot>();
@@ -4957,7 +4963,7 @@ namespace QueryOptimizerCursorTests {
49574963 add<GetCursor::RequireIndex::SecondOrClauseIndexed>();
49584964 add<GetCursor::RequireIndex::SecondOrClauseUnindexed>();
49594965 add<GetCursor::RequireIndex::SecondOrClauseUnindexedUndetected>();
4960- add<GetCursor::RequireIndex::RecordedUnindexedPlan>();
4966+ // add<GetCursor::RequireIndex::RecordedUnindexedPlan>();
49614967 add<GetCursor::IdElseNatural::AllowOptimalNaturalPlan>();
49624968 add<GetCursor::IdElseNatural::AllowOptimalIdPlan>();
49634969 add<GetCursor::IdElseNatural::HintedIdForQuery>( BSON ( " _id" << 1 ) );
@@ -4999,4 +5005,3 @@ namespace QueryOptimizerCursorTests {
49995005 } myall;
50005006
50015007} // namespace QueryOptimizerTests
5002-
0 commit comments