Ticket #855: xapian-trac855-candidate-fix.patch

File xapian-trac855-candidate-fix.patch, 3.1 KB (added by Olly Betts, 3 weeks ago)
  • xapian-core/backends/glass/glass_postlist.cc

    diff --git a/xapian-core/backends/glass/glass_postlist.cc b/xapian-core/backends/glass/glass_postlist.cc
    index a7f6fa535ee6..774521fd179b 100644
    a b GlassPostList::GlassPostList(intrusive_ptr<const GlassDatabase> this_db_,  
    701701          this_db(keep_reference ? this_db_ : nullptr),
    702702          have_started(false),
    703703          is_at_end(false),
     704          all_docs(term_.empty()),
    704705          cursor(this_db_->postlist_table.cursor_get())
    705706{
    706707    LOGCALL_CTOR(DB, "GlassPostList", this_db_.get() | term_ | keep_reference);
    … … GlassPostList::GlassPostList(intrusive_ptr<const GlassDatabase> this_db_,  
    714715          this_db(this_db_),
    715716          have_started(false),
    716717          is_at_end(false),
     718          all_docs(term_.empty()),
    717719          cursor(cursor_)
    718720{
    719721    LOGCALL_CTOR(DB, "GlassPostList", this_db_.get() | term_ | cursor_);
    … … GlassPostList::next_chunk()  
    814816    const char * keypos = cursor->current_key.data();
    815817    const char * keyend = keypos + cursor->current_key.size();
    816818    // Check we're still in same postlist
    817     if (!check_term_in_key_lite(&keypos, keyend, term)) {
     819    string_view kterm = all_docs ? string_view() : term;
     820    if (!check_term_in_key_lite(&keypos, keyend, kterm)) {
    818821        is_at_end = true;
    819822        throw Xapian::DatabaseCorruptError("Unexpected end of posting list for '" +
    820823                                     term + "'");
    … … void  
    900903GlassPostList::move_to_chunk_containing(Xapian::docid desired_did)
    901904{
    902905    LOGCALL_VOID(DB, "GlassPostList::move_to_chunk_containing", desired_did);
    903     (void)cursor->find_entry(GlassPostListTable::make_key(term, desired_did));
     906    string_view kterm = all_docs ? string_view() : term;
     907    (void)cursor->find_entry(GlassPostListTable::make_key(kterm, desired_did));
    904908    Assert(!cursor->after_end());
    905909
    906910    const char * keypos = cursor->current_key.data();
    907911    const char * keyend = keypos + cursor->current_key.size();
    908912    // Check we're still in same postlist
    909     if (!check_term_in_key_lite(&keypos, keyend, term)) {
     913    if (!check_term_in_key_lite(&keypos, keyend, kterm)) {
    910914        // This should only happen if the postlist doesn't exist at all.
    911915        is_at_end = true;
    912916        is_last_chunk = true;
  • xapian-core/backends/glass/glass_postlist.h

    diff --git a/xapian-core/backends/glass/glass_postlist.h b/xapian-core/backends/glass/glass_postlist.h
    index 2fef145b5266..68f852ba9702 100644
    a b class GlassPostList : public LeafPostList {  
    6969    /// Whether we've run off the end of the list yet.
    7070    bool is_at_end;
    7171
     72    /** Are we iterating all docs?
     73     *
     74     *  This is true for the GlassPostList for the doc lengths.
     75     *
     76     *  We also use it for a term which indexes all the documents if we don't
     77     *  need wdfs.  We call set_term() so can't just use the term name to
     78     *  build keys, etc after construction.
     79     */
     80    bool all_docs = false;
     81
    7282    /// Cursor pointing to current chunk of postlist.
    7383    std::unique_ptr<GlassCursor> cursor;
    7484