summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/catalog')
-rw-r--r--src/mongo/db/catalog/coll_mod.cpp2
-rw-r--r--src/mongo/db/catalog/collection.h7
-rw-r--r--src/mongo/db/catalog/collection_impl.cpp13
-rw-r--r--src/mongo/db/catalog/collection_impl.h1
-rw-r--r--src/mongo/db/catalog/collection_mock.h4
-rw-r--r--src/mongo/db/catalog/database_impl.cpp5
-rw-r--r--src/mongo/db/catalog/index_catalog_entry_impl.cpp4
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.cpp4
8 files changed, 28 insertions, 12 deletions
diff --git a/src/mongo/db/catalog/coll_mod.cpp b/src/mongo/db/catalog/coll_mod.cpp
index 59e8623ac7a..1a24d9a8caa 100644
--- a/src/mongo/db/catalog/coll_mod.cpp
+++ b/src/mongo/db/catalog/coll_mod.cpp
@@ -180,7 +180,7 @@ StatusWith<CollModRequest> parseCollModRequest(OperationContext* opCtx,
// instances, as indicated by !validateFeaturesAsMaster.
allowedFeatures |= MatchExpressionParser::kJSONSchema;
}
- auto statusW = coll->parseValidator(e.Obj(), allowedFeatures);
+ auto statusW = coll->parseValidator(opCtx, e.Obj(), allowedFeatures);
if (!statusW.isOK()) {
if (statusW.getStatus().code() == ErrorCodes::JSONSchemaNotAllowed) {
// The default error message for disallowed $jsonSchema is not descriptive
diff --git a/src/mongo/db/catalog/collection.h b/src/mongo/db/catalog/collection.h
index fd0f9b3b1b4..5d30401e2b6 100644
--- a/src/mongo/db/catalog/collection.h
+++ b/src/mongo/db/catalog/collection.h
@@ -302,6 +302,7 @@ public:
virtual void cappedTruncateAfter(OperationContext* opCtx, RecordId end, bool inclusive) = 0;
virtual StatusWithMatchExpression parseValidator(
+ OperationContext* opCtx,
const BSONObj& validator,
MatchExpressionParser::AllowedFeatureSet allowedFeatures) const = 0;
@@ -627,8 +628,10 @@ public:
* Returns a non-ok Status if validator is not legal for this collection.
*/
inline StatusWithMatchExpression parseValidator(
- const BSONObj& validator, MatchExpressionParser::AllowedFeatureSet allowedFeatures) const {
- return this->_impl().parseValidator(validator, allowedFeatures);
+ OperationContext* opCtx,
+ const BSONObj& validator,
+ MatchExpressionParser::AllowedFeatureSet allowedFeatures) const {
+ return this->_impl().parseValidator(opCtx, validator, allowedFeatures);
}
static StatusWith<ValidationLevel> parseValidationLevel(StringData);
diff --git a/src/mongo/db/catalog/collection_impl.cpp b/src/mongo/db/catalog/collection_impl.cpp
index 26af94b10ff..f41d9d2a467 100644
--- a/src/mongo/db/catalog/collection_impl.cpp
+++ b/src/mongo/db/catalog/collection_impl.cpp
@@ -160,7 +160,8 @@ CollectionImpl::CollectionImpl(Collection* _this_init,
_collator(parseCollation(opCtx, _ns, _details->getCollectionOptions(opCtx).collation)),
_validatorDoc(_details->getCollectionOptions(opCtx).validator.getOwned()),
_validator(
- uassertStatusOK(parseValidator(_validatorDoc,
+ uassertStatusOK(parseValidator(opCtx,
+ _validatorDoc,
MatchExpressionParser::kAllowAllSpecialFeatures &
~MatchExpressionParser::AllowedFeatures::kExpr))),
_validationAction(uassertStatusOK(
@@ -268,7 +269,9 @@ Status CollectionImpl::checkValidation(OperationContext* opCtx, const BSONObj& d
}
StatusWithMatchExpression CollectionImpl::parseValidator(
- const BSONObj& validator, MatchExpressionParser::AllowedFeatureSet allowedFeatures) const {
+ OperationContext* opCtx,
+ const BSONObj& validator,
+ MatchExpressionParser::AllowedFeatureSet allowedFeatures) const {
if (validator.isEmpty())
return {nullptr};
@@ -285,8 +288,9 @@ StatusWithMatchExpression CollectionImpl::parseValidator(
<< " database"};
}
+ boost::intrusive_ptr<ExpressionContext> expCtx(new ExpressionContext(opCtx, _collator.get()));
auto statusWithMatcher = MatchExpressionParser::parse(
- validator, _collator.get(), nullptr, ExtensionsCallbackNoop(), allowedFeatures);
+ validator, std::move(expCtx), ExtensionsCallbackNoop(), allowedFeatures);
if (!statusWithMatcher.isOK())
return statusWithMatcher.getStatus();
@@ -894,7 +898,8 @@ Status CollectionImpl::setValidator(OperationContext* opCtx, BSONObj validatorDo
// Note that, by the time we reach this, we should have already done a pre-parse that checks for
// banned features, so we don't need to include that check again.
- auto statusWithMatcher = parseValidator(validatorDoc,
+ auto statusWithMatcher = parseValidator(opCtx,
+ validatorDoc,
MatchExpressionParser::kAllowAllSpecialFeatures &
~MatchExpressionParser::AllowedFeatures::kExpr);
if (!statusWithMatcher.isOK())
diff --git a/src/mongo/db/catalog/collection_impl.h b/src/mongo/db/catalog/collection_impl.h
index f8db017330e..cba3445042e 100644
--- a/src/mongo/db/catalog/collection_impl.h
+++ b/src/mongo/db/catalog/collection_impl.h
@@ -284,6 +284,7 @@ public:
* Returns a non-ok Status if validator is not legal for this collection.
*/
StatusWithMatchExpression parseValidator(
+ OperationContext* opCtx,
const BSONObj& validator,
MatchExpressionParser::AllowedFeatureSet allowedFeatures) const final;
diff --git a/src/mongo/db/catalog/collection_mock.h b/src/mongo/db/catalog/collection_mock.h
index e9ecffc144b..405a3fde968 100644
--- a/src/mongo/db/catalog/collection_mock.h
+++ b/src/mongo/db/catalog/collection_mock.h
@@ -221,7 +221,9 @@ public:
}
StatusWithMatchExpression parseValidator(
- const BSONObj& validator, MatchExpressionParser::AllowedFeatureSet allowedFeatures) const {
+ OperationContext* opCtx,
+ const BSONObj& validator,
+ MatchExpressionParser::AllowedFeatureSet allowedFeatures) const {
std::abort();
}
diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp
index 5f6f7d61748..ad186e8f06b 100644
--- a/src/mongo/db/catalog/database_impl.cpp
+++ b/src/mongo/db/catalog/database_impl.cpp
@@ -1013,9 +1013,10 @@ auto mongo::userCreateNSImpl(OperationContext* opCtx,
// the secondary or on a backup instance, as indicated by !validateFeaturesAsMaster.
allowedFeatures |= MatchExpressionParser::kJSONSchema;
}
+ boost::intrusive_ptr<ExpressionContext> expCtx(
+ new ExpressionContext(opCtx, collator.get()));
auto statusWithMatcher = MatchExpressionParser::parse(collectionOptions.validator,
- collator.get(),
- nullptr,
+ std::move(expCtx),
ExtensionsCallbackNoop(),
allowedFeatures);
diff --git a/src/mongo/db/catalog/index_catalog_entry_impl.cpp b/src/mongo/db/catalog/index_catalog_entry_impl.cpp
index 7f46d56dac8..afa073f7ce0 100644
--- a/src/mongo/db/catalog/index_catalog_entry_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_entry_impl.cpp
@@ -127,8 +127,10 @@ IndexCatalogEntryImpl::IndexCatalogEntryImpl(IndexCatalogEntry* const this_,
if (BSONElement filterElement = _descriptor->getInfoElement("partialFilterExpression")) {
invariant(filterElement.isABSONObj());
BSONObj filter = filterElement.Obj();
+ boost::intrusive_ptr<ExpressionContext> expCtx(
+ new ExpressionContext(opCtx, _collator.get()));
StatusWithMatchExpression statusWithMatcher =
- MatchExpressionParser::parse(filter, _collator.get());
+ MatchExpressionParser::parse(filter, std::move(expCtx));
// this should be checked in create, so can blow up here
invariantOK(statusWithMatcher.getStatus());
_filterExpression = std::move(statusWithMatcher.getValue());
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp
index b128061a1c1..726dc2f5e28 100644
--- a/src/mongo/db/catalog/index_catalog_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_impl.cpp
@@ -666,8 +666,10 @@ Status IndexCatalogImpl::_isSpecOk(OperationContext* opCtx, const BSONObj& spec)
}
// The collator must outlive the constructed MatchExpression.
+ boost::intrusive_ptr<ExpressionContext> expCtx(
+ new ExpressionContext(opCtx, collator.get()));
StatusWithMatchExpression statusWithMatcher =
- MatchExpressionParser::parse(filterElement.Obj(), collator.get());
+ MatchExpressionParser::parse(filterElement.Obj(), std::move(expCtx));
if (!statusWithMatcher.isOK()) {
return statusWithMatcher.getStatus();
}