v20-0003-TEST-Stop-requiring-BTREE_AM_OID-from-within-btr.patch.no-cfbot

application/octet-stream

Filename: v20-0003-TEST-Stop-requiring-BTREE_AM_OID-from-within-btr.patch.no-cfbot
Type: application/octet-stream
Part: 0
Message: Re: Remove extra Sort node above a btree-compatible Index Scan
From bc4f2e01f6e420f04dae817374e547afa600e884 Mon Sep 17 00:00:00 2001
From: Andrew Dunstan <andrew@dunslane.net>
Date: Mon, 25 Nov 2024 15:40:28 -0500
Subject: [PATCH v20 03/16] [TEST] Stop requiring BTREE_AM_OID from within
 btree code

Checking from within btree code that the index AM is btree, either
with Assert or with if/then/elog, makes that code nonreusable by
other indexes, such as that recently added to
src/test/modules/xtree.  Remove those checks.
---
 src/backend/utils/sort/sortsupport.c       | 2 --
 src/backend/utils/sort/tuplesortvariants.c | 2 --
 src/include/access/nbtree.h                | 6 ++----
 3 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/backend/utils/sort/sortsupport.c b/src/backend/utils/sort/sortsupport.c
index 6037031eaa3..9b855be690e 100644
--- a/src/backend/utils/sort/sortsupport.c
+++ b/src/backend/utils/sort/sortsupport.c
@@ -166,8 +166,6 @@ PrepareSortSupportFromIndexRel(Relation indexRel, int16 strategy,
 
 	Assert(ssup->comparator == NULL);
 
-	if (indexRel->rd_rel->relam != BTREE_AM_OID)
-		elog(ERROR, "unexpected non-btree AM: %u", indexRel->rd_rel->relam);
 	if (strategy != BTGreaterStrategyNumber &&
 		strategy != BTLessStrategyNumber)
 		elog(ERROR, "unexpected sort support strategy: %d", strategy);
diff --git a/src/backend/utils/sort/tuplesortvariants.c b/src/backend/utils/sort/tuplesortvariants.c
index 913c4ef455e..617ff0da9af 100644
--- a/src/backend/utils/sort/tuplesortvariants.c
+++ b/src/backend/utils/sort/tuplesortvariants.c
@@ -251,8 +251,6 @@ tuplesort_begin_cluster(TupleDesc tupDesc,
 	TuplesortClusterArg *arg;
 	int			i;
 
-	Assert(indexRel->rd_rel->relam == BTREE_AM_OID);
-
 	oldcontext = MemoryContextSwitchTo(base->maincontext);
 	arg = (TuplesortClusterArg *) palloc0(sizeof(TuplesortClusterArg));
 
diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h
index e4fdeca3402..e26399ce238 100644
--- a/src/include/access/nbtree.h
+++ b/src/include/access/nbtree.h
@@ -1131,16 +1131,14 @@ typedef struct BTOptions
 } BTOptions;
 
 #define BTGetFillFactor(relation) \
-	(AssertMacro(relation->rd_rel->relkind == RELKIND_INDEX && \
-				 relation->rd_rel->relam == BTREE_AM_OID), \
+	(AssertMacro(relation->rd_rel->relkind == RELKIND_INDEX), \
 	 (relation)->rd_options ? \
 	 ((BTOptions *) (relation)->rd_options)->fillfactor : \
 	 BTREE_DEFAULT_FILLFACTOR)
 #define BTGetTargetPageFreeSpace(relation) \
 	(BLCKSZ * (100 - BTGetFillFactor(relation)) / 100)
 #define BTGetDeduplicateItems(relation) \
-	(AssertMacro(relation->rd_rel->relkind == RELKIND_INDEX && \
-				 relation->rd_rel->relam == BTREE_AM_OID), \
+	(AssertMacro(relation->rd_rel->relkind == RELKIND_INDEX), \
 	((relation)->rd_options ? \
 	 ((BTOptions *) (relation)->rd_options)->deduplicate_items : true))
 
-- 
2.48.1