@@ -240,6 +240,11 @@ static volatile sig_atomic_t got_SIGHUP = false;
240240
241241static shmem_startup_hook_type PreviousShmemStartupHook ;
242242
243+ #if PG_VERSION_NUM >= 150000
244+ static shmem_request_hook_type prev_shmem_request_hook = NULL ;
245+ static void mtm_dmq_shmem_request (void );
246+ #endif
247+
243248void * (* dmq_receiver_start_hook )(char * sender_name );
244249dmq_hook_type dmq_receiver_stop_hook ;
245250dmq_hook_type dmq_sender_connect_hook ;
@@ -364,14 +369,19 @@ static Size
364369dmq_shmem_size (void )
365370{
366371 Size size = 0 ;
367- int maxbackends = 0 ;
368-
369- maxbackends = MaxConnections + autovacuum_max_workers +
370- max_worker_processes + max_wal_senders + 1 ;
372+ #if PG_VERSION_NUM < 150000
373+ int maxbackends = MaxConnections + autovacuum_max_workers +
374+ max_worker_processes + max_wal_senders + 1 ;
375+ #endif
371376
372377 size = add_size (size , sizeof (struct DmqSharedState ));
378+ #if PG_VERSION_NUM >= 150000
379+ size = add_size (size , hash_estimate_size (DMQ_MAX_SUBS_PER_BACKEND * MaxBackends ,
380+ sizeof (DmqStreamSubscription )));
381+ #else
373382 size = add_size (size , hash_estimate_size (DMQ_MAX_SUBS_PER_BACKEND * maxbackends ,
374383 sizeof (DmqStreamSubscription )));
384+ #endif
375385 return MAXALIGN (size );
376386}
377387
@@ -384,9 +394,14 @@ dmq_init(int send_timeout, int connect_timeout)
384394 return ;
385395
386396 /* Reserve area for our shared state */
397+ #if PG_VERSION_NUM >= 150000
398+ prev_shmem_request_hook = shmem_request_hook ;
399+ shmem_request_hook = mtm_dmq_shmem_request ;
400+ #else
387401 RequestAddinShmemSpace (dmq_shmem_size ());
388402
389403 RequestNamedLWLockTranche ("dmq" , 1 );
404+ #endif
390405
391406 /* Set up common data for all our workers */
392407 memset (& worker , 0 , sizeof (worker ));
@@ -408,6 +423,18 @@ dmq_init(int send_timeout, int connect_timeout)
408423 shmem_startup_hook = dmq_shmem_startup_hook ;
409424}
410425
426+ #if PG_VERSION_NUM >= 150000
427+ static void
428+ mtm_dmq_shmem_request (void )
429+ {
430+ if (prev_shmem_request_hook )
431+ prev_shmem_request_hook ();
432+
433+ RequestAddinShmemSpace (dmq_shmem_size ());
434+ RequestNamedLWLockTranche ("dmq" , 1 );
435+ }
436+ #endif
437+
411438static Size
412439dmq_toc_size ()
413440{
0 commit comments