Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0f1b89a

Browse files
author
Sergey Shinderuk
committed
PGPRO-6601: Add prefix to global variables and functions.
This is necessary to avoid name collision with other modules. Where possible,make variables and functions static.
1 parent5a4c1dd commit0f1b89a

File tree

3 files changed

+90
-95
lines changed

3 files changed

+90
-95
lines changed

‎collector.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static void handle_sigterm(SIGNAL_ARGS);
3737
* Register background worker for collecting waits history.
3838
*/
3939
void
40-
register_wait_collector(void)
40+
pgws_register_wait_collector(void)
4141
{
4242
BackgroundWorkerworker;
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+
staticvoid
6161
alloc_history(History*observations,intcount)
6262
{
6363
observations->items= (HistoryItem*)palloc0(sizeof(HistoryItem)*count);
@@ -151,7 +151,7 @@ probe_waits(History *observations, HTAB *profile_hash,
151151
TimestampTzts=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
*/
323323
void
324-
collector_main(Datummain_arg)
324+
pgws_collector_main(Datummain_arg)
325325
{
326326
HTAB*profile_hash=NULL;
327327
Historyobservations;
@@ -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
LOCKTAGtag;
445445
SHMRequestrequest;
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_resultmq_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
elseif (request==PROFILE_RESET)
488488
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp