mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-109 handle dynamically removed or clauses when iterating clauses
This commit is contained in:
parent
05c5af2b40
commit
5be4d78fba
@ -600,11 +600,9 @@ namespace mongo {
|
||||
if ( !_or ) {
|
||||
auto_ptr< FieldRangeSet > frs( new FieldRangeSet( ns, _query ) );
|
||||
_currentQps.reset( new QueryPlanSet( ns, frs, _query, order, hint, honorRecordedPlan, min, max ) );
|
||||
_n = 1; // only one run
|
||||
} else {
|
||||
BSONElement e = _query.getField( "$or" );
|
||||
massert( 13268, "invalid $or spec", e.type() == Array && e.embeddedObject().nFields() > 0 );
|
||||
_n = e.embeddedObject().nFields();
|
||||
}
|
||||
}
|
||||
|
||||
@ -614,11 +612,9 @@ namespace mongo {
|
||||
++_i;
|
||||
return _currentQps->runOp( op );
|
||||
}
|
||||
if ( _i != 0 ) {
|
||||
_fros.popOrClause();
|
||||
}
|
||||
++_i;
|
||||
auto_ptr< FieldRangeSet > frs( _fros.topFrs() );
|
||||
_fros.popOrClause();
|
||||
_currentQps.reset( new QueryPlanSet( _ns, frs, _query, BSONObj(), 0, _honorRecordedPlan ) );
|
||||
shared_ptr< QueryOp > ret( _currentQps->runOp( op ) );
|
||||
return ret;
|
||||
|
@ -263,7 +263,7 @@ namespace mongo {
|
||||
shared_ptr< T > runOpOnce( T &op ) {
|
||||
return dynamic_pointer_cast< T >( runOpOnce( static_cast< QueryOp& >( op ) ) );
|
||||
}
|
||||
bool mayRunMore() const { return _i < _n; }
|
||||
bool mayRunMore() const { return _or ? !_fros.orFinished() : _i == 0; }
|
||||
BSONObj oldExplain() const { assertNotOr(); return _currentQps->explain(); }
|
||||
// just report this when only one query op
|
||||
bool usingPrerecordedPlan() const {
|
||||
@ -281,7 +281,6 @@ namespace mongo {
|
||||
FieldRangeOrSet _fros;
|
||||
auto_ptr< QueryPlanSet > _currentQps;
|
||||
int _i;
|
||||
int _n;
|
||||
bool _honorRecordedPlan;
|
||||
bool _bestGuessOnly;
|
||||
};
|
||||
|
@ -6,4 +6,11 @@ t.ensureIndex( {a:1} );
|
||||
assert.eq.automsg( "2", "t.find( {$or:[{a:{$gt:2}},{a:{$gt:0}}]} ).explain().clauses[ 1 ].indexBounds[ 0 ][ 1 ].a" );
|
||||
assert.eq.automsg( "2", "t.find( {$or:[{a:{$lt:2}},{a:{$lt:4}}]} ).explain().clauses[ 1 ].indexBounds[ 0 ][ 0 ].a" );
|
||||
|
||||
printjson( t.find( {$or:[{a:{$lt:2}},{a:{$lt:4}}]} ).explain() );
|
||||
assert.eq.automsg( "2", "t.find( {$or:[{a:{$gt:2,$lt:10}},{a:{$gt:0,$lt:5}}]} ).explain().clauses[ 1 ].indexBounds[ 0 ][ 1 ].a" );
|
||||
assert.eq.automsg( "0", "t.find( {$or:[{a:{$gt:2,$lt:10}},{a:{$gt:0,$lt:15}}]} ).explain().clauses[ 1 ].indexBounds[ 0 ][ 0 ].a" );
|
||||
assert.eq.automsg( "15", "t.find( {$or:[{a:{$gt:2,$lt:10}},{a:{$gt:0,$lt:15}}]} ).explain().clauses[ 1 ].indexBounds[ 0 ][ 1 ].a" );
|
||||
|
||||
// no separate clauses
|
||||
assert.eq.automsg( "null", "t.find( {$or:[{a:{$gt:2,$lt:10}},{a:{$gt:3,$lt:5}}]} ).explain().clauses" );
|
||||
|
||||
assert.eq.automsg( "20", "t.find( {$or:[{a:{$gt:2,$lt:10}},{a:{$gt:3,$lt:5}},{a:{$gt:20}}]} ).explain().clauses[ 1 ].indexBounds[ 0 ][ 0 ].a" );
|
Loading…
Reference in New Issue
Block a user