Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 7D8A1B5DBE7 for ; Tue, 5 Jul 2011 14:24:18 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 99117-01 for ; Tue, 5 Jul 2011 17:24:12 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-iw0-f174.google.com (mail-iw0-f174.google.com [209.85.214.174]) by mail.postgresql.org (Postfix) with ESMTP id 3B631B5DBDC for ; Tue, 5 Jul 2011 14:24:12 -0300 (ADT) Received: by iwn6 with SMTP id 6so5377022iwn.19 for ; Tue, 05 Jul 2011 10:24:11 -0700 (PDT) Received: by 10.42.157.68 with SMTP id c4mr7511617icx.295.1309886651635; Tue, 05 Jul 2011 10:24:11 -0700 (PDT) Received: from [192.168.1.101] (c-69-181-249-16.hsd1.ca.comcast.net [69.181.249.16]) by mx.google.com with ESMTPS id x13sm4344479ibh.16.2011.07.05.10.24.09 (version=SSLv3 cipher=OTHER); Tue, 05 Jul 2011 10:24:10 -0700 (PDT) Subject: Re: Re: PG regression with row comparison when btree_gist is enabled (BUG) From: Jeff Davis To: Tom Lane Cc: oleg@sai.msu.su, Denis de Bernardy , Teodor Sigaev , pgsql-bugs@postgresql.org In-Reply-To: <21086.1309646333@sss.pgh.pa.us> References: <4DF81BA0.3000601@archidevsys.co.nz> <743036.48052.qm@web112401.mail.gq1.yahoo.com> <366790.65150.qm@web112414.mail.gq1.yahoo.com> <1308428403.2597.66.camel@jdavis> <1308504190.2597.71.camel@jdavis> <21086.1309646333@sss.pgh.pa.us> Content-Type: text/plain; charset="UTF-8" Date: Tue, 05 Jul 2011 10:24:16 -0700 Message-ID: <1309886656.3012.83.camel@jdavis> Mime-Version: 1.0 X-Mailer: Evolution 2.32.2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201107/40 X-Sequence-Number: 30652 On Sat, 2011-07-02 at 18:38 -0400, Tom Lane wrote: > Jeff Davis writes: > > On Sat, 2011-06-18 at 13:20 -0700, Jeff Davis wrote: > >> Interesting problem... the bug is in get_op_btree_interpretation() which > >> has code like this: > >> ... > >> However, that's a bogus test, because btree_gist puts <> into an > >> opfamily. Thus, catlist->n_members == 1 even though we really do need to > >> look for the negator. Really, we need to unconditionally search for the > >> operator as well as unconditionally searching for the negator. > > > Patch attached. > > I looked at this a bit. The proposed patch is inadequate, aside from > any excess lookups it introduces, because there is similar logic in > predtest.c. To make the world safe for btree_gist to do this, we'd have > to add extra lookup activity there as well. > > Quite honestly, I think that the bug is that btree_gist took it upon > itself to invent <> as an indexable operator. The odds that that will > ever be of practical use seem negligible, and not at all adequate to > warrant adding extra cycles into mainstream code paths. It's not too > late to rip that out of 9.1, and that's what I think we should do. I think that ripping out the change to btree_gist is also insufficient; we would also have to prevent other extensions from doing the same. That means documenting an odd special case, and testing for it when defining an opclass. And then we'd probably have to backpatch this kludge. Something simpler seems possible here. The root of the problem is that we're being fooled by GiST opclasses when all we care about are BTree opclasses anyway. A simple fix would be to introduce a flag "found_btree_op". If we hit any BTree entries from pg_amop at all, then we're done after the loop is done. If not, then we negate the op and loop again. Would that be acceptable? Regards, Jeff Davis