@@ -58,6 +58,9 @@ shm_mq *recv_mq = NULL;
58
58
shm_mq_handle * recv_mqh = NULL ;
59
59
LOCKTAG queueTag ;
60
60
61
+ #if PG_VERSION_NUM >= 150000
62
+ static shmem_request_hook_type prev_shmem_request_hook = NULL ;
63
+ #endif
61
64
static shmem_startup_hook_type prev_shmem_startup_hook = NULL ;
62
65
static PGPROC * search_proc (int backendPid );
63
66
static PlannedStmt * pgws_planner_hook (Query * parse ,
@@ -91,6 +94,10 @@ get_max_procs_count(void)
91
94
{
92
95
int count = 0 ;
93
96
97
+ #if PG_VERSION_NUM >= 150000
98
+ Assert (MaxBackends > 0 );
99
+ count += MaxBackends ;
100
+ #else
94
101
/*
95
102
* MaxBackends: bgworkers, autovacuum workers and launcher.
96
103
* This has to be in sync with the value computed in
@@ -105,7 +112,8 @@ get_max_procs_count(void)
105
112
*/
106
113
#if PG_VERSION_NUM >= 120000
107
114
count += max_wal_senders ;
108
- #endif
115
+ #endif /* pg 12+ */
116
+ #endif /* pg 15- */
109
117
110
118
/* AuxiliaryProcs */
111
119
count += NUM_AUXILIARY_PROCS ;
@@ -265,6 +273,23 @@ setup_gucs()
265
273
}
266
274
}
267
275
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
+
268
293
/*
269
294
* Distribute shared memory.
270
295
*/
@@ -344,20 +369,27 @@ _PG_init(void)
344
369
if (!process_shared_preload_libraries_in_progress )
345
370
return ;
346
371
372
+ #if PG_VERSION_NUM < 150000
347
373
/*
348
374
* Request additional shared resources. (These are no-ops if we're not in
349
375
* the postmaster process.) We'll allocate or attach to the shared
350
376
* 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.
351
380
*/
352
381
RequestAddinShmemSpace (pgws_shmem_size ());
382
+ #endif
353
383
354
384
register_wait_collector ();
355
385
356
386
/*
357
387
* Install hooks.
358
388
*/
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
361
393
prev_shmem_startup_hook = shmem_startup_hook ;
362
394
shmem_startup_hook = pgws_shmem_startup ;
363
395
planner_hook_next = planner_hook ;
0 commit comments