@@ -44,7 +44,7 @@ void_PG_init(void);
4444
4545static bool shmem_initialized = false;
4646
47- /* Hooks */
47+ /* Hooksvariables */
4848static ExecutorStart_hook_type prev_ExecutorStart = NULL ;
4949static ExecutorRun_hook_type prev_ExecutorRun = NULL ;
5050static ExecutorFinish_hook_type prev_ExecutorFinish = NULL ;
@@ -65,6 +65,7 @@ static shm_mq *recv_mq = NULL;
6565static shm_mq_handle * recv_mqh = NULL ;
6666static LOCKTAG queueTag ;
6767
68+ /* Hook functions */
6869#if PG_VERSION_NUM >=150000
6970static shmem_request_hook_type prev_shmem_request_hook = NULL ;
7071#endif
@@ -126,7 +127,6 @@ static const struct config_enum_entry pgws_profile_queries_options[] =
126127{NULL ,0 , false}
127128};
128129
129- /* GUC variables */
130130int pgws_historySize = 5000 ;
131131int pgws_historyPeriod = 10 ;
132132int pgws_profilePeriod = 10 ;
@@ -253,6 +253,7 @@ pgws_shmem_startup(void)
253253
254254if (!found )
255255{
256+ /* Create shared objects */
256257toc = shm_toc_create (PG_WAIT_SAMPLING_MAGIC ,pgws ,segsize );
257258
258259pgws_collector_hdr = shm_toc_allocate (toc ,sizeof (CollectorShmqHeader ));
@@ -266,6 +267,7 @@ pgws_shmem_startup(void)
266267}
267268else
268269{
270+ /* Attach to existing shared objects */
269271toc = shm_toc_attach (PG_WAIT_SAMPLING_MAGIC ,pgws );
270272pgws_collector_hdr = shm_toc_lookup (toc ,0 , false);
271273pgws_collector_mq = shm_toc_lookup (toc ,1 , false);
@@ -522,6 +524,7 @@ pg_wait_sampling_get_current(PG_FUNCTION_ARGS)
522524
523525if (!PG_ARGISNULL (0 ))
524526{
527+ /* pg_wait_sampling_get_current(pid int4) function */
525528HistoryItem * item ;
526529PGPROC * proc ;
527530
@@ -535,6 +538,7 @@ pg_wait_sampling_get_current(PG_FUNCTION_ARGS)
535538}
536539else
537540{
541+ /* pg_wait_sampling_current view */
538542int procCount = ProcGlobal -> allProcCount ,
539543i ,
540544j = 0 ;
@@ -600,6 +604,7 @@ pg_wait_sampling_get_current(PG_FUNCTION_ARGS)
600604}
601605else
602606{
607+ /* nothing left */
603608SRF_RETURN_DONE (funcctx );
604609}
605610}
@@ -621,6 +626,7 @@ pgws_init_lock_tag(LOCKTAG *tag, uint32 lock)
621626tag -> locktag_lockmethodid = USER_LOCKMETHOD ;
622627}
623628
629+ /* Get array (history or profile data) from shared memory */
624630static void *
625631receive_array (SHMRequest request ,Size item_size ,Size * count )
626632{