Ticket #392: modifiedpostlistdeletes.patch

File modifiedpostlistdeletes.patch, 2.4 KB (added by Rich Lane, 15 years ago)
  • xapian-core/tests/api_wrdb.cc

     
    19581958
    19591959    return true;
    19601960}
     1961
     1962/** Regression test for bug in ModifiedPostList iteration
     1963 */
     1964DEFINE_TESTCASE(modifiedpostlist1, writable) {
     1965    Xapian::WritableDatabase db = get_writable_database();
     1966    Xapian::Document a, b;
     1967    Xapian::Enquire enq(db);
     1968   
     1969    a.add_term("T");
     1970    enq.set_query(Xapian::Query("T"));
     1971   
     1972    db.replace_document(2, a);
     1973    db.commit();
     1974    db.replace_document(1, a);
     1975    db.replace_document(1, b);
     1976   
     1977    mset_expect_order(enq.get_mset(0, 2), 2);
     1978   
     1979    return true;
     1980}
  • xapian-core/backends/chert/chert_modifiedpostlist.cc

     
    3232ChertModifiedPostList::skip_deletes(Xapian::weight w_min)
    3333{
    3434    while (!ChertPostList::at_end()) {
     35        while (it != mods.end() && it->second.first == 'D' && it->first < ChertPostList::get_docid()) ++it;
    3536        if (it == mods.end()) return;
    3637        if (it->first != ChertPostList::get_docid()) return;
    3738        if (it->second.first != 'D') return;
     
    5253{
    5354    if (it == mods.end()) return ChertPostList::get_docid();
    5455    if (ChertPostList::at_end()) return it->first;
     56    Assert(it->second.first != 'D');
    5557    return min(it->first, ChertPostList::get_docid());
    5658}
    5759
  • xapian-core/backends/flint/flint_modifiedpostlist.cc

     
    3232FlintModifiedPostList::skip_deletes(Xapian::weight w_min)
    3333{
    3434    while (!FlintPostList::at_end()) {
     35        while (it != mods.end() && it->second.first == 'D' && it->first < FlintPostList::get_docid()) ++it;
    3536        if (it == mods.end()) return;
    3637        if (it->first != FlintPostList::get_docid()) return;
    3738        if (it->second.first != 'D') return;
     
    5253{
    5354    if (it == mods.end()) return FlintPostList::get_docid();
    5455    if (FlintPostList::at_end()) return it->first;
     56    Assert(it->second.first != 'D');
    5557    return min(it->first, FlintPostList::get_docid());
    5658}
    5759