}
}
+static void
+find_doc_ids_for_term (notmuch_database_t *notmuch,
+ const char *term,
+ Xapian::PostingIterator *begin,
+ Xapian::PostingIterator *end)
+{
+ *begin = notmuch->xapian_db->postlist_begin (term);
+
+ *end = notmuch->xapian_db->postlist_end (term);
+}
+
static void
find_doc_ids (notmuch_database_t *notmuch,
const char *prefix_name,
Xapian::PostingIterator *begin,
Xapian::PostingIterator *end)
{
- Xapian::PostingIterator i;
char *term;
term = talloc_asprintf (notmuch, "%s%s",
_find_prefix (prefix_name), value);
- *begin = notmuch->xapian_db->postlist_begin (term);
-
- *end = notmuch->xapian_db->postlist_end (term);
+ find_doc_ids_for_term (notmuch, term, begin, end);
talloc_free (term);
}
if (i == end) {
*doc_id = 0;
return NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND;
- } else {
- *doc_id = *i;
- return NOTMUCH_PRIVATE_STATUS_SUCCESS;
}
+
+ *doc_id = *i;
+
+#if DEBUG_DATABASE_SANITY
+ i++;
+
+ if (i != end)
+ INTERNAL_ERROR ("Term %s:%s is not unique as expected.\n",
+ prefix_name, value);
+#endif
+
+ return NOTMUCH_PRIVATE_STATUS_SUCCESS;
}
static Xapian::Document