diff options
author | Robert Newson <rnewson@apache.org> | 2018-09-03 19:49:56 +0100 |
---|---|---|
committer | Robert Newson <rnewson@apache.org> | 2018-09-05 11:51:31 +0100 |
commit | a28aee91408cbf64aa7b1e2c4738421f55fd288a (patch) | |
tree | e64a229e4e37db11e817153f80f35e4f255ec420 | |
parent | 231b33362c3976ade0a0711aa68ca02e81c35dcb (diff) | |
download | couchdb-a28aee91408cbf64aa7b1e2c4738421f55fd288a.tar.gz |
grabbag of fixes. needs merging into previous commits
-rw-r--r-- | src/chttpd/src/chttpd_db.erl | 10 | ||||
-rw-r--r-- | src/chttpd/src/chttpd_view.erl | 14 | ||||
-rw-r--r-- | src/couch_mrview/src/couch_mrview_http.erl | 6 | ||||
-rw-r--r-- | src/couch_mrview/src/couch_mrview_util.erl | 12 | ||||
-rw-r--r-- | src/fabric/src/fabric.erl | 2 | ||||
-rw-r--r-- | src/mem3/src/mem3.erl | 1 |
6 files changed, 20 insertions, 25 deletions
diff --git a/src/chttpd/src/chttpd_db.erl b/src/chttpd/src/chttpd_db.erl index 37289ebd6..3fe26a172 100644 --- a/src/chttpd/src/chttpd_db.erl +++ b/src/chttpd/src/chttpd_db.erl @@ -734,16 +734,18 @@ multi_all_docs_view(Req, Db, OP, Queries) -> {ok, Resp1} = chttpd:send_delayed_chunk(VAcc2#vacc.resp, "\r\n]}"), chttpd:end_delayed_json_response(Resp1). -all_docs_view(Req, Db, Keys, OP) -> +all_docs_view(#httpd{path_parts=[DbName | _]}=Req, Db, Keys, OP) -> + Partitioned = mem3:is_partitioned(DbName), Args0 = couch_mrview_http:parse_params(Req, Keys), Args1 = Args0#mrargs{view_type=map}, Args2 = couch_mrview_util:set_extra(Args1, style, all_docs), - Args3 = couch_mrview_util:validate_args(Args2), - Args4 = set_namespace(OP, Args3), + Args3 = couch_mrview_util:set_extra(Args2, partitioned, Partitioned), + Args4 = couch_mrview_util:validate_args(Args3), + Args5 = set_namespace(OP, Args4), Options = [{user_ctx, Req#httpd.user_ctx}], Max = chttpd:chunked_response_buffer_size(), VAcc = #vacc{db=Db, req=Req, threshold=Max}, - {ok, Resp} = fabric:all_docs(Db, Options, fun couch_mrview_http:view_cb/2, VAcc, Args4), + {ok, Resp} = fabric:all_docs(Db, Options, fun couch_mrview_http:view_cb/2, VAcc, Args5), {ok, Resp#vacc.resp}. db_doc_req(#httpd{method='DELETE'}=Req, Db, DocId) -> diff --git a/src/chttpd/src/chttpd_view.erl b/src/chttpd/src/chttpd_view.erl index 25f240931..3743e6da9 100644 --- a/src/chttpd/src/chttpd_view.erl +++ b/src/chttpd/src/chttpd_view.erl @@ -24,7 +24,7 @@ multi_query_view(Req, Db, DDoc, ViewName, Queries) -> QueryArg = couch_mrview_http:parse_params(Query, undefined, Args1, [decoded]), QueryArg1 = couch_mrview_util:set_view_type(QueryArg, ViewName, Views), - couch_mrview_util:validate_args(QueryArg1, [view]) + couch_mrview_util:validate_args(QueryArg1) end, Queries), Options = [{user_ctx, Req#httpd.user_ctx}], VAcc0 = #vacc{db=Db, req=Req, prepend="\r\n"}, @@ -40,8 +40,13 @@ multi_query_view(Req, Db, DDoc, ViewName, Queries) -> chttpd:end_delayed_json_response(Resp1). -design_doc_view(Req, Db, DDoc, ViewName, Keys) -> - Args = couch_mrview_http:parse_params(Req, Keys), +design_doc_view(#httpd{path_parts=[DbName | _]}=Req, Db, DDoc, ViewName, Keys) -> + Args0 = couch_mrview_http:parse_params(Req, Keys), + {Props} = DDoc#doc.body, + {Options} = couch_util:get_value(<<"options">>, Props, {[]}), + DbPartitioned = mem3:is_partitioned(DbName), + Partitioned = couch_util:get_value(<<"partitioned">>, Options, DbPartitioned), + Args = couch_mrview_util:set_extra(Args0, partitioned, Partitioned), design_doc_view_int(Req, Db, DDoc, ViewName, Args). @@ -115,7 +120,8 @@ handle_partition_view_req(#httpd{method='POST', couch_stats:increment_counter([couchdb, httpd, view_reads]), Args0 = couch_mrview_http:parse_params(Req, Keys), Args1 = couch_mrview_util:set_extra(Args0, partition, Partition), - design_doc_view_int(Req, Db, DDoc, ViewName, Args1); + Args2 = couch_mrview_util:set_extra(Args1, partitioned, true), + design_doc_view_int(Req, Db, DDoc, ViewName, Args2); _ -> throw({ bad_request, diff --git a/src/couch_mrview/src/couch_mrview_http.erl b/src/couch_mrview/src/couch_mrview_http.erl index dfdb6449a..86df7968a 100644 --- a/src/couch_mrview/src/couch_mrview_http.erl +++ b/src/couch_mrview/src/couch_mrview_http.erl @@ -461,10 +461,8 @@ row_to_json(Id0, Row) -> ?JSON_ENCODE(Obj). -parse_params(#httpd{path_parts=[DbName | _]}=Req, Keys) -> - Args = parse_params(chttpd:qs(Req), Keys), - Partitioned = mem3:is_partitioned(DbName), - couch_mrview_util:set_extra(Args, partitioned, Partitioned); +parse_params(#httpd{}=Req, Keys) -> + parse_params(chttpd:qs(Req), Keys); parse_params(Props, Keys) -> Args = #mrargs{}, parse_params(Props, Keys, Args). diff --git a/src/couch_mrview/src/couch_mrview_util.erl b/src/couch_mrview/src/couch_mrview_util.erl index 0fa5c1faa..abd731af2 100644 --- a/src/couch_mrview/src/couch_mrview_util.erl +++ b/src/couch_mrview/src/couch_mrview_util.erl @@ -24,7 +24,7 @@ -export([temp_view_to_ddoc/1]). -export([calculate_external_size/1]). -export([calculate_active_size/1]). --export([validate_args/1, validate_args/2]). +-export([validate_args/1]). -export([maybe_load_doc/3, maybe_load_doc/4]). -export([maybe_update_index_file/1]). -export([extract_view/4, extract_view_reduce/1]). @@ -465,9 +465,6 @@ fold_reduce({NthRed, Lang, View}, Fun, Acc, Options) -> validate_args(Args) -> - validate_args(Args, []). - -validate_args(Args, ValidateOptions) -> GroupLevel = determine_group_level(Args), Reduce = Args#mrargs.reduce, case Reduce == undefined orelse is_boolean(Reduce) of @@ -610,13 +607,6 @@ validate_args(Args, ValidateOptions) -> mrverror(<<"`partition` parameter is not supported in this view.">>) end, - case {Partitioned, Args#mrargs.include_docs, ValidateOptions} of - {true, true, [view]} -> - mrverror(<<"`include_docs=true` is not supported in this view.">>); - {_, _, _} -> - ok - end, - case {Partitioned, Args#mrargs.conflicts} of {true, true} -> mrverror(<<"`conflicts=true` is not supported in this view.">>); diff --git a/src/fabric/src/fabric.erl b/src/fabric/src/fabric.erl index fcdbb2a72..f5c793736 100644 --- a/src/fabric/src/fabric.erl +++ b/src/fabric/src/fabric.erl @@ -356,7 +356,7 @@ query_view(DbName, Options, DDoc, ViewName, Callback, Acc0, QueryArgs0) -> {ok, #mrst{views=Views, language=Lang}} = couch_mrview_util:ddoc_to_mrst(Db, DDoc), QueryArgs1 = couch_mrview_util:set_view_type(QueryArgs0, View, Views), - QueryArgs2 = couch_mrview_util:validate_args(QueryArgs1, [view]), + QueryArgs2 = couch_mrview_util:validate_args(QueryArgs1), VInfo = couch_mrview_util:extract_view(Lang, QueryArgs2, View, Views), case is_reduce_view(QueryArgs2) of true -> diff --git a/src/mem3/src/mem3.erl b/src/mem3/src/mem3.erl index e3cd388ba..dd1e63e87 100644 --- a/src/mem3/src/mem3.erl +++ b/src/mem3/src/mem3.erl @@ -360,7 +360,6 @@ is_partitioned(#shard{opts=Opts}) -> is_partitioned(#ordered_shard{opts=Opts}) -> couch_util:get_value(partitioned, Opts) == true. - -ifdef(TEST). -include_lib("eunit/include/eunit.hrl"). |