summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/create_command.cpp
diff options
context:
space:
mode:
authorErwin Pe <erwin.pe@mongodb.com>2022-02-11 17:40:24 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-11 18:33:42 +0000
commit7f30babba00b8bea2df2f1d62d3b29f3bf1f14fa (patch)
treebf78e5ff5b1aa9d664fee3089305acf576e35288 /src/mongo/db/commands/create_command.cpp
parent7ebe8364c1234261a500870df642d245fc8b6f5f (diff)
downloadmongo-7f30babba00b8bea2df2f1d62d3b29f3bf1f14fa.tar.gz
SERVER-63464 Create Collection restrictions with encrypted fields
Diffstat (limited to 'src/mongo/db/commands/create_command.cpp')
-rw-r--r--src/mongo/db/commands/create_command.cpp12
1 files changed, 12 insertions, 0 deletions
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();