summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarren Smith <garren.smith@gmail.com>2018-09-06 16:11:41 +0200
committerGarren Smith <garren.smith@gmail.com>2018-09-06 16:11:41 +0200
commit6f5b82a7765b24d3ecaf403bc6f06618eb0a80f0 (patch)
tree28498dc7f70bfd7d2e6ff6dadb8e0335c8739088
parentccb8cdc394201a09791aab3d801c3f00396be980 (diff)
downloadcouchdb-partition-view-validation.tar.gz
validate that a system db cannot be partitionedpartition-view-validation
-rw-r--r--src/chttpd/src/chttpd_db.erl15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl
index 7707d1203..0bfe0404e 100644
--- a/src/chttpd/src/chttpd_db.erl
+++ b/src/chttpd/src/chttpd_db.erl
@@ -346,6 +346,9 @@ create_db_req(#httpd{}=Req, DbName) ->
{initial_props, [{partitioned, Partitioned}]}
] ++ EngineOpt,
DocUrl = absolute_uri(Req, "/" ++ couch_util:url_encode(DbName)),
+
+ ok = validate_partition_database_create(DbName, Partitioned),
+
case fabric:create_db(DbName, Options) of
ok ->
send_json(Req, 201, [{"Location", DocUrl}], {[{ok, true}]});
@@ -1622,6 +1625,18 @@ extract_header_rev(Req, ExplicitRev) ->
end.
+% cannot partition a system database
+validate_partition_database_create(DbName, Partitioned) ->
+ SystemId = DbName =:= ?l2b(config:get("mem3", "shards_db", "_dbs")) orelse
+ lists:member(DbName, ?SYSTEM_DATABASES),
+ case {Partitioned, SystemId} of
+ {true, true} ->
+ throw({bad_request, <<"Cannot partition a system database">>});
+ {_, _} ->
+ ok
+ end.
+
+
validate_attachment_names(Doc) ->
lists:foreach(fun(Att) ->
Name = couch_att:fetch(name, Att),