summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/planner_access.cpp
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2014-05-30 16:59:32 -0400
committerDavid Storch <david.storch@10gen.com>2014-05-30 16:59:32 -0400
commit3242afb803a5cc523f16c2c63c3ee1dfc10a5671 (patch)
tree5dec03fa889193ff12d862e894c10b9f0f2614ed /src/mongo/db/query/planner_access.cpp
parent1440087f1b43df9f46468ee259016d3e99d728af (diff)
downloadmongo-3242afb803a5cc523f16c2c63c3ee1dfc10a5671.tar.gz
SERVER-13960 bug fixes for OR with inexact predicates
Diffstat (limited to 'src/mongo/db/query/planner_access.cpp')
-rw-r--r--src/mongo/db/query/planner_access.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/mongo/db/query/planner_access.cpp b/src/mongo/db/query/planner_access.cpp
index 3c2d1efdffe..ba8ed3644f7 100644
--- a/src/mongo/db/query/planner_access.cpp
+++ b/src/mongo/db/query/planner_access.cpp
@@ -422,16 +422,31 @@ namespace mongo {
}
// static
+ bool QueryPlannerAccess::orNeedsFetch(const ScanBuildingState* scanState) {
+ if (scanState->loosestBounds == IndexBoundsBuilder::EXACT) {
+ return false;
+ }
+ else if (scanState->loosestBounds == IndexBoundsBuilder::INEXACT_FETCH) {
+ return true;
+ }
+ else {
+ invariant(scanState->loosestBounds == IndexBoundsBuilder::INEXACT_COVERED);
+ const IndexEntry& index = scanState->indices[scanState->currentIndexNumber];
+ return index.multikey;
+ }
+ }
+
+ // static
void QueryPlannerAccess::finishAndOutputLeaf(ScanBuildingState* scanState,
vector<QuerySolutionNode*>* out) {
finishLeafNode(scanState->currentScan.get(),
scanState->indices[scanState->currentIndexNumber]);
if (MatchExpression::OR == scanState->root->matchType()) {
- if (scanState->loosestBounds == IndexBoundsBuilder::INEXACT_FETCH) {
- // This is an $or where at least one predicate has inexact bounds. In this
- // case we must add a fetch node above the index scan whose filter includes
- // *all* of the predicates used to generate the ixscan.
+ if (orNeedsFetch(scanState)) {
+ // In order to correctly evaluate the predicates for this index, we have to
+ // fetch the full documents. Add a fetch node above the index scan whose filter
+ // includes *all* of the predicates used to generate the ixscan.
FetchNode* fetch = new FetchNode();
// Takes ownership.
fetch->filter.reset(scanState->curOr.release());