summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/ops/path_support.cpp11
-rw-r--r--src/mongo/db/ops/path_support.h6
-rw-r--r--src/mongo/s/shard_key_pattern.cpp2
3 files changed, 9 insertions, 10 deletions
diff --git a/src/mongo/db/ops/path_support.cpp b/src/mongo/db/ops/path_support.cpp
index d1e8fa7fcde..0b79a872053 100644
--- a/src/mongo/db/ops/path_support.cpp
+++ b/src/mongo/db/ops/path_support.cpp
@@ -287,9 +287,9 @@ Status setElementAtPath(const FieldRef& path,
}
}
-const BSONElement& findParentEqualityElement(const EqualityMatches& equalities,
- const FieldRef& path,
- int* parentPathParts) {
+BSONElement findParentEqualityElement(const EqualityMatches& equalities,
+ const FieldRef& path,
+ int* parentPathParts) {
// We may have an equality match to an object at a higher point in the pattern path, check
// all path prefixes for equality matches
// ex: path: 'a.b', query : { 'a' : { b : <value> } }
@@ -309,8 +309,7 @@ const BSONElement& findParentEqualityElement(const EqualityMatches& equalities,
}
*parentPathParts = -1;
- static const BSONElement eooElement;
- return eooElement;
+ return BSONElement();
}
/**
@@ -318,7 +317,7 @@ const BSONElement& findParentEqualityElement(const EqualityMatches& equalities,
*/
static Status checkEqualityConflicts(const EqualityMatches& equalities, const FieldRef& path) {
int parentPathPart = -1;
- const BSONElement& parentEl = findParentEqualityElement(equalities, path, &parentPathPart);
+ const BSONElement parentEl = findParentEqualityElement(equalities, path, &parentPathPart);
if (parentEl.eoo())
return Status::OK();
diff --git a/src/mongo/db/ops/path_support.h b/src/mongo/db/ops/path_support.h
index 95d0a3da44c..cebda16aa76 100644
--- a/src/mongo/db/ops/path_support.h
+++ b/src/mongo/db/ops/path_support.h
@@ -170,9 +170,9 @@ Status extractFullEqualityMatches(const MatchExpression& root,
* Path 'a.b.c' has an eqmatch parent of 'a.b' : 1
*
*/
-const BSONElement& findParentEqualityElement(const EqualityMatches& equalities,
- const FieldRef& path,
- int* parentPathParts);
+BSONElement findParentEqualityElement(const EqualityMatches& equalities,
+ const FieldRef& path,
+ int* parentPathParts);
/**
* Adds the BSON values from equality matches into the given document at the equality match
diff --git a/src/mongo/s/shard_key_pattern.cpp b/src/mongo/s/shard_key_pattern.cpp
index 8fca176754c..2071bde5d70 100644
--- a/src/mongo/s/shard_key_pattern.cpp
+++ b/src/mongo/s/shard_key_pattern.cpp
@@ -249,7 +249,7 @@ BSONObj ShardKeyPattern::extractShardKeyFromDoc(const BSONObj& doc) const {
static BSONElement findEqualityElement(const EqualityMatches& equalities, const FieldRef& path) {
int parentPathPart;
- const BSONElement& parentEl =
+ const BSONElement parentEl =
pathsupport::findParentEqualityElement(equalities, path, &parentPathPart);
if (parentPathPart == static_cast<int>(path.numParts()))