diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2018-05-18 17:29:14 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2018-06-07 08:45:11 -0400 |
commit | 80de0da37b00dbeed576b28a842cb172b6714358 (patch) | |
tree | 383e2c5b393eb67688cadd182af88ed18af5d473 /src/mongo/db/commands/run_aggregate.cpp | |
parent | 15e7ffc06ef9b38f9ffe2d85fc691c9b5a567bbd (diff) | |
download | mongo-80de0da37b00dbeed576b28a842cb172b6714358.tar.gz |
SERVER-32198 Get rid of CollectionShardingState::collectionIsSharded
Diffstat (limited to 'src/mongo/db/commands/run_aggregate.cpp')
-rw-r--r-- | src/mongo/db/commands/run_aggregate.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/mongo/db/commands/run_aggregate.cpp b/src/mongo/db/commands/run_aggregate.cpp index f6e599a34ae..f7a4611104a 100644 --- a/src/mongo/db/commands/run_aggregate.cpp +++ b/src/mongo/db/commands/run_aggregate.cpp @@ -58,12 +58,12 @@ #include "mongo/db/read_concern.h" #include "mongo/db/repl/oplog.h" #include "mongo/db/repl/read_concern_args.h" +#include "mongo/db/s/sharding_state.h" #include "mongo/db/service_context.h" #include "mongo/db/session_catalog.h" #include "mongo/db/storage/storage_options.h" #include "mongo/db/views/view.h" #include "mongo/db/views/view_catalog.h" -#include "mongo/db/views/view_sharding_check.h" #include "mongo/stdx/memory.h" #include "mongo/util/log.h" #include "mongo/util/scopeguard.h" @@ -400,6 +400,7 @@ Status runAggregate(OperationContext* opCtx, if (ctx && ctx->getView() && !liteParsedPipeline.startsWithCollStats()) { invariant(nss != NamespaceString::kRsOplogNamespace); invariant(!nss.isCollectionlessAggregateNS()); + // Check that the default collation of 'view' is compatible with the operation's // collation. The check is skipped if the request did not specify a collation. if (!request.getCollation().isEmpty()) { @@ -411,27 +412,28 @@ Status runAggregate(OperationContext* opCtx, } } - ViewShardingCheck::throwResolvedViewIfSharded(opCtx, ctx->getDb(), ctx->getView()); - - auto resolvedView = ctx->getDb()->getViewCatalog()->resolveView(opCtx, nss); - if (!resolvedView.isOK()) { - return resolvedView.getStatus(); - } + auto resolvedView = + uassertStatusOK(ctx->getDb()->getViewCatalog()->resolveView(opCtx, nss)); + uassert(std::move(resolvedView), + "On sharded systems, resolved views must be executed by mongos", + !ShardingState::get(opCtx)->enabled()); // With the view & collation resolved, we can relinquish locks. ctx.reset(); // Parse the resolved view into a new aggregation request. - auto newRequest = resolvedView.getValue().asExpandedViewAggregation(request); + auto newRequest = resolvedView.asExpandedViewAggregation(request); auto newCmd = newRequest.serializeToCommandObj().toBson(); auto status = runAggregate(opCtx, origNss, newRequest, newCmd, result); + { // Set the namespace of the curop back to the view namespace so ctx records // stats on this view namespace on destruction. stdx::lock_guard<Client> lk(*opCtx->getClient()); curOp->setNS_inlock(nss.ns()); } + return status; } |