agora inbox for pgsql-hackers@postgresql.org  
help / color / mirror / Atom feed
[PATCH v17 1/3] Remember PK oid for partitioned tables even when it's invalid
281+ messages / 2 participants
[nested] [flat]

* [PATCH v17 1/3] Remember PK oid for partitioned tables even when it's invalid
@ 2023-07-12 16:57  Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 281+ messages in thread

From: Alvaro Herrera @ 2023-07-12 16:57 UTC (permalink / raw)

---
 src/backend/utils/cache/relcache.c | 34 ++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 8e08ca1c68..7234cb3da6 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -4789,19 +4789,41 @@ RelationGetIndexList(Relation relation)
 		result = lappend_oid(result, index->indexrelid);
 
 		/*
-		 * Invalid, non-unique, non-immediate or predicate indexes aren't
-		 * interesting for either oid indexes or replication identity indexes,
-		 * so don't check them.
+		 * Non-unique, non-immediate or predicate indexes aren't interesting
+		 * for either oid indexes or replication identity indexes, so don't
+		 * check them.
 		 */
-		if (!index->indisvalid || !index->indisunique ||
+		if (!index->indisunique ||
 			!index->indimmediate ||
 			!heap_attisnull(htup, Anum_pg_index_indpred, NULL))
 			continue;
 
-		/* remember primary key index if any */
-		if (index->indisprimary)
+		/*
+		 * Remember primary key index, if any.  We do this only if the index
+		 * is valid; but if the table is partitioned, then we do it even if
+		 * it's invalid.
+		 *
+		 * The reason for returning invalid primary keys for foreign tables is
+		 * because of pg_dump of NOT NULL constraints, and the fact that PKs
+		 * remain marked invalid until the partitions' PKs are attached to it.
+		 * If we make rd_pkindex invalid, then the attnotnull flag is reset
+		 * after the PK is created, which causes the ALTER INDEX ATTACH
+		 * PARTITION to fail with 'column ... is not marked NOT NULL'.  With
+		 * this, dropconstraint_internal() will believe that the columns must
+		 * not have attnotnull reset, so the PKs-on-partitions can be attached
+		 * correctly, until finally the PK-on-parent is marked valid.
+		 *
+		 * Also, this doesn't harm anything, because rd_pkindex is not a
+		 * "real" index anyway, but a RELKIND_PARTITIONED_INDEX.
+		 */
+		if (index->indisprimary &&
+			(index->indisvalid ||
+			 relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE))
 			pkeyIndex = index->indexrelid;
 
+		if (!index->indisvalid)
+			continue;
+
 		/* remember explicitly chosen replica index */
 		if (index->indisreplident)
 			candidateIndex = index->indexrelid;
-- 
2.39.2


--u5bqxbslpyv5rwih
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v17-0002-Add-pg_constraint-rows-for-NOT-NULL-constraints.patch"



^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 62c905c6e7c..3f3332f9730 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index c9cf08872ac..4c0bac683ea 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread

* [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h
@ 2026-01-10 14:11  reshke <reshke@double.cloud>
  0 siblings, 0 replies; 281+ messages in thread

From: reshke @ 2026-01-10 14:11 UTC (permalink / raw)

Suggested-by: Japin Li <japinli@hotmail.com>, Andrey Borodin <x4mmm@yandex-team.ru>

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/pageinspect/pageinspect.h | 2 ++
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 0585b7cee40..a49a9beee68 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -49,8 +49,7 @@ PG_FUNCTION_INFO_V1(bt_page_stats_1_9);
 PG_FUNCTION_INFO_V1(bt_page_stats);
 PG_FUNCTION_INFO_V1(bt_multi_page_stats);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
+#define IS_BTREE(r) (IS_INDEX(r) && (r)->rd_rel->relam == BTREE_AM_OID)
 
 /* ------------------------------------------------
  * structure for single btree page statistics
@@ -225,7 +224,7 @@ check_relation_block_range(Relation rel, int64 blkno)
 static void
 bt_index_block_validate(Relation rel, int64 blkno)
 {
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
@@ -858,7 +857,7 @@ bt_metap(PG_FUNCTION_ARGS)
 	relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 	rel = relation_openrv(relrv, AccessShareLock);
 
-	if (!IS_INDEX(rel) || !IS_BTREE(rel))
+	if (!IS_BTREE(rel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/ginfuncs.c b/contrib/pageinspect/ginfuncs.c
index f0466bc10c3..d0954312187 100644
--- a/contrib/pageinspect/ginfuncs.c
+++ b/contrib/pageinspect/ginfuncs.c
@@ -30,8 +30,7 @@ PG_FUNCTION_INFO_V1(gin_entrypage_items);
 PG_FUNCTION_INFO_V1(gin_leafpage_items);
 PG_FUNCTION_INFO_V1(gin_datapage_items);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
+#define IS_GIN(r) (IS_INDEX(r) && (r)->rd_rel->relam == GIN_AM_OID)
 
 Datum
 gin_metapage_info(PG_FUNCTION_ARGS)
@@ -212,7 +211,7 @@ gin_entrypage_items(PG_FUNCTION_ARGS)
 	/* Open the index relation */
 	indexRel = index_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_GIN(indexRel))
+	if (!IS_GIN(indexRel))
 		ereport(ERROR,
 				errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 7fc97d043ce..86e73b36b41 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -28,8 +28,7 @@ PG_FUNCTION_INFO_V1(hash_page_items);
 PG_FUNCTION_INFO_V1(hash_bitmap_info);
 PG_FUNCTION_INFO_V1(hash_metapage_info);
 
-#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
-#define IS_HASH(r) ((r)->rd_rel->relam == HASH_AM_OID)
+#define IS_HASH(r) (IS_INDEX(r) && (r)->rd_rel->relam == HASH_AM_OID)
 
 /* ------------------------------------------------
  * structure for single hash page statistics
@@ -421,7 +420,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	 */
 	indexRel = relation_open(indexRelid, AccessShareLock);
 
-	if (!IS_INDEX(indexRel) || !IS_HASH(indexRel))
+	if (!IS_HASH(indexRel))
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("\"%s\" is not a %s index",
diff --git a/contrib/pageinspect/pageinspect.h b/contrib/pageinspect/pageinspect.h
index b241fdc97b2..7e5d28eeb4d 100644
--- a/contrib/pageinspect/pageinspect.h
+++ b/contrib/pageinspect/pageinspect.h
@@ -24,6 +24,8 @@ enum pageinspect_version
 	PAGEINSPECT_V1_9,
 };
 
+#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
+
 /* in rawpage.c */
 extern Page get_page_from_raw(bytea *raw_page);
 
-- 
2.43.0


--=-=-=--





^ permalink  raw  reply  [nested|flat] 281+ messages in thread


end of thread, other threads:[~2026-01-10 14:11 UTC | newest]

Thread overview: 281+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-07-12 16:57 [PATCH v17 1/3] Remember PK oid for partitioned tables even when it's invalid Alvaro Herrera <alvherre@alvh.no-ip.org>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v16 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>
2026-01-10 14:11 [PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h reshke <reshke@double.cloud>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox