Allow unknown-size shmem attachments in single-user mode ShmemRequestInternal() rejected SHMEM_ATTACH_UNKNOWN_SIZE whenever IsUnderPostmaster was false. That also rejected an after-startup attachment in a standalone backend, even if the area exists.
To fix, check whether the shared memory has been initialized (ShmemIndex == NULL) rather than IsUnderPostmaster. Refactor the tests, and add more test cases for after-startup attachment, with SHMEM_ATTACH_UNKNOWN_SIZE and a mismatching size, and for this single-user case. 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 ------ master Details ------- https://git.postgresql.org/pg/commitdiff/c712b0d49b971fe7cf521c057bc7adb63b17760c Modified Files -------------- src/backend/storage/ipc/shmem.c | 26 ++- .../modules/test_shmem/t/001_late_shmem_alloc.pl | 182 ++++++++++++++------- src/test/modules/test_shmem/test_shmem--1.0.sql | 4 + src/test/modules/test_shmem/test_shmem.c | 55 +++++++ 4 files changed, 190 insertions(+), 77 deletions(-)
