From: Carl Worth Date: Mon, 21 Dec 2009 23:11:32 +0000 (-0800) Subject: database: Make find_unique_doc_id enforce uniqueness (for a debug build) X-Git-Tag: 0.1~189 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d7e5f5827e21be7dd8993e5a877bdb73cdb64325;p=notmuch.git database: Make find_unique_doc_id enforce uniqueness (for a debug build) Catching any violation of this unique-ness constraint is very much in line with similar, existing INTERNAL_ERROR cases. --- diff --git a/lib/database.cc b/lib/database.cc index 3ed19772..5d300732 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -246,10 +246,19 @@ find_unique_doc_id (notmuch_database_t *notmuch, 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