It might seem pointless to allow use of dsm in single user mode, but otherwise
subsystems might need dedicated single user mode code paths.
Besides changing the assert, all that's needed is to make some windows code
assuming the presence of postmaster conditional.
Author: Andres Freund <andres@anarazel.de>
Reviewed-By: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/CA+hUKGL9hY_VY=+oUK+Gc1iSRx-Ls5qeYJ6q=dQVZnT3R63Taw@mail.gmail.com
 dsm_backend_startup(void)
 {
 #ifdef EXEC_BACKEND
+   if (IsUnderPostmaster)
    {
        void       *control_address = NULL;
 
    FreePageManager *dsm_main_space_fpm = dsm_main_space_begin;
    bool        using_main_dsm_region = false;
 
-   /* Unsafe in postmaster (and pointless in a stand-alone backend). */
-   Assert(IsUnderPostmaster);
+   /*
+    * Unsafe in postmaster. It might seem pointless to allow use of dsm in
+    * single user mode, but otherwise some subsystems will need dedicated
+    * single user mode code paths.
+    */
+   Assert(IsUnderPostmaster || !IsPostmasterEnvironment);
 
    if (!dsm_init_done)
        dsm_backend_startup();
 
    {
 #ifdef USE_DSM_WINDOWS
        case DSM_IMPL_WINDOWS:
+           if (IsUnderPostmaster)
            {
                HANDLE      hmap;
 
                 * is unpinned, dsm_impl_unpin_segment can close it.
                 */
                *impl_private_pm_handle = hmap;
-               break;
            }
+           break;
 #endif
        default:
            break;
    {
 #ifdef USE_DSM_WINDOWS
        case DSM_IMPL_WINDOWS:
+           if (IsUnderPostmaster)
            {
                if (*impl_private &&
                    !DuplicateHandle(PostmasterHandle, *impl_private,
                }
 
                *impl_private = NULL;
-               break;
            }
+           break;
 #endif
        default:
            break;