couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [couchdb] 03/10: add ?partitioned=true parameter when creating a database
Date Tue, 10 Jul 2018 15:06:34 GMT
This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a commit to branch user-partitioned-dbs-wip
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 28bb00bc2677b7cc63cd947b9114152ba9e2e24a
Author: Robert Newson <rnewson@apache.org>
AuthorDate: Thu Jul 5 14:34:29 2018 +0100

    add  ?partitioned=true parameter when creating a database
---
 src/chttpd/src/chttpd_db.erl       | 13 ++++++++++++-
 src/couch/src/couch_db_updater.erl |  4 +++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl
index bf1fe8c..51ee74a 100644
--- a/src/chttpd/src/chttpd_db.erl
+++ b/src/chttpd/src/chttpd_db.erl
@@ -284,12 +284,13 @@ create_db_req(#httpd{}=Req, DbName) ->
     N = chttpd:qs_value(Req, "n", config:get("cluster", "n", "3")),
     Q = chttpd:qs_value(Req, "q", config:get("cluster", "q", "8")),
     P = chttpd:qs_value(Req, "placement", config:get("cluster", "placement")),
+    PartitionedOpt = parse_partitioned_opt(Req),
     EngineOpt = parse_engine_opt(Req),
     Options = [
         {n, N},
         {q, Q},
         {placement, P}
-    ] ++ EngineOpt,
+    ] ++ EngineOpt ++ PartitionedOpt,
     DocUrl = absolute_uri(Req, "/" ++ couch_util:url_encode(DbName)),
     case fabric:create_db(DbName, Options) of
     ok ->
@@ -1413,6 +1414,16 @@ parse_engine_opt(Req) ->
             end
     end.
 
+parse_partitioned_opt(Req) ->
+    case chttpd:qs_value(Req, "partitioned") of
+        undefined ->
+            [];
+        "true" ->
+            [partitioned];
+        _ ->
+            throw({bad_request, <<"`partitioned` parameter can only be set to true.">>})
+    end.
+
 parse_doc_query({Key, Value}, Args) ->
     case {Key, Value} of
         {"attachments", "true"} ->
diff --git a/src/couch/src/couch_db_updater.erl b/src/couch/src/couch_db_updater.erl
index fba99a7..0713582 100644
--- a/src/couch/src/couch_db_updater.erl
+++ b/src/couch/src/couch_db_updater.erl
@@ -27,7 +27,9 @@ init({Engine, DbName, FilePath, Options0}) ->
     erlang:put(io_priority, {db_update, DbName}),
     update_idle_limit_from_config(),
     DefaultSecObj = default_security_object(DbName),
-    Options = [{default_security_object, DefaultSecObj} | Options0],
+    Partitioned = lists:member(partitioned, Options0),
+    Options1 = [{default_security_object, DefaultSecObj} | Options0],
+    Options = [{default_props, [{partitioned, Partitioned}]} | Options1],
     try
         {ok, EngineState} = couch_db_engine:init(Engine, FilePath, Options),
         Db = init_db(DbName, FilePath, EngineState, Options),


Mime
View raw message