summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/query_planner_common.cpp
diff options
context:
space:
mode:
authorJudah Schvimer <judah@mongodb.com>2016-09-15 10:20:59 -0400
committerJudah Schvimer <judah@mongodb.com>2016-09-15 10:20:59 -0400
commit4dc41d135737dbda0a9ecc70af75687dd5df9099 (patch)
tree381dcdf024db4da65d20051a430a4f7515c122d6 /src/mongo/db/query/query_planner_common.cpp
parent97dd4a8eebfb2a2dc2e3a5e0907c8fc6e859c0ac (diff)
downloadmongo-4dc41d135737dbda0a9ecc70af75687dd5df9099.tar.gz
SERVER-26033 Allow simple range to exclude start key
Diffstat (limited to 'src/mongo/db/query/query_planner_common.cpp')
-rw-r--r--src/mongo/db/query/query_planner_common.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/mongo/db/query/query_planner_common.cpp b/src/mongo/db/query/query_planner_common.cpp
index 8f129e54e5b..33eb72100cc 100644
--- a/src/mongo/db/query/query_planner_common.cpp
+++ b/src/mongo/db/query/query_planner_common.cpp
@@ -45,9 +45,19 @@ void QueryPlannerCommon::reverseScans(QuerySolutionNode* node) {
if (isn->bounds.isSimpleRange) {
std::swap(isn->bounds.startKey, isn->bounds.endKey);
- // XXX: Not having a startKeyInclusive means that if we reverse a max/min query
- // we have different results with and without the reverse...
- isn->bounds.endKeyInclusive = true;
+ // If only one bound is included, swap which one is included.
+ switch (isn->bounds.boundInclusion) {
+ case BoundInclusion::kIncludeStartKeyOnly:
+ isn->bounds.boundInclusion = BoundInclusion::kIncludeEndKeyOnly;
+ break;
+ case BoundInclusion::kIncludeEndKeyOnly:
+ isn->bounds.boundInclusion = BoundInclusion::kIncludeStartKeyOnly;
+ break;
+ case BoundInclusion::kIncludeBothStartAndEndKeys:
+ case BoundInclusion::kExcludeBothStartAndEndKeys:
+ // These are both symmetric so no change needed.
+ break;
+ }
} else {
for (size_t i = 0; i < isn->bounds.fields.size(); ++i) {
std::vector<Interval>& iv = isn->bounds.fields[i].intervals;