summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2009-05-23 01:14:13 +0000
committerJohn Christopher Anderson <jchris@apache.org>2009-05-23 01:14:13 +0000
commitc41c2168f0bf0c561448962dd7573b272ce3e447 (patch)
tree696e96764adf520e2b0373c734ed0e912ee2f655 /src
parent0292cbac7611bfa101bae29f31f9723001677752 (diff)
added an design doc option so that doc._local_seq can be available in the map view. Closes COUCHDB-346
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@777757 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_db.erl6
-rw-r--r--src/couchdb/couch_doc.erl2
-rw-r--r--src/couchdb/couch_httpd.erl2
-rw-r--r--src/couchdb/couch_httpd_db.erl3
-rw-r--r--src/couchdb/couch_view_updater.erl13
5 files changed, 22 insertions, 4 deletions
diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl
index 82231924..29dbbd38 100644
--- a/src/couchdb/couch_db.erl
+++ b/src/couchdb/couch_db.erl
@@ -820,7 +820,7 @@ open_doc_int(Db, Id, Options) ->
{not_found, missing}
end.
-doc_meta_info(#doc_info{revs=[#rev_info{rev=Rev}|RestInfo]}, RevTree, Options) ->
+doc_meta_info(#doc_info{high_seq=Seq,revs=[#rev_info{rev=Rev}|RestInfo]}, RevTree, Options) ->
case lists:member(revs_info, Options) of
false -> [];
true ->
@@ -851,6 +851,10 @@ doc_meta_info(#doc_info{revs=[#rev_info{rev=Rev}|RestInfo]}, RevTree, Options) -
[] -> [];
DelConflictRevs -> [{deleted_conflicts, DelConflictRevs}]
end
+ end ++
+ case lists:member(local_seq, Options) of
+ false -> [];
+ true -> [{local_seq, Seq}]
end.
diff --git a/src/couchdb/couch_doc.erl b/src/couchdb/couch_doc.erl
index 906a5725..f3a003e1 100644
--- a/src/couchdb/couch_doc.erl
+++ b/src/couchdb/couch_doc.erl
@@ -56,6 +56,8 @@ to_json_meta(Meta) ->
{JsonObj, PosAcc - 1}
end, Start, RevsInfo),
{<<"_revs_info">>, JsonRevsInfo};
+ ({local_seq, Seq}) ->
+ {<<"_local_seq">>, Seq};
({conflicts, Conflicts}) ->
{<<"_conflicts">>, rev_to_strs(Conflicts)};
({deleted_conflicts, DConflicts}) ->
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index 34a13c88..457ab519 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -179,7 +179,7 @@ handle_request(MochiReq, DefaultFun,
send_error(HttpReq, Error);
Tag:Error ->
?LOG_ERROR("Uncaught error in HTTP request: ~p",[{Tag, Error}]),
- ?LOG_DEBUG("Stacktrace: ~p",[erlang:get_stacktrace()]),
+ ?LOG_INFO("Stacktrace: ~p",[erlang:get_stacktrace()]),
send_error(HttpReq, Error)
end,
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index 666f1bef..04f178d5 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -801,6 +801,9 @@ parse_doc_query(Req) ->
{"revs", "true"} ->
Options = [revs | Args#doc_query_args.options],
Args#doc_query_args{options=Options};
+ {"local_seq", "true"} ->
+ Options = [local_seq | Args#doc_query_args.options],
+ Args#doc_query_args{options=Options};
{"revs_info", "true"} ->
Options = [revs_info | Args#doc_query_args.options],
Args#doc_query_args{options=Options};
diff --git a/src/couchdb/couch_view_updater.erl b/src/couchdb/couch_view_updater.erl
index c06e733e..f5b17b37 100644
--- a/src/couchdb/couch_view_updater.erl
+++ b/src/couchdb/couch_view_updater.erl
@@ -97,11 +97,20 @@ process_doc(Db, DocInfo, {Docs, #group{sig=Sig,name=GroupId,design_options=Desig
#doc_info{id=DocId, revs=[#rev_info{deleted=Deleted}|_]} = DocInfo,
IncludeDesign = proplists:get_value(<<"include_design">>,
DesignOptions, false),
+ LocalSeq = proplists:get_value(<<"local_seq">>,
+ DesignOptions, false),
+ DocOpts = case LocalSeq of
+ true ->
+ [conflicts, deleted_conflicts, local_seq];
+ _ ->
+ [conflicts, deleted_conflicts]
+ end,
+ ?LOG_ERROR("DocOpts ~p LocalSeq ~p",[DocOpts, LocalSeq]),
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_int(Db, DocInfo, [conflicts, deleted_conflicts]) of
+ case couch_db:open_doc_int(Db, DocInfo, DocOpts) of
{ok, Doc} ->
case couch_view_group:design_doc_to_view_group(Doc) of
#group{sig=Sig} ->
@@ -126,7 +135,7 @@ process_doc(Db, DocInfo, {Docs, #group{sig=Sig,name=GroupId,design_options=Desig
{Docs, [{DocId, []} | DocIdViewIdKeys]};
true ->
{ok, Doc} = couch_db:open_doc_int(Db, DocInfo,
- [conflicts, deleted_conflicts]),
+ DocOpts),
{[Doc | Docs], DocIdViewIdKeys}
end,