summaryrefslogtreecommitdiff
path: root/src/mongo/db/ops
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2016-02-12 11:03:58 -0500
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2016-02-12 11:03:58 -0500
commit4f1cc51f3e21e4ff76c68e86ecae4e5d138de0aa (patch)
treeed0d7c3dc2d60437d7997c277dfa4912ffa107ff /src/mongo/db/ops
parentdb403d46d2ed98a3600410d90ef3deee8901bed6 (diff)
downloadmongo-4f1cc51f3e21e4ff76c68e86ecae4e5d138de0aa.tar.gz
SERVER-22569 Change findParentEqualityElement() to return by value.
MSVC 2013 doesn't support thread-safe initialization of function-local static-duration objects, so it's possible to return a reference to 'eooElement' prior to the value being fully initialized.
Diffstat (limited to 'src/mongo/db/ops')
-rw-r--r--src/mongo/db/ops/path_support.cpp11
-rw-r--r--src/mongo/db/ops/path_support.h6
2 files changed, 8 insertions, 9 deletions
diff --git a/src/mongo/db/ops/path_support.cpp b/src/mongo/db/ops/path_support.cpp
index 894b0117393..0523ef6acbb 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 6e01c03390e..6fbd95ec0a9 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