@@ -58,6 +58,9 @@ shm_mq *recv_mq = NULL;
5858shm_mq_handle * recv_mqh = NULL ;
5959LOCKTAG queueTag ;
6060
61+ #if PG_VERSION_NUM >=150000
62+ static shmem_request_hook_type prev_shmem_request_hook = NULL ;
63+ #endif
6164static shmem_startup_hook_type prev_shmem_startup_hook = NULL ;
6265static PGPROC * search_proc (int backendPid );
6366static PlannedStmt * pgws_planner_hook (Query * parse ,
@@ -91,6 +94,10 @@ get_max_procs_count(void)
9194{
9295int count = 0 ;
9396
97+ #if PG_VERSION_NUM >=150000
98+ Assert (MaxBackends > 0 );
99+ count += MaxBackends ;
100+ #else
94101/*
95102 * MaxBackends: bgworkers, autovacuum workers and launcher.
96103 * This has to be in sync with the value computed in
@@ -105,7 +112,8 @@ get_max_procs_count(void)
105112 */
106113#if PG_VERSION_NUM >=120000
107114count += max_wal_senders ;
108- #endif
115+ #endif /* pg 12+ */
116+ #endif /* pg 15- */
109117
110118/* AuxiliaryProcs */
111119count += NUM_AUXILIARY_PROCS ;
@@ -265,6 +273,23 @@ setup_gucs()
265273}
266274}
267275
276+ #if PG_VERSION_NUM >=150000
277+ /*
278+ * shmem_request hook: request additional shared memory resources.
279+ *
280+ * If you change code here, don't forget to also report the modifications in
281+ * _PG_init() for pg14 and below.
282+ */
283+ static void
284+ pgws_shmem_request (void )
285+ {
286+ if (prev_shmem_request_hook )
287+ prev_shmem_request_hook ();
288+
289+ RequestAddinShmemSpace (pgws_shmem_size ());
290+ }
291+ #endif
292+
268293/*
269294 * Distribute shared memory.
270295 */
@@ -344,20 +369,27 @@ _PG_init(void)
344369if (!process_shared_preload_libraries_in_progress )
345370return ;
346371
372+ #if PG_VERSION_NUM < 150000
347373/*
348374 * Request additional shared resources. (These are no-ops if we're not in
349375 * the postmaster process.) We'll allocate or attach to the shared
350376 * resources in pgws_shmem_startup().
377+ *
378+ * If you change code here, don't forget to also report the modifications
379+ * in pgsp_shmem_request() for pg15 and later.
351380 */
352381RequestAddinShmemSpace (pgws_shmem_size ());
382+ #endif
353383
354384register_wait_collector ();
355385
356386/*
357387 * Install hooks.
358388 */
359- prev_shmem_startup_hook = shmem_startup_hook ;
360- shmem_startup_hook = pgws_shmem_startup ;
389+ #if PG_VERSION_NUM >=150000
390+ prev_shmem_request_hook = shmem_request_hook ;
391+ shmem_request_hook = pgws_shmem_request ;
392+ #endif
361393prev_shmem_startup_hook = shmem_startup_hook ;
362394shmem_startup_hook = pgws_shmem_startup ;
363395planner_hook_next = planner_hook ;