Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tngkb-000JZg-DK for pgsql-committers@arkaria.postgresql.org; Thu, 27 Feb 2025 16:28:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tngje-0005Xb-7i for pgsql-committers@arkaria.postgresql.org; Thu, 27 Feb 2025 16:27:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tngje-0005XT-0n for pgsql-committers@lists.postgresql.org; Thu, 27 Feb 2025 16:27:40 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tngjY-0000rD-35 for pgsql-committers@lists.postgresql.org; Thu, 27 Feb 2025 16:27:40 +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 51RGRXEv2557075; Thu, 27 Feb 2025 11:27:33 -0500 From: Tom Lane To: Peter Eisentraut cc: pgsql-committers@lists.postgresql.org, Mark Dilger Subject: Re: pgsql: Generalize hash and ordering support in amapi In-reply-to: References: Comments: In-reply-to Peter Eisentraut message dated "Thu, 27 Feb 2025 16:15:46 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2557073.1740673653.1@sss.pgh.pa.us> Date: Thu, 27 Feb 2025 11:27:33 -0500 Message-ID: <2557074.1740673653@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Eisentraut writes: > Generalize hash and ordering support in amapi > Stop comparing access method OID values against HASH_AM_OID and > BTREE_AM_OID, and instead check the IndexAmRoutine for an index to see > if it advertises its ability to perform the necessary ordering, > hashing, or cross-type comparing functionality. A field amcanorder > already existed, this uses it more widely. Fields amcanhash and > amcancrosscompare are added for the other purposes. AFAICS, this patch sets amcancrosscompare true only for btree, which means this change to equality_ops_are_compatible is surely wrong: - /* must be btree or hash */ - if (op_form->amopmethod == BTREE_AM_OID || - op_form->amopmethod == HASH_AM_OID) + if (amroutine->amcancrosscompare) More generally, I think that "amcancrosscompare" is a horribly underspecified and misleadingly-named concept. Most of our AMs are capable of supporting cross-type operators, though for some it's more about what the per-opclass infrastructure can do than what the AM does. So what does that flag *really* mean? I also object strongly to the fact that the comments for equality_ops_are_compatible and comparison_ops_are_compatible were not modified: * This is trivially true if they are the same operator. Otherwise, * we look to see if they can be found in the same btree or hash opfamily. * This is trivially true if they are the same operator. Otherwise, * we look to see if they can be found in the same btree opfamily. I do not think this was in shape to be committed. For stuff like this, clarity of thought and precision of specification are critical, and this patch has neither. regards, tom lane