From: Heikki Linnakangas Date: Wed, 1 Apr 2026 20:56:51 +0000 (+0300) Subject: Make ShmemIndex visible in the pg_shmem_allocations view X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1bdbb211bbf31b0024f000746c42326648ecde90;p=thirdparty%2Fpostgresql.git Make ShmemIndex visible in the pg_shmem_allocations view Reviewed-by: Tomas Vondra Discussion: https://www.postgresql.org/message-id/01ab1d41-3eda-4705-8bbd-af898f5007f1@iki.fi --- diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c index 0e49debaaac..a5b7360e2dc 100644 --- a/src/backend/storage/ipc/shmem.c +++ b/src/backend/storage/ipc/shmem.c @@ -131,7 +131,7 @@ InitShmemAllocator(PGShmemHeader *seghdr) Size offset; HASHCTL info; int hash_flags; - size_t size; + size_t size = 0; #ifndef EXEC_BACKEND Assert(!IsUnderPostmaster); @@ -198,6 +198,22 @@ InitShmemAllocator(PGShmemHeader *seghdr) info.hctl = ShmemAllocator->index; ShmemIndex = hash_create("ShmemIndex", SHMEM_INDEX_SIZE, &info, hash_flags); Assert(ShmemIndex != NULL); + + /* + * Add an entry for ShmemIndex itself into ShmemIndex, so that it's + * visible in the pg_shmem_allocations view + */ + if (!IsUnderPostmaster) + { + bool found; + ShmemIndexEnt *result = (ShmemIndexEnt *) + hash_search(ShmemIndex, "ShmemIndex", HASH_ENTER, &found); + + Assert(!found); + result->size = size; + result->allocated_size = size; + result->location = ShmemAllocator->index; + } } /*