Re: [PATCH v2 2/3] lib: Add support for automatically excluding tags from queries
authorAustin Clements <amdragon@MIT.EDU>
Sun, 15 Jan 2012 00:05:31 +0000 (19:05 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:42:10 +0000 (09:42 -0800)
f9/09bd86b8150b7f137337b0a992995081ce5866 [new file with mode: 0644]

diff --git a/f9/09bd86b8150b7f137337b0a992995081ce5866 b/f9/09bd86b8150b7f137337b0a992995081ce5866
new file mode 100644 (file)
index 0000000..0e5312c
--- /dev/null
@@ -0,0 +1,142 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 613AC421191\r
+       for <notmuch@notmuchmail.org>; Sat, 14 Jan 2012 16:05:37 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 0S5G8lKSaSED for <notmuch@notmuchmail.org>;\r
+       Sat, 14 Jan 2012 16:05:36 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU\r
+       [18.7.68.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id C1149421176\r
+       for <notmuch@notmuchmail.org>; Sat, 14 Jan 2012 16:05:36 -0800 (PST)\r
+X-AuditID: 12074422-b7fd66d0000008f9-8f-4f1218502875\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+       by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id E6.53.02297.058121F4; Sat, 14 Jan 2012 19:05:36 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q0F05aJc020421; \r
+       Sat, 14 Jan 2012 19:05:36 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0F05YLH026525\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Sat, 14 Jan 2012 19:05:35 -0500 (EST)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amdragon@MIT.EDU>)\r
+       id 1RmDbH-0002Id-Iv; Sat, 14 Jan 2012 19:05:31 -0500\r
+Date: Sat, 14 Jan 2012 19:05:31 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Jameson Graef Rollins <jrollins@finestructure.net>\r
+Subject: Re: [PATCH v2 2/3] lib: Add support for automatically excluding tags\r
+       from queries\r
+Message-ID: <20120115000531.GF1801@mit.edu>\r
+References: <1326258173-21163-1-git-send-email-amdragon@mit.edu>\r
+       <1326496024-14403-1-git-send-email-amdragon@mit.edu>\r
+       <1326496024-14403-3-git-send-email-amdragon@mit.edu>\r
+       <87zkdpsvln.fsf@servo.finestructure.net>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Disposition: inline\r
+Content-Transfer-Encoding: 8bit\r
+In-Reply-To: <87zkdpsvln.fsf@servo.finestructure.net>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFlrHKsWRmVeSWpSXmKPExsUixG6nohsgIeRv8PyrpEXTdGeLPfu8LK7f\r
+       nMnswOxx9zSXx637r9k9nq26xRzAHMVlk5Kak1mWWqRvl8CV8f74G5aCCWIV718cYG1gfCbY\r
+       xcjJISFgIrF86gt2CFtM4sK99WxdjFwcQgL7GCUmr1zACOFsYJQ48PIFC0iVkMBJJon9t+Mh\r
+       EkuAEmvXMIIkWARUJTZ1vGICsdkENCS27V8OFhcRMJPo+fIHzGYW0JF4ffg90CAODmGBGIlT\r
+       b4VAwrwC2hKLp19kh5h5k1Hi5qaZjBAJQYmTM5+wQPSqS/yZd4kZpJdZQFpi+T8OiLC8RPPW\r
+       2cwgNqeAqcSlp/vZQGxRARWJKSe3sU1gFJ6FZNIsJJNmIUyahWTSAkaWVYyyKblVurmJmTnF\r
+       qcm6xcmJeXmpRbqmermZJXqpKaWbGMFR4aK0g/HnQaVDjAIcjEo8vIU5Av5CrIllxZW5hxgl\r
+       OZiURHnXigv5C/El5adUZiQWZ8QXleakFh9ilOBgVhLhXcAKlONNSaysSi3Kh0lJc7AoifOq\r
+       a73zExJITyxJzU5NLUgtgsnKcHAoSfC+BhkqWJSanlqRlplTgpBm4uAEGc4DNPwZSA1vcUFi\r
+       bnFmOkT+FKMux8m1V84xCrHk5eelSonz7gIpEgApyijNg5sDS2avGMWB3hLmXQdSxQNMhHCT\r
+       XgEtYQJaUpbCB7KkJBEhJdXAuGLXL27TEK/Jjt1FUSd+qB5gfPRE96PiejFdoTJO66BFd7hP\r
+       rWB+yPZj39Me7YT0SGXWDzqmniw/1m0N1I36U/zrlqPIt2m6wkFPmMr637DOS9BxFOVTmuYd\r
+       0V6iHmy0oHRZc6ztlqSsuB0aj1bqatovsVxpmRgiLhb+8Ostp5Cw5XM1JZiUWIozEg21mIuK\r
+       EwFJWWkXQQMAAA==\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 15 Jan 2012 00:05:37 -0000\r
+\r
+Quoth Jameson Graef Rollins on Jan 14 at  3:38 pm:\r
+> It looks like something in this patch is causing the following build\r
+> warning:\r
+> \r
+> CXX -O2 lib/query.o\r
+> lib/query.cc:26:8: warning: ‘_notmuch_query’ declared with greater visibility than the type of its field\r
+> ‘_notmuch_query::exclude_terms’ [-Wattributes]\r
+> \r
+> However, I can't quite figure out what's causing it.\r
+\r
+The problem is that notmuch_query_t is a "visible" symbol because the\r
+type is declared (though not defined) in lib/notmuch.h.  The actual\r
+definition is tucked away in lib/query.cc, but GCC doesn't seem to\r
+care.  I added a field of type notmuch_string_list_t to the struct's\r
+definition, but notmuch_string_list_t is declared between the "hidden"\r
+pragmas in lib/notmuch-private.h because the type is private to the\r
+library.  This field with a hidden type in a visible type is what GCC\r
+is complaining about.\r
+\r
+I'm rather confused by the whole type visibility thing since type\r
+symbols aren't linkable anyway.  However, while puzzling over how you\r
+could possibly use hidden types if they can only be used in other\r
+hidden types, I discovered that Carl had solved this exact problem\r
+last May in d5523ead by adding a visibility("default") attribute to\r
+the offending hidden type.\r
+\r
+> > +void\r
+> > +notmuch_query_add_tag_exclude (notmuch_query_t *query, const char *tag)\r
+> > +{\r
+> > +    char *term = talloc_asprintf (query, "%s%s", _find_prefix ("tag"), tag);\r
+> > +    _notmuch_string_list_append (query->exclude_terms, term);\r
+> > +}\r
+> \r
+> This is really not an issue with this patch at all, and it should NOT\r
+> prevent it from being applied, but this came up briefly on IRC and I'm\r
+> curious, so I'll ask about it here.\r
+> \r
+> Are terms ALWAYS lower cased?  If not, it seems to me it's possible to\r
+> have an indexed term 'Kspam' that would get confused with the term\r
+> 'spam' prefixed with the keyword prefix 'K' (which we use for tags).\r
+> Maybe this degeneracy is broken by the query parser somehow (or maybe by\r
+> the fact that tags are boolean terms?), but I wonder if it's not safer\r
+> to use the built-in xapian prefix separator ':', ie:\r
+> \r
+>   ... talloc_asprintf (query, "%s:%s", _find_prefix ("tag"), tag);\r
+> \r
+> I guess fixing that globally would require a database rebuild...\r
+\r
+We discussed this on IRC, but to summarize for the list, the tag\r
+prefix is a single character, so Xapian's ':' rule doesn't apply.\r
+There are several places where we *do* get this wrong and use a\r
+multi-character term prefix with a term that may start with a capital\r
+letter but they're all terms you can't search anyway and, unless I'm\r
+mistaken, we're completely consistent about where we violate or do not\r
+violate the ':' rule.\r
+\r
+> Ok, that's totally just an aside, and should not be a blocker for this\r
+> patch.\r
+> \r
+> jamie.\r