Fix ShmemInitStruct() reattachment in single-user mode

ShmemInitStruct() only looked for an existing allocation when
IsUnderPostmaster was true.  Because of that, you could not reattach
to an existing shmem area in a standalone backend.

Usually, you only call ShmemInitStruct() for the same shmem area once
in a process and hold onto the returned pointer, but there was no rule
that you couldn't call it twice for the same area if you wanted to,
and before commit 283e823f9d, it worked.  To fix, check for an
existing allocation regardless of process type, like the old
implementation did.

Author: Ayush Tiwari <[email protected]>
Reviewed-by: Ashutosh Bapat <[email protected]>
Discusssion: 
https://www.postgresql.org/message-id/cajtyswxregxcnwdzjsxt8pt2uy_y2gsx+houu2x3s8ydclj...@mail.gmail.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9ac2cb07b44f56a9185c08dafbba0ece74e8fcab

Modified Files
--------------
src/backend/storage/ipc/shmem.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

Reply via email to