Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oO8PV-0007PR-Rb for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Aug 2022 02:03:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oO8PU-0003Qs-LY for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Aug 2022 02:03:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oO8PU-0003QV-C0 for pgsql-hackers@lists.postgresql.org; Wed, 17 Aug 2022 02:03:56 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oO8PS-0007Rp-5n for pgsql-hackers@postgresql.org; Wed, 17 Aug 2022 02:03:55 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 27H23rSo1606487; Tue, 16 Aug 2022 22:03:53 -0400 From: Tom Lane To: Quan Zongliang cc: pgsql-hackers Subject: Re: Bug: When user-defined AM is used, the index path cannot be selected correctly In-reply-to: References: Comments: In-reply-to Quan Zongliang message dated "Wed, 17 Aug 2022 09:43:54 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1606485.1660701833.1@sss.pgh.pa.us> Date: Tue, 16 Aug 2022 22:03:53 -0400 Message-ID: <1606486.1660701833@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Quan Zongliang writes: > 1. When using extended PGroonga > ... > 3. Neither ID = 'f' nor id= 't' can use the index correctly. This works fine for btree indexes. I think the actual problem is that IsBooleanOpfamily only accepts the btree and hash opclasses, and that's what needs to be improved. Your proposed patch fails to do that, which makes it just a crude hack that solves some aspects of the issue (and probably breaks other things). It might work to change IsBooleanOpfamily so that it checks to see whether BooleanEqualOperator is a member of the opclass. That's basically what we need to know before we dare generate substitute index clauses. It's kind of an expensive test though, and the existing coding assumes that IsBooleanOpfamily is cheap ... regards, tom lane