From 83f92645ff1f934e7960534c32ad2d67b2f0b910 Mon Sep 17 00:00:00 2001
From: Masahiro Ikeda <ikedamsh@oss.nttdata.com>
Date: Fri, 16 May 2025 14:41:27 +0900
Subject: [PATCH v2 2/2] Fix error message details for partitioned indexes in
 amcheck

Until now, the error detail could be misleading when bt_index_check()
is run on partitioned indexes. For example, the index
"pgbench_accounts_pkey" is both a btree and a partitioned index.

Before this change, the error message was:

> ERROR: expected "btree" index as targets for verification
> DETAIL: Relation "pgbench_accounts_pkey" is a btree index.

This change adds the word "partitioned" to the error detail to avoid
confusion about why the error occurred.

After this change, the error message becomes:

> ERROR: expected "btree" index as targets for verification
> DETAIL: Relation "pgbench_accounts_pkey" is a btree partitioned index.
---
 contrib/amcheck/verify_common.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/contrib/amcheck/verify_common.c b/contrib/amcheck/verify_common.c
index d095e62ce55..b68ddaf895d 100644
--- a/contrib/amcheck/verify_common.c
+++ b/contrib/amcheck/verify_common.c
@@ -169,8 +169,9 @@ index_checkable(Relation rel, Oid am_id)
 		ereport(ERROR,
 				(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
 				 errmsg("expected \"%s\" index as targets for verification", NameStr(((Form_pg_am) GETSTRUCT(amtup))->amname)),
-				 errdetail("Relation \"%s\" is a %s index.",
-						   RelationGetRelationName(rel), NameStr(((Form_pg_am) GETSTRUCT(amtuprel))->amname))));
+				 errdetail("Relation \"%s\" is a %s %sindex.",
+						   RelationGetRelationName(rel), NameStr(((Form_pg_am) GETSTRUCT(amtuprel))->amname),
+						   (rel->rd_rel->relkind == RELKIND_PARTITIONED_INDEX) ? "partitioned " : "")));
 	}
 
 	if (RELATION_IS_OTHER_TEMP(rel))
-- 
2.34.1

