@@ -92,6 +92,9 @@ void _PG_fini(void);
9292
9393#endif
9494
95+ #if PG_VERSION_NUM >= 150000
96+ shmem_request_hook_type prev_shmem_request_hook = NULL ;
97+ #endif
9598shmem_startup_hook_type prev_shmem_startup_hook = NULL ;
9699
97100bool plpgsql_check_regress_test_mode ;
@@ -305,14 +308,25 @@ _PG_init(void)
305308 PGC_POSTMASTER , 0 ,
306309 NULL , NULL , NULL );
307310
311+ #if PG_VERSION_NUM < 150000
312+ /*
313+ * If you change code here, don't forget to also report the
314+ * modifications in plpgsql_check_profiler_shmem_request() for pg15 and
315+ * later.
316+ */
308317 RequestAddinShmemSpace (plpgsql_check_shmem_size ());
309318
310319 RequestNamedLWLockTranche ("plpgsql_check profiler" , 1 );
311320 RequestNamedLWLockTranche ("plpgsql_check fstats" , 1 );
321+ #endif
312322
313323 /*
314324 * Install hooks.
315325 */
326+ #if PG_VERSION_NUM >= 150000
327+ prev_shmem_startup_hook = shmem_request_hook ;
328+ shmem_request_hook = plpgsql_check_profiler_shmem_request ;
329+ #endif
316330 prev_shmem_startup_hook = shmem_startup_hook ;
317331 shmem_startup_hook = plpgsql_check_profiler_shmem_startup ;
318332 }
@@ -334,6 +348,9 @@ _PG_init(void)
334348void
335349_PG_fini (void )
336350{
351+ #if PG_VERSION_NUM >= 150000
352+ shmem_request_hook = prev_shmem_request_hook ;
353+ #endif
337354 shmem_startup_hook = prev_shmem_startup_hook ;
338355
339356 /* Be more correct, and clean rendezvous variable */
@@ -343,4 +360,4 @@ _PG_fini(void)
343360 fmgr_hook = plpgsql_check_next_fmgr_hook ;
344361}
345362
346- #endif
363+ #endif
0 commit comments