From ef7f64323d326aa54dcc4b0f25ac47242e11def9 Mon Sep 17 00:00:00 2001
From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Date: Fri, 19 Dec 2025 04:08:33 +0000
Subject: [PATCH v2] Use relation_close() more consistently

All the code paths updated here have been using index_close() to
close a relation that has already been opened with relation_open().

index_close() does the same thing as relation_close(), so there was no harm, but
being inconsistent could lead to issues if the internals of these close() functions
begin to introduce specific logic in the future.

Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/aUKamYGiDKO6byp5@ip-10-97-1-34.eu-west-3.compute.internal
---
 contrib/pageinspect/hashfuncs.c   | 2 +-
 contrib/pgstattuple/pgstatindex.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
  53.1% contrib/pageinspect/
  46.8% contrib/pgstattuple/

diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 0e898889fa5..d3066eac81f 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -486,7 +486,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 	bit = ISSET(freep, bitmapbit) != 0;
 
 	_hash_relbuf(indexRel, mapbuf);
-	index_close(indexRel, AccessShareLock);
+	relation_close(indexRel, AccessShareLock);
 
 	/* Build a tuple descriptor for our result type */
 	if (get_call_result_type(fcinfo, NULL, &tupleDesc) != TYPEFUNC_COMPOSITE)
diff --git a/contrib/pgstattuple/pgstatindex.c b/contrib/pgstattuple/pgstatindex.c
index 40823d54fca..f4bee79a216 100644
--- a/contrib/pgstattuple/pgstatindex.c
+++ b/contrib/pgstattuple/pgstatindex.c
@@ -691,7 +691,7 @@ pgstathashindex(PG_FUNCTION_ARGS)
 	}
 
 	/* Done accessing the index */
-	index_close(rel, AccessShareLock);
+	relation_close(rel, AccessShareLock);
 
 	/* Count unused pages as free space. */
 	stats.free_space += (uint64) stats.unused_pages * stats.space_per_page;
-- 
2.34.1

