* [PATCH 0/2] Query debug improvements
@ 2012-03-14 2:31 Austin Clements
2012-03-14 2:31 ` [PATCH 1/2] lib: Expose query debug output via an environment variable Austin Clements
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Austin Clements @ 2012-03-14 2:31 UTC (permalink / raw)
To: notmuch
Two simple improvements for query debugging.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] lib: Expose query debug output via an environment variable
2012-03-14 2:31 [PATCH 0/2] Query debug improvements Austin Clements
@ 2012-03-14 2:31 ` Austin Clements
2012-03-14 2:31 ` [PATCH 2/2] lib: Add exclude query debug output Austin Clements
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Austin Clements @ 2012-03-14 2:31 UTC (permalink / raw)
To: notmuch
Allow query debugging to be enabled at run-time by setting the
NOTMUCH_DEBUG_QUERY environment variable to a non-empty string.
Previously, enabling query debugging required recompiling, but parsed
queries are often useful for tracking down bugs in situations where
recompiling is inconvenient.
---
lib/query.cc | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/lib/query.cc b/lib/query.cc
index ab18fbc..1e5e99a 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -64,15 +64,21 @@ _notmuch_doc_id_set_init (void *ctx,
notmuch_doc_id_set_t *doc_ids,
GArray *arr);
+static notmuch_bool_t
+_debug_query (void)
+{
+ char *env = getenv ("NOTMUCH_DEBUG_QUERY");
+ return (env && strcmp (env, "") != 0);
+}
+
notmuch_query_t *
notmuch_query_create (notmuch_database_t *notmuch,
const char *query_string)
{
notmuch_query_t *query;
-#ifdef DEBUG_QUERY
- fprintf (stderr, "Query string is:\n%s\n", query_string);
-#endif
+ if (_debug_query ())
+ fprintf (stderr, "Query string is:\n%s\n", query_string);
query = talloc (NULL, notmuch_query_t);
if (unlikely (query == NULL))
@@ -255,9 +261,9 @@ notmuch_query_search_messages (notmuch_query_t *query)
break;
}
-#if DEBUG_QUERY
- fprintf (stderr, "Final query is:\n%s\n", final_query.get_description().c_str());
-#endif
+ if (_debug_query ())
+ fprintf (stderr, "Final query is:\n%s\n",
+ final_query.get_description ().c_str ());
enquire.set_query (final_query);
@@ -531,9 +537,9 @@ notmuch_query_count_messages (notmuch_query_t *query)
enquire.set_weighting_scheme(Xapian::BoolWeight());
enquire.set_docid_order(Xapian::Enquire::ASCENDING);
-#if DEBUG_QUERY
- fprintf (stderr, "Final query is:\n%s\n", final_query.get_description().c_str());
-#endif
+ if (_debug_query ())
+ fprintf (stderr, "Final query is:\n%s\n",
+ final_query.get_description ().c_str ());
enquire.set_query (final_query);
--
1.7.7.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] lib: Add exclude query debug output
2012-03-14 2:31 [PATCH 0/2] Query debug improvements Austin Clements
2012-03-14 2:31 ` [PATCH 1/2] lib: Expose query debug output via an environment variable Austin Clements
@ 2012-03-14 2:31 ` Austin Clements
2012-03-17 6:02 ` [PATCH 0/2] Query debug improvements Jameson Graef Rollins
2012-03-18 12:48 ` David Bremner
3 siblings, 0 replies; 5+ messages in thread
From: Austin Clements @ 2012-03-14 2:31 UTC (permalink / raw)
To: notmuch
---
lib/query.cc | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/query.cc b/lib/query.cc
index 1e5e99a..53d505a 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -261,9 +261,12 @@ notmuch_query_search_messages (notmuch_query_t *query)
break;
}
- if (_debug_query ())
+ if (_debug_query ()) {
+ fprintf (stderr, "Exclude query is:\n%s\n",
+ exclude_query.get_description ().c_str ());
fprintf (stderr, "Final query is:\n%s\n",
final_query.get_description ().c_str ());
+ }
enquire.set_query (final_query);
@@ -537,9 +540,12 @@ notmuch_query_count_messages (notmuch_query_t *query)
enquire.set_weighting_scheme(Xapian::BoolWeight());
enquire.set_docid_order(Xapian::Enquire::ASCENDING);
- if (_debug_query ())
+ if (_debug_query ()) {
+ fprintf (stderr, "Exclude query is:\n%s\n",
+ exclude_query.get_description ().c_str ());
fprintf (stderr, "Final query is:\n%s\n",
final_query.get_description ().c_str ());
+ }
enquire.set_query (final_query);
--
1.7.7.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] Query debug improvements
2012-03-14 2:31 [PATCH 0/2] Query debug improvements Austin Clements
2012-03-14 2:31 ` [PATCH 1/2] lib: Expose query debug output via an environment variable Austin Clements
2012-03-14 2:31 ` [PATCH 2/2] lib: Add exclude query debug output Austin Clements
@ 2012-03-17 6:02 ` Jameson Graef Rollins
2012-03-18 12:48 ` David Bremner
3 siblings, 0 replies; 5+ messages in thread
From: Jameson Graef Rollins @ 2012-03-17 6:02 UTC (permalink / raw)
To: Austin Clements, notmuch
[-- Attachment #1: Type: text/plain, Size: 231 bytes --]
On Tue, 13 Mar 2012 22:31:29 -0400, Austin Clements <amdragon@MIT.EDU> wrote:
> Two simple improvements for query debugging.
Awesome. These are both great, and I wholeheartedly support easier
on-the-fly debugging. LGTM.
jamie.
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] Query debug improvements
2012-03-14 2:31 [PATCH 0/2] Query debug improvements Austin Clements
` (2 preceding siblings ...)
2012-03-17 6:02 ` [PATCH 0/2] Query debug improvements Jameson Graef Rollins
@ 2012-03-18 12:48 ` David Bremner
3 siblings, 0 replies; 5+ messages in thread
From: David Bremner @ 2012-03-18 12:48 UTC (permalink / raw)
To: Austin Clements, notmuch
On Tue, 13 Mar 2012 22:31:29 -0400, Austin Clements <amdragon@MIT.EDU> wrote:
> Two simple improvements for query debugging.
>
pushed,
d
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-03-18 12:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-14 2:31 [PATCH 0/2] Query debug improvements Austin Clements
2012-03-14 2:31 ` [PATCH 1/2] lib: Expose query debug output via an environment variable Austin Clements
2012-03-14 2:31 ` [PATCH 2/2] lib: Add exclude query debug output Austin Clements
2012-03-17 6:02 ` [PATCH 0/2] Query debug improvements Jameson Graef Rollins
2012-03-18 12:48 ` David Bremner
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).