From 3a54f4199f66812b7b9496b91a4aebd47dcb7218 Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Thu, 22 Jan 2009 22:42:45 +0000 Subject: change update=false to stale=ok git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@736837 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_db.hrl | 2 +- src/couchdb/couch_httpd_view.erl | 10 ++++++---- src/couchdb/couch_view.erl | 12 ++++++++---- 3 files changed, 15 insertions(+), 9 deletions(-) (limited to 'src') 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 -> -- cgit v1.2.3