0011-Fix-compilation-failure-in-pg_get_shmem_all-20250610.patch

text/x-patch

Filename: 0011-Fix-compilation-failure-in-pg_get_shmem_all-20250610.patch
Type: text/x-patch
Part: 11
Message: Re: Changing shared_buffers without restart

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch 0011
Subject: Fix compilation failure in pg_get_shmem_allocations_numa()
File+
src/backend/storage/ipc/shmem.c 6 1
From f079821259a3841637b794d2d8ad1153e14eb4b3 Mon Sep 17 00:00:00 2001
From: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Date: Thu, 5 Jun 2025 11:34:12 +0530
Subject: [PATCH 11/17] Fix compilation failure in
 pg_get_shmem_allocations_numa()

The compilation failure is caused by
5cefa489760e34d947dbe67b4a922468b2e43668. Ideal fix should be compute
the total page count across all the shared memory segments. This commit
just fixes the compilation failure.  # Please enter the commit message
for your changes. Lines starting

Ashutosh Bapat
---
 src/backend/storage/ipc/shmem.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c
index c07572d6f89..b411fbce37e 100644
--- a/src/backend/storage/ipc/shmem.c
+++ b/src/backend/storage/ipc/shmem.c
@@ -696,7 +696,12 @@ pg_get_shmem_allocations_numa(PG_FUNCTION_ARGS)
 	 * this is not very likely, and moreover we have more entries, each of
 	 * them using only fraction of the total pages.
 	 */
-	shm_total_page_count = (ShmemSegHdr->totalsize / os_page_size) + 1;
+	/*
+	 * TODO: We should loop through all the Shm segments, instead of just the
+	 * main segment, to find the total page count.
+	 */
+	shm_total_page_count = (Segments[MAIN_SHMEM_SEGMENT].ShmemSegHdr->totalsize
+	/ os_page_size) + 1;
 	page_ptrs = palloc0(sizeof(void *) * shm_total_page_count);
 	pages_status = palloc(sizeof(int) * shm_total_page_count);
 
-- 
2.34.1