diff options
author | David Storch <david.storch@10gen.com> | 2014-04-11 12:24:37 -0400 |
---|---|---|
committer | Matt Kangas <matt.kangas@mongodb.com> | 2014-04-14 13:40:51 -0400 |
commit | 9f1ef97401471aaeb430cb5c4ad9c06ffe7e60c6 (patch) | |
tree | f6c0366fdf009f6b44b32237ceba9c6a3a6be014 /jstests | |
parent | 279163e3802cf5b538b22eac9302419f0f7bb6f8 (diff) | |
download | mongo-9f1ef97401471aaeb430cb5c4ad9c06ffe7e60c6.tar.gz |
SERVER-13537 better handle numerical overflow of large limit values
(cherry picked from commit 3e4b9474749fc3b4df182d813e09a26b0e02fcc6)
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/core/skip1.js | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/jstests/core/skip1.js b/jstests/core/skip1.js index c620fb01bca..c1895e8889a 100644 --- a/jstests/core/skip1.js +++ b/jstests/core/skip1.js @@ -1,8 +1,9 @@ // SERVER-2845 When skipping objects without loading them, they shouldn't be // included in the nscannedObjects count. +var t = db.jstests_skip1; + if ( 0 ) { // SERVER-2845 -t = db.jstests_skip1; t.drop(); t.ensureIndex( {a:1} ); @@ -12,4 +13,19 @@ t.save( {a:5} ); assert.eq( 3, t.find( {a:5} ).skip( 2 ).explain().nscanned ); assert.eq( 1, t.find( {a:5} ).skip( 2 ).explain().nscannedObjects ); -}
\ No newline at end of file +} + +// SERVER-13537: Ensure that combinations of skip and limit don't crash +// the server due to overflow. +t.drop(); +for (var i = 0; i < 10; i++) { + t.save({a: i}); +} +assert.eq( 9, t.find().sort({a: 1}).limit(2147483647).skip(1).itcount() ); +assert.eq( 0, t.find().sort({a: 1}).skip(2147483647).limit(1).itcount() ); +assert.throws( function() { + assert.eq( 0, t.find().sort({a: 1}).skip(2147483648).itcount() ); +}); +assert.throws( function() { + assert.eq( 0, t.find().sort({a: 1}).limit(2147483648).itcount() ); +}); |