Make ShmemIndex visible in the pg_shmem_allocations view

Reviewed-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://www.postgresql.org/message-id/01ab1d41-3eda-4705-8bbd-af898f5007f1@iki.fi
This commit is contained in:
Heikki Linnakangas 2026-04-01 23:56:51 +03:00
parent db89a47115
commit 1bdbb211bb

View file

@ -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;
}
}
/*