couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject svn commit: r1141522 - in /couchdb/branches/1.1.x: share/www/script/test/etags_views.js src/couchdb/couch_httpd_show.erl src/couchdb/couch_httpd_view.erl
Date Thu, 30 Jun 2011 13:04:39 GMT
Author: rnewson
Date: Thu Jun 30 13:04:39 2011
New Revision: 1141522

URL: http://svn.apache.org/viewvc?rev=1141522&view=rev
Log:
COUCHDB-1206 - include current_seq in view ETag for include_docs=true

Modified:
    couchdb/branches/1.1.x/share/www/script/test/etags_views.js
    couchdb/branches/1.1.x/src/couchdb/couch_httpd_show.erl
    couchdb/branches/1.1.x/src/couchdb/couch_httpd_view.erl

Modified: couchdb/branches/1.1.x/share/www/script/test/etags_views.js
URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/share/www/script/test/etags_views.js?rev=1141522&r1=1141521&r2=1141522&view=diff
==============================================================================
--- couchdb/branches/1.1.x/share/www/script/test/etags_views.js (original)
+++ couchdb/branches/1.1.x/share/www/script/test/etags_views.js Thu Jun 30 13:04:39 2011
@@ -70,6 +70,14 @@ couchTests.etags_views = function(debug)
   xhr = CouchDB.request("GET", "/test_suite_db/_design/etags/_view/basicView");
   var etag1 = xhr.getResponseHeader("etag");
   T(etag1 == etag);
+
+  // verify ETag always changes for include_docs=true on update
+  xhr = CouchDB.request("GET", "/test_suite_db/_design/etags/_view/basicView?include_docs=true");
+  var etag1 = xhr.getResponseHeader("etag");
+  T(db.save({"_id":"doc2", "foo":"bar"}).ok);
+  xhr = CouchDB.request("GET", "/test_suite_db/_design/etags/_view/basicView?include_docs=true");
+  var etag2 = xhr.getResponseHeader("etag");
+  T(etag1 != etag2);
  
   // Verify that purges affect etags
   xhr = CouchDB.request("GET", "/test_suite_db/_design/etags/_view/fooView");

Modified: couchdb/branches/1.1.x/src/couchdb/couch_httpd_show.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/src/couchdb/couch_httpd_show.erl?rev=1141522&r1=1141521&r2=1141522&view=diff
==============================================================================
--- couchdb/branches/1.1.x/src/couchdb/couch_httpd_show.erl (original)
+++ couchdb/branches/1.1.x/src/couchdb/couch_httpd_show.erl Thu Jun 30 13:04:39 2011
@@ -190,14 +190,14 @@ handle_view_list_req(Req, _Db, _DDoc) ->
 handle_view_list(Req, Db, DDoc, LName, {ViewDesignName, ViewName}, Keys) ->
     ViewDesignId = <<"_design/", ViewDesignName/binary>>,
     {ViewType, View, Group, QueryArgs} = couch_httpd_view:load_view(Req, Db, {ViewDesignId,
ViewName}, Keys),
-    Etag = list_etag(Req, Db, Group, View, {couch_httpd:doc_etag(DDoc), Keys}),
+    Etag = list_etag(Req, Db, Group, View, QueryArgs, {couch_httpd:doc_etag(DDoc), Keys}),
     couch_httpd:etag_respond(Req, Etag, fun() ->
             output_list(ViewType, Req, Db, DDoc, LName, View, QueryArgs, Etag, Keys, Group)
         end).
 
