diff options
author | Filipe David Borba Manana <fdmanana@apache.org> | 2010-08-02 17:33:59 +0000 |
---|---|---|
committer | Filipe David Borba Manana <fdmanana@apache.org> | 2010-08-02 17:33:59 +0000 |
commit | 495c20b9856b2abcbdc5a4620d6b4304dcafd70d (patch) | |
tree | 72af504ca756ed42c1bda6cb07127ce533037584 /src | |
parent | d2a2a95aa75636493ed90a43f714768f6a2057bf (diff) |
Add option "stale=update_after" when querying a view. Closes COUCHDB-837.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@981607 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/couchdb/couch_httpd_view.erl | 5 | ||||
-rw-r--r-- | src/couchdb/couch_view.erl | 16 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/couchdb/couch_httpd_view.erl b/src/couchdb/couch_httpd_view.erl index 3c93e50a..62d0ee5b 100644 --- a/src/couchdb/couch_httpd_view.erl +++ b/src/couchdb/couch_httpd_view.erl @@ -282,8 +282,11 @@ parse_view_param("count", _Value) -> throw({query_parse_error, <<"Query parameter 'count' is now 'limit'.">>}); parse_view_param("stale", "ok") -> [{stale, ok}]; +parse_view_param("stale", "update_after") -> + [{stale, update_after}]; parse_view_param("stale", _Value) -> - throw({query_parse_error, <<"stale only available as stale=ok">>}); + throw({query_parse_error, + <<"stale only available as stale=ok or as stale=update_after">>}); parse_view_param("update", _Value) -> throw({query_parse_error, <<"update=false is now stale=ok">>}); parse_view_param("descending", Value) -> diff --git a/src/couchdb/couch_view.erl b/src/couchdb/couch_view.erl index 38c0a783..189bd98f 100644 --- a/src/couchdb/couch_view.erl +++ b/src/couchdb/couch_view.erl @@ -58,11 +58,23 @@ get_group_server(DbName, GroupId) -> get_group(Db, GroupId, Stale) -> MinUpdateSeq = case Stale of ok -> 0; + update_after -> 0; _Else -> couch_db:get_update_seq(Db) end, - couch_view_group:request_group( + Result = {ok, Group} = couch_view_group:request_group( get_group_server(couch_db:name(Db), GroupId), - MinUpdateSeq). + MinUpdateSeq), + case Stale of + update_after -> + % best effort, process might die + spawn(fun() -> + LastSeq = couch_db:get_update_seq(Db), + couch_view_group:request_group(Group, LastSeq) + end); + _ -> + ok + end, + Result. get_temp_group(Db, Language, DesignOptions, MapSrc, RedSrc) -> couch_view_group:request_group( |