v4-0004-Cleanup-includes-in-pg_get_dsm_registry_allocatio.patch

application/octet-stream

Filename: v4-0004-Cleanup-includes-in-pg_get_dsm_registry_allocatio.patch
Type: application/octet-stream
Part: 3
Message: Re: like pg_shmem_allocations, but fine-grained for DSM registry ?
From 502455e799005dea5f9fab28bcc3f0f33e776b65 Mon Sep 17 00:00:00 2001
From: Florents Tselai <florents.tselai@gmail.com>
Date: Tue, 3 Jun 2025 23:06:15 +0300
Subject: [PATCH v4 4/4] Cleanup includes in pg_get_dsm_registry_allocations;
 remove unused headers and alphabetize. Add entry in System View overview

---
 doc/src/sgml/system-views.sgml         |  5 +++++
 src/backend/storage/ipc/dsm_registry.c | 15 ++-------------
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/doc/src/sgml/system-views.sgml b/doc/src/sgml/system-views.sgml
index 2d55671f5fa..e41a7b5745f 100644
--- a/doc/src/sgml/system-views.sgml
+++ b/doc/src/sgml/system-views.sgml
@@ -186,6 +186,11 @@
       <entry>NUMA node mappings for shared memory allocations</entry>
      </row>
 
+     <row>
+      <entry><link linkend="view-pg-dsm-registry-allocations"><structname>pg_dsm_registry_allocations</structname></link></entry>
+      <entry>DSM segment allocations registered via the DSM registry</entry>
+     </row>
+
      <row>
       <entry><link linkend="view-pg-stats"><structname>pg_stats</structname></link></entry>
       <entry>planner statistics</entry>
diff --git a/src/backend/storage/ipc/dsm_registry.c b/src/backend/storage/ipc/dsm_registry.c
index 33e3d9ba3f0..0650c70e173 100644
--- a/src/backend/storage/ipc/dsm_registry.c
+++ b/src/backend/storage/ipc/dsm_registry.c
@@ -26,15 +26,13 @@
 
 #include "postgres.h"
 
+#include "funcapi.h"
 #include "lib/dshash.h"
 #include "storage/dsm_registry.h"
 #include "storage/lwlock.h"
 #include "storage/shmem.h"
-#include "utils/memutils.h"
-#include "fmgr.h"
-#include "funcapi.h"
-#include "miscadmin.h"
 #include "utils/builtins.h"
+#include "utils/memutils.h"
 
 typedef struct DSMRegistryCtxStruct
 {
@@ -203,12 +201,6 @@ GetNamedDSMSegment(const char *name, size_t size,
 	return ret;
 }
 
-typedef struct
-{
-	Tuplestorestate *tupstore;
-	TupleDesc        tupdesc;
-} DSMRegistrySRFContext;
-
 Datum
 pg_get_dsm_registry_allocations(PG_FUNCTION_ARGS)
 {
@@ -216,9 +208,6 @@ pg_get_dsm_registry_allocations(PG_FUNCTION_ARGS)
 	DSMRegistryEntry *entry;
 	dshash_seq_status status;
 
-	if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
-		ereport(ERROR, (errmsg("pg_get_dsm_registry_allocations must be used in a SRF context")));
-
 	InitMaterializedSRF(fcinfo, MAT_SRF_USE_EXPECTED_DESC);
 
 	/* Ensure DSM registry initialized */
-- 
2.49.0