Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fix limit with $with SERVER-777

  • Loading branch information...
commit df2dd73fdb3b945e691d5dec50a08fdce4abd34c 1 parent 89c4484
Eliot erh authored

Showing 3 changed files with 11 additions and 3 deletions. Show diff stats Hide diff stats

  1. +1 1  db/query.cpp
  2. +6 0 db/query.h
  3. +4 2 jstests/geo_box1.js
2  db/query.cpp
@@ -547,7 +547,7 @@ namespace mongo {
547 547 }
548 548 _n++;
549 549 if ( ! _c->supportGetMore() ){
550   - if ( _buf.len() >= MaxBytesToReturnToClientAtOnce ){
  550 + if ( _pq.enough( _n ) || _buf.len() >= MaxBytesToReturnToClientAtOnce ){
551 551 finish();
552 552 return;
553 553 }
6 db/query.h
@@ -199,6 +199,12 @@ namespace mongo {
199 199 return ( len > 1024 * 1024 ) || n >= 101;
200 200 return n >= _ntoreturn || len > MaxBytesToReturnToClientAtOnce;
201 201 }
  202 +
  203 + bool enough( int n ) const {
  204 + if ( _ntoreturn == 0 )
  205 + return false;
  206 + return n >= _ntoreturn;
  207 + }
202 208
203 209 private:
204 210 void init( const BSONObj& q ){
6 jstests/geo_box1.js
@@ -36,6 +36,8 @@ assert.eq( 0 , t.find( { loc : { $within : { $box : [ [100 , 100 ] , [ 110 , 110
36 36 assert.eq( 0 , t.find( { loc : { $within : { $box : [ [100 , 100 ] , [ 110 , 110 ] ] } } } ).count() , "E2" )
37 37
38 38
39   -assert.eq( num , t.find( { loc : { $within : { $box : [ [ 0 , 0 ] , [ 110 , 110 ] ] } } } ).count() , "E2" )
40   -assert.eq( num , t.find( { loc : { $within : { $box : [ [ 0 , 0 ] , [ 110 , 110 ] ] } } } ).itcount() , "E2" )
  39 +assert.eq( num , t.find( { loc : { $within : { $box : [ [ 0 , 0 ] , [ 110 , 110 ] ] } } } ).count() , "E3" )
  40 +assert.eq( num , t.find( { loc : { $within : { $box : [ [ 0 , 0 ] , [ 110 , 110 ] ] } } } ).itcount() , "E4" )
  41 +
  42 +assert.eq( 57 , t.find( { loc : { $within : { $box : [ [ 0 , 0 ] , [ 110 , 110 ] ] } } } ).limit(57).itcount() , "E5" )
41 43

0 comments on commit df2dd73

Please sign in to comment.
Something went wrong with that request. Please try again.