agora inbox for pgsql-hackers@postgresql.org  
help / color / mirror / Atom feed
[PATCH v15 3/3] Move IS_INDEX macro to pageinspect.h
282+ messages / 1 participants
[nested] [flat]

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

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ 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; 282+ messages in thread

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

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

Discussion: https://postgr.es/m/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com
---
 contrib/pageinspect/btreefuncs.c  | 7 +++----
 contrib/pageinspect/ginfuncs.c    | 5 ++---
 contrib/pageinspect/hashfuncs.c   | 5 ++---
 contrib/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] 282+ messages in thread


end of thread, other threads:[~2026-01-10 14:11 UTC | newest]

Thread overview: 282+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox