summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2014-05-07 14:22:05 -0400
committerDan Pasette <dan@mongodb.com>2014-05-15 19:31:40 -0400
commitbf471cd8e2aaf70e7950ea179b9c22822b6ddc2c (patch)
tree0f8f81bf70151454648c33ce793af76b8da575cf
parent652d7a4c95719ccf619dba4a5b57ef21626df2a4 (diff)
downloadmongo-bf471cd8e2aaf70e7950ea179b9c22822b6ddc2c.tar.gz
SERVER-13715 fix use of auto_ptr after release in subplan runner
(cherry picked from commit 193aba81f1c9c9c0c0a7e9ba857e7538dc6b6ed0)
-rw-r--r--jstests/core/orq.js22
-rw-r--r--src/mongo/db/query/subplan_runner.cpp18
2 files changed, 31 insertions, 9 deletions
diff --git a/jstests/core/orq.js b/jstests/core/orq.js
new file mode 100644
index 00000000000..2a8263e298f
--- /dev/null
+++ b/jstests/core/orq.js
@@ -0,0 +1,22 @@
+// A few rooted $or cases.
+
+var t = db.jstests_orq;
+t.drop();
+
+t.ensureIndex({a: 1, c: 1});
+t.ensureIndex({b: 1, c: 1});
+
+t.save({a: 1, c: 9});
+t.save({a: 1, c: 10});
+t.save({b: 2, c: 8});
+t.save({b: 2, c: 7});
+
+// This can be answered using a merge sort. See SERVER-13715.
+var cursor = t.find({$or: [{a: 1}, {b: 2}]}).sort({c: 1});
+for (var i = 7; i < 11; i++) {
+ assert.eq(i, cursor.next()["c"]);
+}
+assert(!cursor.hasNext());
+
+// SERVER-13715
+assert.eq(4, t.find({$or: [{a: 1}, {b: 2}]}).sort({a: 1}).itcount());
diff --git a/src/mongo/db/query/subplan_runner.cpp b/src/mongo/db/query/subplan_runner.cpp
index 9a901314ef1..48e00165085 100644
--- a/src/mongo/db/query/subplan_runner.cpp
+++ b/src/mongo/db/query/subplan_runner.cpp
@@ -277,13 +277,13 @@ namespace mongo {
// We want a well-formed *indexed* solution.
if (NULL == autoSoln->cacheData.get()) {
// For example, we don't cache things for 2d indices.
- QLOG() << "Subplanner: No cache data for subchild " << orChildCQ->toString();
+ QLOG() << "Subplanner: No cache data for subchild " << orChild->toString();
return false;
}
if (SolutionCacheData::USE_INDEX_TAGS_SOLN != autoSoln->cacheData->solnType) {
QLOG() << "Subplanner: No indexed cache data for subchild "
- << orChildCQ->toString();
+ << orChild->toString();
return false;
}
@@ -292,8 +292,8 @@ namespace mongo {
orChild, autoSoln->cacheData->tree.get(), _indexMap);
if (!tagStatus.isOK()) {
- QLOG() << "Subplanner: Failed to extract indices from subchild"
- << orChildCQ->toString();
+ QLOG() << "Subplanner: Failed to extract indices from subchild "
+ << orChild->toString();
return false;
}
@@ -326,7 +326,7 @@ namespace mongo {
BSONObj errorObj;
if (!mpr->pickBestPlan(&bestPlan, &errorObj)) {
QLOG() << "Subplanner: Failed to pick best plan for subchild "
- << orChildCQ->toString()
+ << orChild->toString()
<< " error obj is " << errorObj.toString();
return false;
}
@@ -334,7 +334,7 @@ namespace mongo {
// pickBestPlan can yield. Make sure we're not dead any which way.
if (_killed) {
QLOG() << "Subplanner: Killed while picking best plan for subchild "
- << orChildCQ->toString();
+ << orChild->toString();
return false;
}
@@ -342,7 +342,7 @@ namespace mongo {
if (SolutionCacheData::USE_INDEX_TAGS_SOLN != bestSoln->cacheData->solnType) {
QLOG() << "Subplanner: No indexed cache data for subchild "
- << orChildCQ->toString();
+ << orChild->toString();
return false;
}
@@ -351,8 +351,8 @@ namespace mongo {
orChild, bestSoln->cacheData->tree.get(), _indexMap);
if (!tagStatus.isOK()) {
- QLOG() << "Subplanner: Failed to extract indices from subchild"
- << orChildCQ->toString();
+ QLOG() << "Subplanner: Failed to extract indices from subchild "
+ << orChild->toString();
return false;
}