diff options
author | Kevin Pulo <kevin.pulo@mongodb.com> | 2019-11-26 03:23:07 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-11-26 03:23:07 +0000 |
commit | 8b0f534a706005d366e200ee56af5c76217656b2 (patch) | |
tree | 4ff0d0d1ea68d4f1a17ce39c4ab8087cfa617434 /src/mongo/db/commands.h | |
parent | 34e093782f53dec39ff89116c0c7128430c99bae (diff) | |
download | mongo-8b0f534a706005d366e200ee56af5c76217656b2.tar.gz |
SERVER-44470 Parse aggregation commands earlier, and rationalize aggregation readConcern handling
Diffstat (limited to 'src/mongo/db/commands.h')
-rw-r--r-- | src/mongo/db/commands.h | 58 |
1 files changed, 14 insertions, 44 deletions
diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h index ea62ac51fc0..2350a040b6d 100644 --- a/src/mongo/db/commands.h +++ b/src/mongo/db/commands.h @@ -45,6 +45,7 @@ #include "mongo/db/commands/test_commands_enabled.h" #include "mongo/db/jsobj.h" #include "mongo/db/query/explain.h" +#include "mongo/db/read_concern_support_result.h" #include "mongo/db/repl/read_concern_args.h" #include "mongo/db/write_concern.h" #include "mongo/rpc/op_msg.h" @@ -269,6 +270,13 @@ public: virtual std::unique_ptr<CommandInvocation> parse(OperationContext* opCtx, const OpMsgRequest& request) = 0; + virtual std::unique_ptr<CommandInvocation> parseForExplain( + OperationContext* opCtx, + const OpMsgRequest& request, + boost::optional<ExplainOptions::Verbosity> explainVerbosity) { + return parse(opCtx, request); + } + /** * Returns the command's name. This value never changes for the lifetime of the command. */ @@ -433,46 +441,6 @@ private: }; /** - * The result of checking an invocation's support for readConcern. There are two parts: - * - Whether or not the invocation supports the given readConcern. - * - Whether or not the invocation permits having the default readConcern applied to it. - */ -struct ReadConcernSupportResult { - /** - * Whether this command invocation supports the requested readConcern level. This only - * applies when running outside transactions because all commands that are allowed to run - * in a transaction must support all the read concerns that can be used in a transaction. - */ - enum class ReadConcern { kSupported, kNotSupported } readConcern; - - /** - * Whether this command invocation supports applying the default readConcern to it. - */ - enum class DefaultReadConcern { kPermitted, kNotPermitted } defaultReadConcern; - - /** - * Construct with either the enum value or a bool, where true indicates - * ReadConcern::kSupported or DefaultReadConcern::kPermitted (as appropriate). - */ - ReadConcernSupportResult(ReadConcern supported, DefaultReadConcern defaultPermitted) - : readConcern(supported), defaultReadConcern(defaultPermitted) {} - - ReadConcernSupportResult(bool supported, DefaultReadConcern defaultPermitted) - : readConcern(supported ? ReadConcern::kSupported : ReadConcern::kNotSupported), - defaultReadConcern(defaultPermitted) {} - - ReadConcernSupportResult(ReadConcern supported, bool defaultPermitted) - : readConcern(supported), - defaultReadConcern(defaultPermitted ? DefaultReadConcern::kPermitted - : DefaultReadConcern::kNotPermitted) {} - - ReadConcernSupportResult(bool supported, bool defaultPermitted) - : readConcern(supported ? ReadConcern::kSupported : ReadConcern::kNotSupported), - defaultReadConcern(defaultPermitted ? DefaultReadConcern::kPermitted - : DefaultReadConcern::kNotPermitted) {} -}; - -/** * Represents a single invocation of a given command. */ class CommandInvocation { @@ -516,8 +484,9 @@ public: * Returns this invocation's support for readConcern. */ virtual ReadConcernSupportResult supportsReadConcern(repl::ReadConcernLevel level) const { - return {level == repl::ReadConcernLevel::kLocalReadConcern, - ReadConcernSupportResult::DefaultReadConcern::kNotPermitted}; + return {{level != repl::ReadConcernLevel::kLocalReadConcern, + {ErrorCodes::InvalidOptions, "read concern not supported"}}, + {{ErrorCodes::InvalidOptions, "default read concern not permitted"}}}; } /** @@ -667,8 +636,9 @@ public: virtual ReadConcernSupportResult supportsReadConcern(const std::string& dbName, const BSONObj& cmdObj, repl::ReadConcernLevel level) const { - return {level == repl::ReadConcernLevel::kLocalReadConcern, - ReadConcernSupportResult::DefaultReadConcern::kNotPermitted}; + return {{level != repl::ReadConcernLevel::kLocalReadConcern, + {ErrorCodes::InvalidOptions, "read concern not supported"}}, + {{ErrorCodes::InvalidOptions, "default read concern not permitted"}}}; } virtual bool allowsAfterClusterTime(const BSONObj& cmdObj) const { |