]> git.notmuchmail.org Git - notmuch/commitdiff
Add debugging code for examining query strings.
authorCarl Worth <cworth@cworth.org>
Sun, 25 Oct 2009 05:18:20 +0000 (22:18 -0700)
committerCarl Worth <cworth@cworth.org>
Sun, 25 Oct 2009 05:18:20 +0000 (22:18 -0700)
It's nice that Xapian provides a little function to print a textual
representation of the entire query tree. So now, if you compile
like so:

make CFLAGS=-DDEBUG_QUERY

then you get a nice output of the query string received by the query
module, and the final query actually being sent to Xapian.

Makefile
query.cc

index 13f2b28d3f4a2081f4fd1b2075ec5ad1fbea3290..1737a32e61dee659c9568e657e7c33577f06166b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@ MODULES=              \
 all: $(PROGS)
 
 %.o: %.cc
 all: $(PROGS)
 
 %.o: %.cc
-       $(CXX) -c $(CXXFLAGS) $(MYCXXFLAGS) $< -o $@
+       $(CXX) -c $(CFLAGS) $(CXXFLAGS) $(MYCXXFLAGS) $< -o $@
 
 %.o: %.c
        $(CC) -c $(CFLAGS) $(MYCFLAGS) $< -o $@
 
 %.o: %.c
        $(CC) -c $(CFLAGS) $(MYCFLAGS) $< -o $@
index a15de9664a5ac4b8d15f5e567f873364a39d2f9a..f66ee55649767639006fade6c22a6e963848adb7 100644 (file)
--- a/query.cc
+++ b/query.cc
@@ -41,6 +41,10 @@ notmuch_query_create (notmuch_database_t *notmuch,
 {
     notmuch_query_t *query;
 
 {
     notmuch_query_t *query;
 
+#ifdef DEBUG_QUERY
+    fprintf (stderr, "Query string is:\n%s\n", query_string);
+#endif
+
     query = talloc (NULL, notmuch_query_t);
     if (unlikely (query == NULL))
        return NULL;
     query = talloc (NULL, notmuch_query_t);
     if (unlikely (query == NULL))
        return NULL;
@@ -118,6 +122,10 @@ notmuch_query_search (notmuch_query_t *query)
            break;
        }
 
            break;
        }
 
+#if DEBUG_QUERY
+       fprintf (stderr, "Final query is:\n%s\n", final_query.get_description().c_str());
+#endif
+
        enquire.set_query (final_query);
 
        mset = enquire.get_mset (0, notmuch->xapian_db->get_doccount ());
        enquire.set_query (final_query);
 
        mset = enquire.get_mset (0, notmuch->xapian_db->get_doccount ());