summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/couchdb/couch_db.hrl2
-rw-r--r--src/couchdb/couch_httpd_view.erl10
-rw-r--r--src/couchdb/couch_view.erl12
3 files changed, 15 insertions, 9 deletions
diff --git a/src/couchdb/couch_db.hrl b/src/couchdb/couch_db.hrl
index d22d09c7..083468dc 100644
--- a/src/couchdb/couch_db.hrl
+++ b/src/couchdb/couch_db.hrl
@@ -144,7 +144,7 @@
limit = 10000000000, % a huge huge default number. Picked so we don't have
% to do different logic for when there is no limit
% limit
- update = true,
+ stale = false,
direction = fwd,
start_docid = nil,
end_docid = {},
diff --git a/src/couchdb/couch_httpd_view.erl b/src/couchdb/couch_httpd_view.erl
index 2ce68b67..dca1e6e3 100644
--- a/src/couchdb/couch_httpd_view.erl
+++ b/src/couchdb/couch_httpd_view.erl
@@ -23,15 +23,15 @@
design_doc_view(Req, Db, Id, ViewName, Keys) ->
#view_query_args{
- update = Update,
+ stale = Stale,
reduce = Reduce
} = QueryArgs = parse_view_query(Req, Keys),
DesignId = <<"_design/", Id/binary>>,
- case couch_view:get_map_view(Db, DesignId, ViewName, Update) of
+ case couch_view:get_map_view(Db, DesignId, ViewName, Stale) of
{ok, View} ->
output_map_view(Req, View, Db, QueryArgs, Keys);
{not_found, Reason} ->
- case couch_view:get_reduce_view(Db, DesignId, ViewName, Update) of
+ case couch_view:get_reduce_view(Db, DesignId, ViewName, Stale) of
{ok, ReduceView} ->
parse_view_query(Req, Keys, true), % just for validation
case Reduce of
@@ -256,8 +256,10 @@ parse_view_query(Req, Keys, IsReduce) ->
end;
{"count", Value} ->
throw({query_parse_error, "URL query parameter 'count' has been changed to 'limit'."});
+ {"stale", "ok"} ->
+ Args#view_query_args{stale=ok};
{"update", "false"} ->
- Args#view_query_args{update=false};
+ throw({query_parse_error, "URL query parameter 'update=false' has been changed to 'stale=ok'."});
{"descending", "true"} ->
case Args#view_query_args.direction of
fwd ->
diff --git a/src/couchdb/couch_view.erl b/src/couchdb/couch_view.erl
index ce41dd23..3faec4b9 100644
--- a/src/couchdb/couch_view.erl
+++ b/src/couchdb/couch_view.erl
@@ -41,10 +41,14 @@ get_group_server(DbName, GroupId) ->
throw(Error)
end.
-get_group(Db, GroupId, Update) ->
+get_group(Db, GroupId, Stale) ->
+ MinUpdateSeq = case Stale of
+ ok -> 0;
+ _Else -> couch_db:get_update_seq(Db)
+ end,
couch_view_group:request_group(
get_group_server(couch_db:name(Db), GroupId),
- if Update -> couch_db:get_update_seq(Db); true -> 0 end).
+ MinUpdateSeq).
get_temp_group(Db, Type, MapSrc, RedSrc) ->
@@ -136,8 +140,8 @@ get_temp_map_view(Db, Type, Src) ->
{ok, #group{views=[View]}} = get_temp_group(Db, Type, Src, []),
{ok, View}.
-get_map_view(Db, GroupId, Name, Update) ->
- case get_group(Db, GroupId, Update) of
+get_map_view(Db, GroupId, Name, Stale) ->
+ case get_group(Db, GroupId, Stale) of
{ok, #group{views=Views}} ->
get_map_view0(Name, Views);
Error ->