-list_etag(#httpd{user_ctx=UserCtx}=Req, Db, Group, View, More) ->
+list_etag(#httpd{user_ctx=UserCtx}=Req, Db, Group, View, QueryArgs, More) ->
     Accept = couch_httpd:header_value(Req, "Accept"),
-    couch_httpd_view:view_etag(Db, Group, View, {More, Accept, UserCtx#user_ctx.roles}).
+    couch_httpd_view:view_etag(Db, Group, View, QueryArgs, {More, Accept, UserCtx#user_ctx.roles}).
 
 output_list(map, Req, Db, DDoc, LName, View, QueryArgs, Etag, Keys, Group) ->
     output_map_list(Req, Db, DDoc, LName, View, QueryArgs, Etag, Keys, Group);

Modified: couchdb/branches/1.1.x/src/couchdb/couch_httpd_view.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/src/couchdb/couch_httpd_view.erl?rev=1141522&r1=1141521&r2=1141522&view=diff
==============================================================================
--- couchdb/branches/1.1.x/src/couchdb/couch_httpd_view.erl (original)
+++ couchdb/branches/1.1.x/src/couchdb/couch_httpd_view.erl Thu Jun 30 13:04:39 2011
@@ -17,7 +17,7 @@
 
 -export([parse_view_params/3]).
 -export([make_view_fold_fun/7, finish_view_fold/4, finish_view_fold/5, view_row_obj/4]).
--export([view_etag/3, view_etag/4, make_reduce_fold_funs/6]).
+-export([view_etag/5, make_reduce_fold_funs/6]).
 -export([design_doc_view/5, parse_bool_param/1, doc_member/3]).
 -export([make_key_options/1, load_view/4]).
 
@@ -114,7 +114,7 @@ output_map_view(Req, View, Group, Db, Qu
         limit = Limit,
         skip = SkipCount
     } = QueryArgs,
-    CurrentEtag = view_etag(Db, Group, View),
+    CurrentEtag = view_etag(Db, Group, View, QueryArgs),
     couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
         {ok, RowCount} = couch_view:get_row_count(View),
         FoldlFun = make_view_fold_fun(Req, QueryArgs, CurrentEtag, Db, Group#group.current_seq,
RowCount, #view_fold_helper_funs{reduce_count=fun couch_view:reduce_to_count/1}),
@@ -130,7 +130,7 @@ output_map_view(Req, View, Group, Db, Qu
         limit = Limit,
         skip = SkipCount
     } = QueryArgs,
-    CurrentEtag = view_etag(Db, Group, View, Keys),
+    CurrentEtag = view_etag(Db, Group, View, QueryArgs, Keys),
     couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
         {ok, RowCount} = couch_view:get_row_count(View),
         FoldAccInit = {Limit, SkipCount, undefined, []},
@@ -155,7 +155,7 @@ output_reduce_view(Req, Db, View, Group,
         skip = Skip,
         group_level = GroupLevel
     } = QueryArgs,
-    CurrentEtag = view_etag(Db, Group, View),
+    CurrentEtag = view_etag(Db, Group, View, QueryArgs),
     couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
         {ok, GroupRowsFun, RespFun} = make_reduce_fold_funs(Req, GroupLevel,
                 QueryArgs, CurrentEtag, Group#group.current_seq,
@@ -173,7 +173,7 @@ output_reduce_view(Req, Db, View, Group,
         skip = Skip,
         group_level = GroupLevel
     } = QueryArgs,
-    CurrentEtag = view_etag(Db, Group, View, Keys),
+    CurrentEtag = view_etag(Db, Group, View, QueryArgs, Keys),
     couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
         {ok, GroupRowsFun, RespFun} = make_reduce_fold_funs(Req, GroupLevel,
                 QueryArgs, CurrentEtag, Group#group.current_seq,
@@ -640,14 +640,16 @@ send_json_reduce_row(Resp, {Key, Value},
     send_chunk(Resp, RowFront ++ ?JSON_ENCODE({[{key, Key}, {value, Value}]})),
     {ok, ",\r\n"}.
 
-view_etag(Db, Group, View) ->
-    view_etag(Db, Group, View, nil).
+view_etag(Db, Group, View, QueryArgs) ->
+    view_etag(Db, Group, View, QueryArgs, nil).
 
-view_etag(Db, Group, {reduce, _, _, View}, Extra) ->
-    view_etag(Db, Group, View, Extra);
-view_etag(Db, Group, {temp_reduce, View}, Extra) ->
-    view_etag(Db, Group, View, Extra);
-view_etag(_Db, #group{sig=Sig}, #view{update_seq=UpdateSeq, purge_seq=PurgeSeq}, Extra) ->
+view_etag(Db, Group, {reduce, _, _, View}, QueryArgs, Extra) ->
+    view_etag(Db, Group, View, QueryArgs, Extra);
+view_etag(Db, Group, {temp_reduce, View}, QueryArgs, Extra) ->
+    view_etag(Db, Group, View, QueryArgs, Extra);
+view_etag(_Db, #group{sig=Sig, current_seq=CurrentSeq}, _View, #view_query_args{include_docs=true},
Extra) ->
+    couch_httpd:make_etag({Sig, CurrentSeq, Extra});
+view_etag(_Db, #group{sig=Sig}, #view{update_seq=UpdateSeq, purge_seq=PurgeSeq}, _QueryArgs,
Extra) ->
     couch_httpd:make_etag({Sig, UpdateSeq, PurgeSeq, Extra}).
 
 % the view row has an error



Mime
View raw message