summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_view_updater.erl
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2009-02-01 22:21:09 +0000
committerJohn Christopher Anderson <jchris@apache.org>2009-02-01 22:21:09 +0000
commitcdfe55c54de515581121f6923e8301e8cbea5bcc (patch)
tree13db216a91aa8ad0f39d30324afa41023334b685 /src/couchdb/couch_view_updater.erl
parent614f3c26d98ab656e095b5672511d710732f034a (diff)
Added options member to design docs. Currently the only option is include_designs (views can now run over design docs as well if they need to), the default is false, which is the current behavior. Thanks davisp for the original patch. Closes COUCHDB-156
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@739866 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_view_updater.erl')
-rw-r--r--src/couchdb/couch_view_updater.erl27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/couchdb/couch_view_updater.erl b/src/couchdb/couch_view_updater.erl
index b6ae860f..956ac3f1 100644
--- a/src/couchdb/couch_view_updater.erl
+++ b/src/couchdb/couch_view_updater.erl
@@ -90,43 +90,52 @@ purge_index(#group{db=Db, views=Views, id_btree=IdBtree}=Group) ->
views=Views2,
purge_seq=couch_db:get_purge_seq(Db)}.
-process_doc(Db, DocInfo, {Docs, #group{sig=Sig,name=GroupId}=Group, ViewKVs,
+process_doc(Db, DocInfo, {Docs, #group{sig=Sig,name=GroupId,design_options=DesignOptions}=Group, ViewKVs,
DocIdViewIdKeys}) ->
% This fun computes once for each document
#doc_info{id=DocId, deleted=Deleted} = DocInfo,
- case DocId of
- GroupId ->
+ IncludeDesign = proplists:get_value(<<"include_design">>,
+ DesignOptions, false),
+ case {IncludeDesign, DocId} of
+ {_, GroupId} ->
% uh oh. this is the design doc with our definitions. See if
% anything in the definition changed.
- case couch_db:open_doc(Db, DocInfo) of
+ case couch_db:open_doc(Db, DocInfo, [conflicts, deleted_conflicts]) of
{ok, Doc} ->
case couch_view_group:design_doc_to_view_group(Doc) of
#group{sig=Sig} ->
% The same md5 signature, keep on computing
- {Docs, Group, ViewKVs, DocIdViewIdKeys};
+ case IncludeDesign of
+ true ->
+ {[Doc | Docs], Group, ViewKVs, DocIdViewIdKeys};
+ _ ->
+ {Docs, Group, ViewKVs, DocIdViewIdKeys}
+ end;
_ ->
exit(reset)
end;
{not_found, deleted} ->
exit(reset)
end;
- <<?DESIGN_DOC_PREFIX, _/binary>> -> % we skip design docs
+ {false, <<?DESIGN_DOC_PREFIX, _/binary>>} -> % we skip design docs
{Docs, Group, ViewKVs, DocIdViewIdKeys};
_ ->
{Docs2, DocIdViewIdKeys2} =
if Deleted ->
{Docs, [{DocId, []} | DocIdViewIdKeys]};
true ->
- {ok, Doc} = couch_db:open_doc(Db, DocInfo, [conflicts, deleted_conflicts]),
+ {ok, Doc} = couch_db:open_doc(Db, DocInfo,
+ [conflicts, deleted_conflicts]),
{[Doc | Docs], DocIdViewIdKeys}
end,
case couch_util:should_flush() of
true ->
{Group1, Results} = view_compute(Group, Docs2),
- {ViewKVs3, DocIdViewIdKeys3} = view_insert_query_results(Docs2, Results, ViewKVs, DocIdViewIdKeys2),
+ {ViewKVs3, DocIdViewIdKeys3} = view_insert_query_results(Docs2,
+ Results, ViewKVs, DocIdViewIdKeys2),
{ok, Group2} = write_changes(Group1, ViewKVs3, DocIdViewIdKeys3,
- DocInfo#doc_info.update_seq),
+ DocInfo#doc_info.update_seq),
garbage_collect(),
ViewEmptyKeyValues = [{View, []} || View <- Group2#group.views],
{[], Group2, ViewEmptyKeyValues, []};