summaryrefslogtreecommitdiff
path: root/jstests/core/index/index_sort_within_multiple_point_ranges.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/index/index_sort_within_multiple_point_ranges.js')
-rw-r--r--jstests/core/index/index_sort_within_multiple_point_ranges.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/jstests/core/index/index_sort_within_multiple_point_ranges.js b/jstests/core/index/index_sort_within_multiple_point_ranges.js
new file mode 100644
index 00000000000..6caaad1cb6f
--- /dev/null
+++ b/jstests/core/index/index_sort_within_multiple_point_ranges.js
@@ -0,0 +1,26 @@
+/**
+ * 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());
+})();