diff options
author | Tess Avitabile <tess.avitabile@mongodb.com> | 2017-06-27 13:06:18 -0400 |
---|---|---|
committer | Tess Avitabile <tess.avitabile@mongodb.com> | 2017-06-30 17:10:38 -0400 |
commit | 07baac065147381842a172726a5f80d7e57a6ef8 (patch) | |
tree | f358a00798025d4b848ddb5231ccd2974e3db501 /src/mongo/db/update/pop_node.cpp | |
parent | acc6b704793fc37d5439b32b64a186a500436a36 (diff) | |
download | mongo-07baac065147381842a172726a5f80d7e57a6ef8.tar.gz |
SERVER-29162 UpdateNode implementation should only validate modified fields
Diffstat (limited to 'src/mongo/db/update/pop_node.cpp')
-rw-r--r-- | src/mongo/db/update/pop_node.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mongo/db/update/pop_node.cpp b/src/mongo/db/update/pop_node.cpp index c0a81132118..38a36157382 100644 --- a/src/mongo/db/update/pop_node.cpp +++ b/src/mongo/db/update/pop_node.cpp @@ -44,6 +44,8 @@ void PopNode::apply(mutablebson::Element element, FieldRef* pathTaken, StringData matchedField, bool fromReplication, + bool validateForStorage, + const FieldRefSet& immutablePaths, const UpdateIndexData* indexData, LogBuilder* logBuilder, bool* indexesAffected, @@ -113,6 +115,21 @@ void PopNode::apply(mutablebson::Element element, auto elementToRemove = _popFromFront ? element.leftChild() : element.rightChild(); invariantOK(elementToRemove.remove()); + // No need to validate for storage, since we cannot have increased the BSON depth or interfered + // with a DBRef. + + // Ensure we are not changing any immutable paths. + for (auto immutablePath = immutablePaths.begin(); immutablePath != immutablePaths.end(); + ++immutablePath) { + uassert(ErrorCodes::ImmutableField, + str::stream() << "Performing a $pop on the path '" << pathTaken->dottedField() + << "' would modify the immutable field '" + << (*immutablePath)->dottedField() + << "'", + pathTaken->commonPrefixSize(**immutablePath) < + std::min(pathTaken->numParts(), (*immutablePath)->numParts())); + } + if (logBuilder) { uassertStatusOK(logBuilder->addToSetsWithNewFieldName(pathTaken->dottedField(), element)); } |