From 7f30babba00b8bea2df2f1d62d3b29f3bf1f14fa Mon Sep 17 00:00:00 2001 From: Erwin Pe Date: Fri, 11 Feb 2022 17:40:24 +0000 Subject: SERVER-63464 Create Collection restrictions with encrypted fields --- src/mongo/db/commands/create_command.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/mongo/db/commands/create_command.cpp') diff --git a/src/mongo/db/commands/create_command.cpp b/src/mongo/db/commands/create_command.cpp index 81a631467f0..b1629c16729 100644 --- a/src/mongo/db/commands/create_command.cpp +++ b/src/mongo/db/commands/create_command.cpp @@ -39,6 +39,7 @@ #include "mongo/db/commands/feature_compatibility_version.h" #include "mongo/db/query/collation/collator_factory_interface.h" #include "mongo/db/query/query_feature_flags_gen.h" +#include "mongo/db/repl/replication_coordinator.h" #include "mongo/db/s/operation_sharding_state.h" #include "mongo/db/storage/storage_parameters_gen.h" #include "mongo/db/timeseries/timeseries_constants.h" @@ -174,6 +175,17 @@ public: cmd.getViewOn()); } + if (cmd.getEncryptedFields()) { + uassert(6346401, + "Encrypted fields cannot be used with views or timeseries collections", + !(cmd.getViewOn() || cmd.getTimeseries())); + + uassert(6346402, + "Encrypted collections are not supported on standalone", + repl::ReplicationCoordinator::get(opCtx)->getReplicationMode() == + repl::ReplicationCoordinator::Mode::modeReplSet); + } + if (auto timeseries = cmd.getTimeseries()) { for (auto&& option : cmd.toBSON({})) { auto fieldName = option.fieldNameStringData(); -- cgit v1.2.1