anchor.diff:      % the trees, the attachments are already written to disk)
       {ok, FlushedFullDocInfos} = flush_trees(Db2, NewFullDocInfos, []),
   
  -    {IndexFullDocInfos, IndexDocInfos} =
  -            new_index_entries(FlushedFullDocInfos, [], []),
  +    {IndexFullDocInfos, IndexDocInfos, UpdatedDDocIds} =
  +            new_index_entries(FlushedFullDocInfos, [], [], []),
   
       % and the indexes
       {ok, DocInfoByIdBTree2} = couch_btree:add_remove(DocInfoByIdBTree, IndexFullDocInfos, []),
  
positive.code: 
      % Check if we just updated any design documents, and update the validation
      % funs if we did.
      case lists:any(
          fun(<<"_design/", _/binary>>) -> true; (_) -> false end, Ids) of
      false ->
          Db4 = Db3;
      true ->
          Db4 = refresh_validate_doc_funs(Db3)
      end,
  
      {ok, commit_data(Db4, not FullCommit)}.
  
  
  update_local_docs(Db, []) ->
      {ok, Db};
  
negative.code: 
  
  
  new_index_entries([], AccById, AccBySeq, AccDDocIds) ->
      {AccById, AccBySeq, AccDDocIds};
  new_index_entries([FullDocInfo|RestInfos], AccById, AccBySeq, AccDDocIds) ->
      #doc_info{revs=[#rev_info{deleted=Deleted}|_], id=Id} = DocInfo =
              couch_doc:to_doc_info(FullDocInfo),
      AccDDocIds2 = case Id of
      <<?DESIGN_DOC_PREFIX, _/binary>> ->
          [Id | AccDDocIds];
      _ ->
          AccDDocIds
      end,
      new_index_entries(RestInfos,
          [FullDocInfo#full_doc_info{deleted=Deleted}|AccById],
          [DocInfo|AccBySeq],
          AccDDocIds2).
  
  
  stem_full_doc_infos(#db{revs_limit=Limit}, DocInfos) ->
  