anchor.diff:          }
       }.
   
  +should_not_remember_docs_in_index_after_backup_restore_test() ->
  +    %% COUCHDB-640
  +    start(),
  +    DbName = setup_with_docs(),
  +
  +    ok = backup_db_file(DbName),
  +    create_doc(DbName),
  +
  +    Body0 = query_view(DbName, "foo", "bar"),
  +    ViewJson0 = ejson:decode(Body0),
  +    Rows0 = couch_util:get_nested_json_value(ViewJson0, [<<"rows">>]),
  +    ?assert(has_doc("doc1", Rows0)),
  +    ?assert(has_doc("doc2", Rows0)),
  +    ?assert(has_doc("doc3", Rows0)),
  +    ?assert(has_doc("doc666", Rows0)),
  +
  +    restore_backup_db_file(DbName),
  +
  +    Body1 = query_view(DbName, "foo", "bar"),
  +    ViewJson1 = ejson:decode(Body1),
  +    Rows1 = couch_util:get_nested_json_value(ViewJson1, [<<"rows">>]),
  +    ?assert(has_doc("doc1", Rows1)),
  +    ?assert(has_doc("doc2", Rows1)),
  +    ?assert(has_doc("doc3", Rows1)),
  +    ?assertNot(has_doc("doc666", Rows1)),
  +
  +    teardown(DbName),
  +    stop(whereis(couch_server_sup)).
  +
  +
   should_have_two_indexes_alive_before_deletion({DbName, _}) ->
       view_cleanup(DbName),
       ?_assertEqual(2, count_index_files(DbName)).
  
positive.code: db_url(DbName) ->
      Addr = couch_config:get("httpd", "bind_address", "127.0.0.1"),
      Port = integer_to_list(mochiweb_socket_server:get(couch_httpd, port)),
      "http://" ++ Addr ++ ":" ++ Port ++ "/" ++ binary_to_list(DbName).
  
  query_view(DbName, DDoc, View) ->
      {ok, Code, _Headers, _Body} = test_request:get(
          db_url(DbName) ++ "/_design/" ++ DDoc ++ "/_view/" ++ View),
      ?assertEqual(200, Code),
      ok.
  
  view_cleanup(DbName) ->
      {ok, Db} = couch_db:open(DbName, [?ADMIN_USER]),
  
negative.code:     view_cleanup(DbName),
      ?_assertEqual(0, count_index_files(DbName)).
  
  
  create_doc(DbName) ->
      {ok, Db} = couch_db:open(DbName, [?ADMIN_USER]),
      Doc666 = couch_doc:from_json_obj({[
          {<<"_id">>, <<"doc666">>},
          {<<"value">>, 999}
  
      ]}),
      {ok, _} = couch_db:update_docs(Db, [Doc666]),
      couch_db:ensure_full_commit(Db),
      couch_db:close(Db).
  
  create_docs(DbName) ->
      {ok, Db} = couch_db:open(DbName, [?ADMIN_USER]),
      Doc1 = couch_doc:from_json_obj({[
          {<<"_id">>, <<"doc1">>},
          {<<"value">>, 1}
  
      ]}),
      Doc2 = couch_doc:from_json_obj({[
          {<<"_id">>, <<"doc2">>},
          {<<"value">>, 2}
  
      ]}),
      Doc3 = couch_doc:from_json_obj({[
          {<<"_id">>, <<"doc3">>},
          {<<"value">>, 3}
  
      ]}),
      {ok, _} = couch_db:update_docs(Db, [Doc1, Doc2, Doc3]),
      couch_db:ensure_full_commit(Db),
      couch_db:close(Db).
  
  create_design_doc(DbName, DDName, ViewName) ->
      {ok, Db} = couch_db:open(DbName, [?ADMIN_USER]),
  