You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2018/07/18 19:53:41 UTC

[couchdb] branch user-partitioned-dbs-wip updated: prohibit custom reduces for partitioned views

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


The following commit(s) were added to refs/heads/user-partitioned-dbs-wip by this push:
     new 0440e86  prohibit custom reduces for partitioned views
0440e86 is described below

commit 0440e862eb38ee626eba9b1f124d3fd6277b7efc
Author: Robert Newson <rn...@apache.org>
AuthorDate: Wed Jul 18 20:53:22 2018 +0100

    prohibit custom reduces for partitioned views
---
 src/couch_mrview/src/couch_mrview.erl | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/couch_mrview/src/couch_mrview.erl b/src/couch_mrview/src/couch_mrview.erl
index a9d5d0a..7219d1f 100644
--- a/src/couch_mrview/src/couch_mrview.erl
+++ b/src/couch_mrview/src/couch_mrview.erl
@@ -56,7 +56,9 @@ validate_ddoc_fields(DDoc) ->
         [{<<"filters">>, object}, {any, [object, string]}],
         [{<<"language">>, string}],
         [{<<"lists">>, object}, {any, [object, string]}],
-        [{<<"options">>, object}],
+        [{<<"options">>, object}, {<<"include_design">>, boolean}],
+        [{<<"options">>, object}, {<<"partitioned">>, boolean}],
+        [{<<"options">>, object}, {<<"local_seq">>, boolean}],
         [{<<"rewrites">>, [string, array]}],
         [{<<"shows">>, object}, {any, [object, string]}],
         [{<<"updates">>, object}, {any, [object, string]}],
@@ -133,6 +135,8 @@ validate_ddoc_field(Value, array) when is_list(Value) ->
     ok;
 validate_ddoc_field({Value}, object) when is_list(Value) ->
     ok;
+validate_ddoc_field(Value, boolean) when is_boolean(Value) ->
+    ok;
 validate_ddoc_field({Props}, {any, Type}) ->
     validate_ddoc_field1(Props, Type);
 validate_ddoc_field({Props}, {Key, Type}) ->
@@ -176,6 +180,7 @@ validate(DbName,  DDoc) ->
         (#mrview{reduce_funs = [{Name, _} | _]}) -> Name;
         (_) -> null
     end,
+    Partitioned = mem3:is_partitioned(DbName),
     ValidateView = fun(Proc, #mrview{def=MapSrc, reduce_funs=Reds}=View) ->
         couch_query_servers:try_compile(Proc, map, GetName(View), MapSrc),
         lists:foreach(fun
@@ -190,6 +195,9 @@ validate(DbName,  DDoc) ->
             ({_RedName, <<"_", _/binary>> = Bad}) ->
                 Msg = ["`", Bad, "` is not a supported reduce function."],
                 throw({invalid_design_doc, Msg});
+            ({_RedName, _RedSrc}) when Partitioned ->
+                Msg = <<"partitioned views must use built-in reduces.">>,
+                throw({invalid_design_doc, Msg});
             ({RedName, RedSrc}) ->
                 couch_query_servers:try_compile(Proc, reduce, RedName, RedSrc)
         end, Reds)