@@ -37,7 +37,7 @@ static void handle_sigterm(SIGNAL_ARGS);
3737 * Register background worker for collecting waits history. 
3838 */ 
3939void 
40- register_wait_collector (void )
40+ pgws_register_wait_collector (void )
4141{
4242	BackgroundWorker  worker ;
4343
@@ -48,7 +48,7 @@ register_wait_collector(void)
4848	worker .bgw_restart_time  =  1 ;
4949	worker .bgw_notify_pid  =  0 ;
5050	snprintf (worker .bgw_library_name , BGW_MAXLEN , "pg_wait_sampling" );
51- 	snprintf (worker .bgw_function_name , BGW_MAXLEN , CppAsString (collector_main ));
51+ 	snprintf (worker .bgw_function_name , BGW_MAXLEN , CppAsString (pgws_collector_main ));
5252	snprintf (worker .bgw_name , BGW_MAXLEN , "pg_wait_sampling collector" );
5353	worker .bgw_main_arg  =  (Datum ) 0 ;
5454	RegisterBackgroundWorker (& worker );
@@ -57,7 +57,7 @@ register_wait_collector(void)
5757/* 
5858 * Allocate memory for waits history. 
5959 */ 
60- void 
60+ static   void 
6161alloc_history (History  * observations , int  count )
6262{
6363	observations -> items  =  (HistoryItem  * ) palloc0 (sizeof (HistoryItem ) *  count );
@@ -151,7 +151,7 @@ probe_waits(History *observations, HTAB *profile_hash,
151151	TimestampTz 	ts  =  GetCurrentTimestamp ();
152152
153153	/* Realloc waits history if needed */ 
154- 	newSize  =  collector_hdr -> historySize ;
154+ 	newSize  =  pgws_collector_hdr -> historySize ;
155155	if  (observations -> count  !=  newSize )
156156		realloc_history (observations , newSize );
157157
@@ -173,8 +173,8 @@ probe_waits(History *observations, HTAB *profile_hash,
173173		item .pid  =  proc -> pid ;
174174		item .wait_event_info  =  proc -> wait_event_info ;
175175
176- 		if  (collector_hdr -> profileQueries )
177- 			item .queryId  =  proc_queryids [i ];
176+ 		if  (pgws_collector_hdr -> profileQueries )
177+ 			item .queryId  =  pgws_proc_queryids [i ];
178178		else 
179179			item .queryId  =  0 ;
180180
@@ -292,7 +292,7 @@ make_profile_hash()
292292	hash_ctl .hash  =  tag_hash ;
293293	hash_ctl .hcxt  =  TopMemoryContext ;
294294
295- 	if  (collector_hdr -> profileQueries )
295+ 	if  (pgws_collector_hdr -> profileQueries )
296296		hash_ctl .keysize  =  offsetof(ProfileItem , count );
297297	else 
298298		hash_ctl .keysize  =  offsetof(ProfileItem , queryId );
@@ -321,7 +321,7 @@ millisecs_diff(TimestampTz tz1, TimestampTz tz2)
321321 * Main routine of wait history collector. 
322322 */ 
323323void 
324- collector_main (Datum  main_arg )
324+ pgws_collector_main (Datum  main_arg )
325325{
326326	HTAB 		   * profile_hash  =  NULL ;
327327	History 			observations ;
@@ -358,13 +358,13 @@ collector_main(Datum main_arg)
358358	pgstat_report_appname ("pg_wait_sampling collector" );
359359
360360	profile_hash  =  make_profile_hash ();
361- 	collector_hdr -> latch  =  & MyProc -> procLatch ;
361+ 	pgws_collector_hdr -> latch  =  & MyProc -> procLatch ;
362362
363363	CurrentResourceOwner  =  ResourceOwnerCreate (NULL , "pg_wait_sampling collector" );
364364	collector_context  =  AllocSetContextCreate (TopMemoryContext ,
365365			"pg_wait_sampling context" , ALLOCSET_DEFAULT_SIZES );
366366	old_context  =  MemoryContextSwitchTo (collector_context );
367- 	alloc_history (& observations , collector_hdr -> historySize );
367+ 	alloc_history (& observations , pgws_collector_hdr -> historySize );
368368	MemoryContextSwitchTo (old_context );
369369
370370	ereport (LOG , (errmsg ("pg_wait_sampling collector started" )));
@@ -391,16 +391,16 @@ collector_main(Datum main_arg)
391391
392392		history_diff  =  millisecs_diff (history_ts , current_ts );
393393		profile_diff  =  millisecs_diff (profile_ts , current_ts );
394- 		history_period  =  collector_hdr -> historyPeriod ;
395- 		profile_period  =  collector_hdr -> profilePeriod ;
394+ 		history_period  =  pgws_collector_hdr -> historyPeriod ;
395+ 		profile_period  =  pgws_collector_hdr -> profilePeriod ;
396396
397397		write_history  =  (history_diff  >= (int64 )history_period );
398398		write_profile  =  (profile_diff  >= (int64 )profile_period );
399399
400400		if  (write_history  ||  write_profile )
401401		{
402402			probe_waits (& observations , profile_hash ,
403- 						write_history , write_profile , collector_hdr -> profilePid );
403+ 						write_history , write_profile , pgws_collector_hdr -> profilePid );
404404
405405			if  (write_history )
406406			{
@@ -439,24 +439,24 @@ collector_main(Datum main_arg)
439439		ResetLatch (& MyProc -> procLatch );
440440
441441		/* Handle request if any */ 
442- 		if  (collector_hdr -> request  !=  NO_REQUEST )
442+ 		if  (pgws_collector_hdr -> request  !=  NO_REQUEST )
443443		{
444444			LOCKTAG 		tag ;
445445			SHMRequest 	request ;
446446
447- 			init_lock_tag (& tag , PGWS_COLLECTOR_LOCK );
447+ 			pgws_init_lock_tag (& tag , PGWS_COLLECTOR_LOCK );
448448
449449			LockAcquire (& tag , ExclusiveLock , false, false);
450- 			request  =  collector_hdr -> request ;
451- 			collector_hdr -> request  =  NO_REQUEST ;
450+ 			request  =  pgws_collector_hdr -> request ;
451+ 			pgws_collector_hdr -> request  =  NO_REQUEST ;
452452
453453			if  (request  ==  HISTORY_REQUEST  ||  request  ==  PROFILE_REQUEST )
454454			{
455455				shm_mq_result 	mq_result ;
456456
457457				/* Send history or profile */ 
458- 				shm_mq_set_sender (collector_mq , MyProc );
459- 				mqh  =  shm_mq_attach (collector_mq , NULL , NULL );
458+ 				shm_mq_set_sender (pgws_collector_mq , MyProc );
459+ 				mqh  =  shm_mq_attach (pgws_collector_mq , NULL , NULL );
460460				mq_result  =  shm_mq_wait_for_attach (mqh );
461461				switch  (mq_result )
462462				{
@@ -482,7 +482,7 @@ collector_main(Datum main_arg)
482482					default :
483483						AssertState (false);
484484				}
485- 				shm_mq_detach_compat (mqh , collector_mq );
485+ 				shm_mq_detach_compat (mqh , pgws_collector_mq );
486486			}
487487			else  if  (request  ==  PROFILE_RESET )
488488			{
0 commit comments