summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
authorMoustafa Maher Khalil <m.maher@mongodb.com>2022-02-02 17:19:31 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-02 18:34:55 +0000
commitb6ec92b3b7d0be5b7dd53c3e915b4d93b7b576ed (patch)
tree66b34825ea76b7054dcf6bef810fafc7b474bc0e /src/mongo/db/commands
parent7c3c590d5996089b5cf20263e3660ae0a0bec999 (diff)
downloadmongo-b6ec92b3b7d0be5b7dd53c3e915b4d93b7b576ed.tar.gz
SERVER-62562 Use CollectionUUIDMismatch error code for collectionUUID parameter of aggregate command
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r--src/mongo/db/commands/run_aggregate.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/mongo/db/commands/run_aggregate.cpp b/src/mongo/db/commands/run_aggregate.cpp
index b1b80cc7827..e7634306797 100644
--- a/src/mongo/db/commands/run_aggregate.cpp
+++ b/src/mongo/db/commands/run_aggregate.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/api_parameters.h"
#include "mongo/db/auth/authorization_session.h"
+#include "mongo/db/catalog/collection_uuid_mismatch.h"
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/commands/cqf/cqf_aggregate.h"
@@ -770,10 +771,11 @@ Status runAggregate(OperationContext* opCtx,
if (ctx && ctx->getView() && !liteParsedPipeline.startsWithCollStats()) {
invariant(nss != NamespaceString::kRsOplogNamespace);
invariant(!nss.isCollectionlessAggregateNS());
- uassert(ErrorCodes::OptionNotSupportedOnView,
- str::stream() << AggregateCommandRequest::kCollectionUUIDFieldName
- << " is not supported against a view",
- !request.getCollectionUUID());
+
+ checkCollectionUUIDMismatch(opCtx,
+ collections.getMainCollection(),
+ request.getCollectionUUID(),
+ false /* checkFeatureFlag */);
uassert(ErrorCodes::CommandNotSupportedOnView,
"mapReduce on a view is not supported",
@@ -851,13 +853,11 @@ Status runAggregate(OperationContext* opCtx,
return status;
}
- if (request.getCollectionUUID()) {
- // If the namespace is not a view and collectionUUID was provided, verify the collection
- // exists and has the expected UUID.
- uassert(ErrorCodes::NamespaceNotFound,
- "No collection found with the given namespace and UUID",
- uuid && uuid == *request.getCollectionUUID());
- }
+ // If collectionUUID was provided, verify the collection exists and has the expected UUID.
+ checkCollectionUUIDMismatch(opCtx,
+ collections.getMainCollection(),
+ request.getCollectionUUID(),
+ false /* checkFeatureFlag */);
invariant(collatorToUse);
expCtx = makeExpressionContext(