diff options
Diffstat (limited to 'jstests/core/index_sort_within_multiple_point_ranges.js')
-rw-r--r-- | jstests/core/index_sort_within_multiple_point_ranges.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/jstests/core/index_sort_within_multiple_point_ranges.js b/jstests/core/index_sort_within_multiple_point_ranges.js new file mode 100644 index 00000000000..51861742ea4 --- /dev/null +++ b/jstests/core/index_sort_within_multiple_point_ranges.js @@ -0,0 +1,24 @@ +/* + * This is a regression test for SERVER-45508, which was an invariant failure in the query planner. + * + * Previously the invariant would be triggered only when all of these happen together: + * - an index with a collation exists + * - the query planner chooses index bounds with more than one point range + * - the point ranges are indexed in descending order + * - more than one index can satisfy the query + * - the query asks for a sort within each point range + * @tags: [assumes_no_implicit_collection_creation_after_drop] + */ +(function() { + 'use strict'; + + const coll = db.collation_multi_point_range; + coll.drop(); + assert.commandWorked(db.createCollection(coll.getName(), {collation: {locale: 'fr'}})); + assert.commandWorked(coll.createIndex({x: -1})); + assert.commandWorked(coll.createIndex({x: -1, y: 1})); + coll.insert({x: 2, y: 99}); + + assert.commandWorked(coll.find({x: {$in: [2, 5]}}).sort({y: 1}).explain()); + assert.eq(1, coll.find({x: {$in: [2, 5]}}).sort({y: 1}).itcount()); +})(); |