@@ -44,7 +44,7 @@ void _PG_init(void);
44
44
45
45
static bool shmem_initialized = false;
46
46
47
- /* Hooks */
47
+ /* Hooks variables */
48
48
static ExecutorStart_hook_type prev_ExecutorStart = NULL ;
49
49
static ExecutorRun_hook_type prev_ExecutorRun = NULL ;
50
50
static ExecutorFinish_hook_type prev_ExecutorFinish = NULL ;
@@ -65,6 +65,7 @@ static shm_mq *recv_mq = NULL;
65
65
static shm_mq_handle * recv_mqh = NULL ;
66
66
static LOCKTAG queueTag ;
67
67
68
+ /* Hook functions */
68
69
#if PG_VERSION_NUM >= 150000
69
70
static shmem_request_hook_type prev_shmem_request_hook = NULL ;
70
71
#endif
@@ -126,7 +127,6 @@ static const struct config_enum_entry pgws_profile_queries_options[] =
126
127
{NULL , 0 , false}
127
128
};
128
129
129
- /* GUC variables */
130
130
int pgws_historySize = 5000 ;
131
131
int pgws_historyPeriod = 10 ;
132
132
int pgws_profilePeriod = 10 ;
@@ -253,6 +253,7 @@ pgws_shmem_startup(void)
253
253
254
254
if (!found )
255
255
{
256
+ /* Create shared objects */
256
257
toc = shm_toc_create (PG_WAIT_SAMPLING_MAGIC , pgws , segsize );
257
258
258
259
pgws_collector_hdr = shm_toc_allocate (toc , sizeof (CollectorShmqHeader ));
@@ -266,6 +267,7 @@ pgws_shmem_startup(void)
266
267
}
267
268
else
268
269
{
270
+ /* Attach to existing shared objects */
269
271
toc = shm_toc_attach (PG_WAIT_SAMPLING_MAGIC , pgws );
270
272
pgws_collector_hdr = shm_toc_lookup (toc , 0 , false);
271
273
pgws_collector_mq = shm_toc_lookup (toc , 1 , false);
@@ -522,6 +524,7 @@ pg_wait_sampling_get_current(PG_FUNCTION_ARGS)
522
524
523
525
if (!PG_ARGISNULL (0 ))
524
526
{
527
+ /* pg_wait_sampling_get_current(pid int4) function */
525
528
HistoryItem * item ;
526
529
PGPROC * proc ;
527
530
@@ -535,6 +538,7 @@ pg_wait_sampling_get_current(PG_FUNCTION_ARGS)
535
538
}
536
539
else
537
540
{
541
+ /* pg_wait_sampling_current view */
538
542
int procCount = ProcGlobal -> allProcCount ,
539
543
i ,
540
544
j = 0 ;
@@ -600,6 +604,7 @@ pg_wait_sampling_get_current(PG_FUNCTION_ARGS)
600
604
}
601
605
else
602
606
{
607
+ /* nothing left */
603
608
SRF_RETURN_DONE (funcctx );
604
609
}
605
610
}
@@ -621,6 +626,7 @@ pgws_init_lock_tag(LOCKTAG *tag, uint32 lock)
621
626
tag -> locktag_lockmethodid = USER_LOCKMETHOD ;
622
627
}
623
628
629
+ /* Get array (history or profile data) from shared memory */
624
630
static void *
625
631
receive_array (SHMRequest request , Size item_size , Size * count )
626
632
{
0 commit comments