diff options
author | David Percy <david.percy@mongodb.com> | 2021-08-11 20:05:31 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-08-11 21:08:27 +0000 |
commit | 02894677cc0eaa10fac99d2b99f18abf4fc33c74 (patch) | |
tree | 1023be6f3b380413e807567d39940d5b9fb399cc /src/mongo/s | |
parent | 9d6ad7ae69480376a5424fef9f962c616c8d0a25 (diff) | |
download | mongo-02894677cc0eaa10fac99d2b99f18abf4fc33c74.tar.gz |
SERVER-58443 Translate $near/$nearSphere on a view to $geoNear
Diffstat (limited to 'src/mongo/s')
-rw-r--r-- | src/mongo/s/commands/cluster_find_cmd.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/mongo/s/commands/cluster_find_cmd.cpp b/src/mongo/s/commands/cluster_find_cmd.cpp index 46374f2e505..861664d9b2c 100644 --- a/src/mongo/s/commands/cluster_find_cmd.cpp +++ b/src/mongo/s/commands/cluster_find_cmd.cpp @@ -38,6 +38,7 @@ #include "mongo/db/matcher/extensions_callback_noop.h" #include "mongo/db/query/cursor_response.h" #include "mongo/db/stats/counters.h" +#include "mongo/db/storage/storage_parameters_gen.h" #include "mongo/db/views/resolved_view.h" #include "mongo/rpc/get_status_from_command_result.h" #include "mongo/s/catalog_cache.h" @@ -197,8 +198,14 @@ public: auto bodyBuilder = result->getBodyBuilder(); bodyBuilder.resetToEmpty(); - auto aggCmdOnView = - uassertStatusOK(query_request_helper::asAggregationCommand(*findCommand)); + auto cq = uassertStatusOK( + CanonicalQuery::canonicalize(opCtx, + std::move(findCommand), + false /*isExplain*/, + nullptr /*expCtx*/, + ExtensionsCallbackNoop(), + Pipeline::viewFindMatcherFeatures())); + auto aggCmdOnView = uassertStatusOK(asAggregationCommand(*cq)); auto viewAggregationCommand = OpMsgRequest::fromDBAndBody(_dbName, aggCmdOnView).body; @@ -264,8 +271,16 @@ public: } catch (const ExceptionFor<ErrorCodes::CommandOnShardedViewNotSupportedOnMongod>& ex) { result->reset(); - auto aggCmdOnView = uassertStatusOK( - query_request_helper::asAggregationCommand(cq->getFindCommandRequest())); + // 'cq' was constructed with kAllowAllSpecialFeatures, but now we want to convert it + // to an aggregation, which implies a stricter set of allowed features. + cq = uassertStatusOK( + CanonicalQuery::canonicalize(opCtx, + std::move(*cq).releaseFindCommandRequest(), + false, /* isExplain */ + expCtx, + ExtensionsCallbackNoop(), + Pipeline::viewFindMatcherFeatures())); + auto aggCmdOnView = uassertStatusOK(asAggregationCommand(*cq)); auto viewAggregationCommand = OpMsgRequest::fromDBAndBody(_dbName, aggCmdOnView).body; |