summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/query_request_helper.cpp
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
commit4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch)
tree1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/db/query/query_request_helper.cpp
parentaa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff)
parent8f0827553e09872941945a093b647a4211a9db7f (diff)
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0' with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/mongo/db/query/query_request_helper.cpp')
-rw-r--r--src/mongo/db/query/query_request_helper.cpp42
1 files changed, 11 insertions, 31 deletions
diff --git a/src/mongo/db/query/query_request_helper.cpp b/src/mongo/db/query/query_request_helper.cpp
index b713b9d8000..410c05fcaf0 100644
--- a/src/mongo/db/query/query_request_helper.cpp
+++ b/src/mongo/db/query/query_request_helper.cpp
@@ -85,35 +85,6 @@ Status validateGetMoreCollectionName(StringData collectionName) {
return Status::OK();
}
-Status validateResumeAfter(const mongo::BSONObj& resumeAfter, bool isClusteredCollection) {
- if (resumeAfter.isEmpty()) {
- return Status::OK();
- }
-
- BSONType recordIdType = resumeAfter["$recordId"].type();
- if (resumeAfter.nFields() != 1 ||
- (recordIdType != BSONType::NumberLong && recordIdType != BSONType::BinData &&
- recordIdType != BSONType::jstNULL)) {
- return Status(ErrorCodes::BadValue,
- "Malformed resume token: the '_resumeAfter' object must contain"
- " exactly one field named '$recordId', of type NumberLong, BinData "
- "or jstNULL.");
- }
-
- // Clustered collections can only have accept '$_resumeAfter' parameter of type
- // BinData. Non clustered collections should only accept '$_resumeAfter' of type
- // Long.
- if ((isClusteredCollection && recordIdType == BSONType::NumberLong) ||
- (!isClusteredCollection && recordIdType == BSONType::BinData)) {
- return Status(ErrorCodes::Error(7738600),
- "The '$_resumeAfter parameter must match collection type. Clustered "
- "collections only have BinData recordIds, and all other collections"
- "have Long recordId.");
- }
-
- return Status::OK();
-}
-
Status validateFindCommandRequest(const FindCommandRequest& findCommand) {
// Min and Max objects must have the same fields.
if (!findCommand.getMin().isEmpty() && !findCommand.getMax().isEmpty()) {
@@ -156,8 +127,17 @@ Status validateFindCommandRequest(const FindCommandRequest& findCommand) {
return Status(ErrorCodes::BadValue,
"sort must be unset or {$natural:1} if 'requestResumeToken' is enabled");
}
- // The $_resumeAfter parameter is checked in 'validateResumeAfter()'.
-
+ if (!findCommand.getResumeAfter().isEmpty()) {
+ if (findCommand.getResumeAfter().nFields() != 1 ||
+ (findCommand.getResumeAfter()["$recordId"].type() != BSONType::NumberLong &&
+ findCommand.getResumeAfter()["$recordId"].type() != BSONType::BinData &&
+ findCommand.getResumeAfter()["$recordId"].type() != BSONType::jstNULL)) {
+ return Status(ErrorCodes::BadValue,
+ "Malformed resume token: the '_resumeAfter' object must contain"
+ " exactly one field named '$recordId', of type NumberLong, BinData "
+ "or jstNULL.");
+ }
+ }
} else if (!findCommand.getResumeAfter().isEmpty()) {
return Status(ErrorCodes::BadValue,
"'requestResumeToken' must be true if 'resumeAfter' is"