diff options
author | Moustafa Maher Khalil <m.maher@mongodb.com> | 2022-02-02 17:19:31 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-02-02 18:34:55 +0000 |
commit | b6ec92b3b7d0be5b7dd53c3e915b4d93b7b576ed (patch) | |
tree | 66b34825ea76b7054dcf6bef810fafc7b474bc0e /src/mongo/db/commands | |
parent | 7c3c590d5996089b5cf20263e3660ae0a0bec999 (diff) | |
download | mongo-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.cpp | 22 |
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( |