diff options
author | Robert Newson <rnewson@apache.org> | 2018-08-22 15:35:51 +0100 |
---|---|---|
committer | Robert Newson <rnewson@apache.org> | 2018-10-08 09:51:20 +0100 |
commit | ca6180a4ba32382c507b90961b02ed78713e6b75 (patch) | |
tree | e0f427e0fdf5724d28a33713dbd988118807655a | |
parent | b5cb039116bfba7a8ffa76c018bf54e003cbc749 (diff) | |
download | couchdb-ca6180a4ba32382c507b90961b02ed78713e6b75.tar.gz |
Add restrictions to partitioned views
* Block design documents with partitioned option in non-partitioned db
* Prohibit javascript reduces in partitioned:true ddocs
* Prohibit include_docs=true for _view in partitioned db
-rw-r--r-- | src/couch_mrview/src/couch_mrview.erl | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/couch_mrview/src/couch_mrview.erl b/src/couch_mrview/src/couch_mrview.erl index f5963e70f..7862afb1e 100644 --- a/src/couch_mrview/src/couch_mrview.erl +++ b/src/couch_mrview/src/couch_mrview.erl @@ -176,6 +176,16 @@ join([H|T], Sep, Acc) -> validate(DbName, DDoc) -> ok = validate_ddoc_fields(DDoc#doc.body), + DbPartitioned = mem3:is_partitioned(DbName), + DDocPartitioned = get_partitioned_opt(DDoc#doc.body, DbPartitioned), + if + not DbPartitioned andalso DDocPartitioned -> + throw({invalid_design_doc, + <<"partitioned option cannot be true in a " + "non-partitioned database.">>}); + true -> + ok + end, GetName = fun (#mrview{map_names = [Name | _]}) -> Name; (#mrview{reduce_funs = [{Name, _} | _]}) -> Name; @@ -195,6 +205,9 @@ validate(DbName, DDoc) -> ({_RedName, <<"_", _/binary>> = Bad}) -> Msg = ["`", Bad, "` is not a supported reduce function."], throw({invalid_design_doc, Msg}); + ({_RedName, _RedSrc}) when DDocPartitioned -> + Msg = <<"Javascript reduces not supported in partitioned view.">>, + throw({invalid_design_doc, Msg}); ({RedName, RedSrc}) -> couch_query_servers:try_compile(Proc, reduce, RedName, RedSrc) end, Reds) @@ -215,6 +228,9 @@ validate(DbName, DDoc) -> ok end. +get_partitioned_opt({Props}, Default) -> + {Options} = couch_util:get_value(<<"options">>, Props, {[]}), + couch_util:get_value(<<"partitioned">>, Options, Default). query_all_docs(Db, Args) -> query_all_docs(Db, Args, fun default_cb/2, []). |