summaryrefslogtreecommitdiff
path: root/src/mongo/db/update
diff options
context:
space:
mode:
authorLuxi Liu <luxi.liu@mongodb.com>2022-06-30 15:00:38 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-06-30 16:00:04 +0000
commit55ac53e928a22867e8ad1b544765695c4c6bcf9d (patch)
treedc5df2ff5e355d8712b26391939a79dd9b933c6e /src/mongo/db/update
parent94c23b6b7974dc9bb6515cb1c279c42b7f055da3 (diff)
downloadmongo-55ac53e928a22867e8ad1b544765695c4c6bcf9d.tar.gz
SERVER-66923 Removed kFullyDowngradedTo_5_0 constants in the codebase
Diffstat (limited to 'src/mongo/db/update')
-rw-r--r--src/mongo/db/update/pipeline_executor.cpp11
-rw-r--r--src/mongo/db/update/storage_validation.cpp27
2 files changed, 12 insertions, 26 deletions
diff --git a/src/mongo/db/update/pipeline_executor.cpp b/src/mongo/db/update/pipeline_executor.cpp
index 710803d6b04..acbe69b133f 100644
--- a/src/mongo/db/update/pipeline_executor.cpp
+++ b/src/mongo/db/update/pipeline_executor.cpp
@@ -103,12 +103,11 @@ UpdateExecutor::ApplyResult PipelineExecutor::applyUpdate(ApplyParams applyParam
// Replace the pre-image document in applyParams with the post image we got from running the
// post image.
- bool allowTopLevelDollarPrefixedFields =
- serverGlobalParams.featureCompatibility.isVersionInitialized() &&
- serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0);
- auto ret = ObjectReplaceExecutor::applyReplacementUpdate(
- applyParams, transformedDoc, transformedDocHasIdField, allowTopLevelDollarPrefixedFields);
+ auto ret =
+ ObjectReplaceExecutor::applyReplacementUpdate(applyParams,
+ transformedDoc,
+ transformedDocHasIdField,
+ true /* allowTopLevelDollarPrefixedFields */);
// The oplog entry should not have been populated yet.
invariant(ret.oplogEntry.isEmpty());
diff --git a/src/mongo/db/update/storage_validation.cpp b/src/mongo/db/update/storage_validation.cpp
index d94c645a588..0feb5877ef5 100644
--- a/src/mongo/db/update/storage_validation.cpp
+++ b/src/mongo/db/update/storage_validation.cpp
@@ -112,17 +112,12 @@ void validateDollarPrefixElement(mutablebson::ConstElement elem) {
curr.rightSibling().ok() && curr.rightSibling().getFieldName() == "$id");
} else {
// Not an okay, $ prefixed field name.
- const auto replaceWithHint =
- serverGlobalParams.featureCompatibility.isVersionInitialized() &&
- serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0)
- ? "' is not allowed in the context of an update's replacement document. Consider using "
- "an aggregation pipeline with $replaceWith."
- : "' is not valid for storage.";
-
uasserted(ErrorCodes::DollarPrefixedFieldName,
str::stream() << "The dollar ($) prefixed field '" << elem.getFieldName()
- << "' in '" << mutablebson::getFullName(elem) << replaceWithHint);
+ << "' in '" << mutablebson::getFullName(elem)
+ << "' is not allowed in the context of an update's replacement"
+ " document. Consider using an aggregation pipeline with"
+ " $replaceWith.");
}
}
} // namespace
@@ -137,10 +132,7 @@ Status storageValidIdField(const mongo::BSONElement& element) {
<< "The '_id' value cannot be of type " << typeName(element.type()));
case BSONType::Object: {
auto status = element.Obj().storageValidEmbedded();
- if (!status.isOK() && status.code() == ErrorCodes::DollarPrefixedFieldName &&
- serverGlobalParams.featureCompatibility.isVersionInitialized() &&
- serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0)) {
+ if (!status.isOK() && status.code() == ErrorCodes::DollarPrefixedFieldName) {
return Status(status.code(),
str::stream() << "_id fields may not contain '$'-prefixed fields: "
<< status.reason());
@@ -200,21 +192,16 @@ void scanDocument(mutablebson::ConstElement elem,
// Only check top-level fields if 'allowTopLevelDollarPrefixes' is false, and don't validate any
// fields for '$'-prefixes if 'allowTopLevelDollarPrefixes' is true.
const bool checkTopLevelFields = !allowTopLevelDollarPrefixes && (recursionLevel == 1);
- const bool dotsAndDollarsFeatureEnabled =
- serverGlobalParams.featureCompatibility.isVersionInitialized() &&
- serverGlobalParams.featureCompatibility.isGreaterThanOrEqualTo(
- multiversion::FeatureCompatibilityVersion::kFullyDowngradedTo_5_0);
- const bool checkFields = !dotsAndDollarsFeatureEnabled || checkTopLevelFields;
auto fieldName = elem.getFieldName();
if (fieldName[0] == '$') {
- if (dotsAndDollarsFeatureEnabled && containsDotsAndDollarsField) {
+ if (containsDotsAndDollarsField) {
*containsDotsAndDollarsField = true;
// If we are not validating for storage, return once a $-prefixed field is found.
if (!shouldValidate)
return;
}
- if (!childOfArray && checkFields && shouldValidate) {
+ if (!childOfArray && checkTopLevelFields && shouldValidate) {
// Cannot start with "$", unless dbref.
validateDollarPrefixElement(elem);
}