Skip to content

Commit 7c89eda

Browse files
committed
Fix compatibility with pg15 new shmem_request_hook.
Hook added upstream in 4f2400cb3f10aa79f99fba680c198237da28dd38.
1 parent 1a8aa64 commit 7c89eda

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

pg_wait_sampling.c

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ shm_mq *recv_mq = NULL;
5858
shm_mq_handle *recv_mqh = NULL;
5959
LOCKTAG queueTag;
6060

61+
#if PG_VERSION_NUM >= 150000
62+
static shmem_request_hook_type prev_shmem_request_hook = NULL;
63+
#endif
6164
static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
6265
static PGPROC * search_proc(int backendPid);
6366
static PlannedStmt *pgws_planner_hook(Query *parse,
@@ -91,6 +94,10 @@ get_max_procs_count(void)
9194
{
9295
int 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
107114
count += max_wal_senders;
108-
#endif
115+
#endif /* pg 12+ */
116+
#endif /* pg 15- */
109117

110118
/* AuxiliaryProcs */
111119
count += 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)
344369
if (!process_shared_preload_libraries_in_progress)
345370
return;
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
*/
352381
RequestAddinShmemSpace(pgws_shmem_size());
382+
#endif
353383

354384
register_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
361393
prev_shmem_startup_hook = shmem_startup_hook;
362394
shmem_startup_hook = pgws_shmem_startup;
363395
planner_hook_next = planner_hook;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy