summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2012-02-09 21:01:20 -0800
committerAaron <aaron@10gen.com>2012-02-12 16:46:50 -0800
commitba1ac9effdd92b5e5ac4ed8b0163fcca886d096c (patch)
treed9a3a4f69d0cf6b48102f0e3708ba6c958c91283 /src/mongo
parent7def59b99e68b9b3e7d8e3293d7ac35fa37209b1 (diff)
downloadmongo-ba1ac9effdd92b5e5ac4ed8b0163fcca886d096c.tar.gz
query optimizer cursor add check that a recorded unindexed cursor will trigger plan reevaluation in requireIndex mode
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/dbtests/queryoptimizercursortests.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/mongo/dbtests/queryoptimizercursortests.cpp b/src/mongo/dbtests/queryoptimizercursortests.cpp
index ec68340e12e..c7e98207fff 100644
--- a/src/mongo/dbtests/queryoptimizercursortests.cpp
+++ b/src/mongo/dbtests/queryoptimizercursortests.cpp
@@ -2470,6 +2470,26 @@ namespace QueryOptimizerCursorTests {
}
};
+ class RequireIndexRecordedUnindexedPlan : public Base {
+ public:
+ RequireIndexRecordedUnindexedPlan() {
+ _cli.ensureIndex( ns(), BSON( "a" << 1 ) );
+ _cli.insert( ns(), BSON( "a" << BSON_ARRAY( 1 << 2 << 3 ) << "b" << 1 ) );
+ BSONObj explain = _cli.findOne( ns(), QUERY( "a" << GT << 0 << "b" << 1 ).explain() );
+ ASSERT_EQUALS( "BasicCursor", explain[ "cursor" ].String() );
+ }
+ bool requireIndex() const { return true; }
+ string expectedType() const { return "QueryOptimizerCursor"; }
+ BSONObj query() const { return BSON( "a" << GT << 0 << "b" << 1 ); }
+ void check( const shared_ptr<Cursor> &c ) {
+ ASSERT( c->ok() );
+ ASSERT_EQUALS( BSON( "a" << 1 ), c->indexKeyPattern() );
+ while( c->advance() ) {
+ ASSERT_EQUALS( BSON( "a" << 1 ), c->indexKeyPattern() );
+ }
+ }
+ };
+
} // namespace GetCursor
class All : public Suite {
@@ -2575,6 +2595,7 @@ namespace QueryOptimizerCursorTests {
add<QueryOptimizerCursorTests::GetCursor::RequireIndexSecondOrClauseIndexed>();
add<QueryOptimizerCursorTests::GetCursor::RequireIndexSecondOrClauseUnindexed>();
add<QueryOptimizerCursorTests::GetCursor::RequireIndexSecondOrClauseUnindexedUndetected>();
+ add<QueryOptimizerCursorTests::GetCursor::RequireIndexRecordedUnindexedPlan>();
}
} myall;