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

Commit067701f

Browse files
committed
Remove MyAuxProcType, use MyBackendType instead
MyAuxProcType was redundant with MyBackendType.Reviewed-by: Reid Thompson, Andres FreundDiscussion:https://www.postgresql.org/message-id/f3ecd4cb-85ee-4e54-8278-5fabfb3a4ed0@iki.fi
1 parenta0cd954 commit067701f

File tree

5 files changed

+75
-115
lines changed

5 files changed

+75
-115
lines changed

‎src/backend/postmaster/auxprocess.c

Lines changed: 11 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@
3838
staticvoidShutdownAuxiliaryProcess(intcode,Datumarg);
3939

4040

41-
/* ----------------
42-
*global variables
43-
* ----------------
44-
*/
45-
46-
AuxProcTypeMyAuxProcType=NotAnAuxProcess;/* declared in miscadmin.h */
47-
48-
4941
/*
5042
* AuxiliaryProcessMain
5143
*
@@ -55,39 +47,11 @@ AuxProcType MyAuxProcType = NotAnAuxProcess;/* declared in miscadmin.h */
5547
* This code is here just because of historical reasons.
5648
*/
5749
void
58-
AuxiliaryProcessMain(AuxProcTypeauxtype)
50+
AuxiliaryProcessMain(BackendTypeauxtype)
5951
{
6052
Assert(IsUnderPostmaster);
6153

62-
MyAuxProcType=auxtype;
63-
64-
switch (MyAuxProcType)
65-
{
66-
caseStartupProcess:
67-
MyBackendType=B_STARTUP;
68-
break;
69-
caseArchiverProcess:
70-
MyBackendType=B_ARCHIVER;
71-
break;
72-
caseBgWriterProcess:
73-
MyBackendType=B_BG_WRITER;
74-
break;
75-
caseCheckpointerProcess:
76-
MyBackendType=B_CHECKPOINTER;
77-
break;
78-
caseWalWriterProcess:
79-
MyBackendType=B_WAL_WRITER;
80-
break;
81-
caseWalReceiverProcess:
82-
MyBackendType=B_WAL_RECEIVER;
83-
break;
84-
caseWalSummarizerProcess:
85-
MyBackendType=B_WAL_SUMMARIZER;
86-
break;
87-
default:
88-
elog(PANIC,"unrecognized process type: %d", (int)MyAuxProcType);
89-
MyBackendType=B_INVALID;
90-
}
54+
MyBackendType=auxtype;
9155

9256
init_ps_display(NULL);
9357

@@ -126,38 +90,38 @@ AuxiliaryProcessMain(AuxProcType auxtype)
12690

12791
SetProcessingMode(NormalProcessing);
12892

129-
switch (MyAuxProcType)
93+
switch (MyBackendType)
13094
{
131-
caseStartupProcess:
95+
caseB_STARTUP:
13296
StartupProcessMain();
13397
proc_exit(1);
13498

135-
caseArchiverProcess:
99+
caseB_ARCHIVER:
136100
PgArchiverMain();
137101
proc_exit(1);
138102

139-
caseBgWriterProcess:
103+
caseB_BG_WRITER:
140104
BackgroundWriterMain();
141105
proc_exit(1);
142106

143-
caseCheckpointerProcess:
107+
caseB_CHECKPOINTER:
144108
CheckpointerMain();
145109
proc_exit(1);
146110

147-
caseWalWriterProcess:
111+
caseB_WAL_WRITER:
148112
WalWriterMain();
149113
proc_exit(1);
150114

151-
caseWalReceiverProcess:
115+
caseB_WAL_RECEIVER:
152116
WalReceiverMain();
153117
proc_exit(1);
154118

155-
caseWalSummarizerProcess:
119+
caseB_WAL_SUMMARIZER:
156120
WalSummarizerMain();
157121
proc_exit(1);
158122

159123
default:
160-
elog(PANIC,"unrecognized process type: %d", (int)MyAuxProcType);
124+
elog(PANIC,"unrecognized process type: %d", (int)MyBackendType);
161125
proc_exit(1);
162126
}
163127
}

‎src/backend/postmaster/postmaster.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ static intCountChildren(int target);
442442
staticboolassign_backendlist_entry(RegisteredBgWorker*rw);
443443
staticvoidmaybe_start_bgworkers(void);
444444
staticboolCreateOptsFile(intargc,char*argv[],char*fullprogname);
445-
staticpid_tStartChildProcess(AuxProcTypetype);
445+
staticpid_tStartChildProcess(BackendTypetype);
446446
staticvoidStartAutovacuumWorker(void);
447447
staticvoidMaybeStartWalReceiver(void);
448448
staticvoidMaybeStartWalSummarizer(void);
@@ -1452,14 +1452,14 @@ PostmasterMain(int argc, char *argv[])
14521452

14531453
/* Start bgwriter and checkpointer so they can help with recovery */
14541454
if (CheckpointerPID==0)
1455-
CheckpointerPID=StartChildProcess(CheckpointerProcess);
1455+
CheckpointerPID=StartChildProcess(B_CHECKPOINTER);
14561456
if (BgWriterPID==0)
1457-
BgWriterPID=StartChildProcess(BgWriterProcess);
1457+
BgWriterPID=StartChildProcess(B_BG_WRITER);
14581458

14591459
/*
14601460
* We're ready to rock and roll...
14611461
*/
1462-
StartupPID=StartChildProcess(StartupProcess);
1462+
StartupPID=StartChildProcess(B_STARTUP);
14631463
Assert(StartupPID!=0);
14641464
StartupStatus=STARTUP_RUNNING;
14651465
pmState=PM_STARTUP;
@@ -1793,9 +1793,9 @@ ServerLoop(void)
17931793
pmState==PM_HOT_STANDBY||pmState==PM_STARTUP)
17941794
{
17951795
if (CheckpointerPID==0)
1796-
CheckpointerPID=StartChildProcess(CheckpointerProcess);
1796+
CheckpointerPID=StartChildProcess(B_CHECKPOINTER);
17971797
if (BgWriterPID==0)
1798-
BgWriterPID=StartChildProcess(BgWriterProcess);
1798+
BgWriterPID=StartChildProcess(B_BG_WRITER);
17991799
}
18001800

18011801
/*
@@ -1804,7 +1804,7 @@ ServerLoop(void)
18041804
* be writing any new WAL).
18051805
*/
18061806
if (WalWriterPID==0&&pmState==PM_RUN)
1807-
WalWriterPID=StartChildProcess(WalWriterProcess);
1807+
WalWriterPID=StartChildProcess(B_WAL_WRITER);
18081808

18091809
/*
18101810
* If we have lost the autovacuum launcher, try to start a new one. We
@@ -1823,7 +1823,7 @@ ServerLoop(void)
18231823

18241824
/* If we have lost the archiver, try to start a new one. */
18251825
if (PgArchPID==0&&PgArchStartupAllowed())
1826-
PgArchPID=StartChildProcess(ArchiverProcess);
1826+
PgArchPID=StartChildProcess(B_ARCHIVER);
18271827

18281828
/* If we need to start a slot sync worker, try to do that now */
18291829
MaybeStartSlotSyncWorker();
@@ -3003,11 +3003,11 @@ process_pm_child_exit(void)
30033003
* if this fails, we'll just try again later.
30043004
*/
30053005
if (CheckpointerPID==0)
3006-
CheckpointerPID=StartChildProcess(CheckpointerProcess);
3006+
CheckpointerPID=StartChildProcess(B_CHECKPOINTER);
30073007
if (BgWriterPID==0)
3008-
BgWriterPID=StartChildProcess(BgWriterProcess);
3008+
BgWriterPID=StartChildProcess(B_BG_WRITER);
30093009
if (WalWriterPID==0)
3010-
WalWriterPID=StartChildProcess(WalWriterProcess);
3010+
WalWriterPID=StartChildProcess(B_WAL_WRITER);
30113011
MaybeStartWalSummarizer();
30123012

30133013
/*
@@ -3017,7 +3017,7 @@ process_pm_child_exit(void)
30173017
if (!IsBinaryUpgrade&&AutoVacuumingActive()&&AutoVacPID==0)
30183018
AutoVacPID=StartAutoVacLauncher();
30193019
if (PgArchStartupAllowed()&&PgArchPID==0)
3020-
PgArchPID=StartChildProcess(ArchiverProcess);
3020+
PgArchPID=StartChildProcess(B_ARCHIVER);
30213021
MaybeStartSlotSyncWorker();
30223022

30233023
/* workers may be scheduled to start now */
@@ -3173,7 +3173,7 @@ process_pm_child_exit(void)
31733173
HandleChildCrash(pid,exitstatus,
31743174
_("archiver process"));
31753175
if (PgArchStartupAllowed())
3176-
PgArchPID=StartChildProcess(ArchiverProcess);
3176+
PgArchPID=StartChildProcess(B_ARCHIVER);
31773177
continue;
31783178
}
31793179

@@ -3777,7 +3777,7 @@ PostmasterStateMachine(void)
37773777
Assert(Shutdown>NoShutdown);
37783778
/* Start the checkpointer if not running */
37793779
if (CheckpointerPID==0)
3780-
CheckpointerPID=StartChildProcess(CheckpointerProcess);
3780+
CheckpointerPID=StartChildProcess(B_CHECKPOINTER);
37813781
/* And tell it to shut down */
37823782
if (CheckpointerPID!=0)
37833783
{
@@ -3932,7 +3932,7 @@ PostmasterStateMachine(void)
39323932
/* re-create shared memory and semaphores */
39333933
CreateSharedMemoryAndSemaphores();
39343934

3935-
StartupPID=StartChildProcess(StartupProcess);
3935+
StartupPID=StartChildProcess(B_STARTUP);
39363936
Assert(StartupPID!=0);
39373937
StartupStatus=STARTUP_RUNNING;
39383938
pmState=PM_STARTUP;
@@ -4967,7 +4967,7 @@ SubPostmasterMain(int argc, char *argv[])
49674967
}
49684968
if (strcmp(argv[1],"--forkaux")==0)
49694969
{
4970-
AuxProcTypeauxtype;
4970+
BackendTypeauxtype;
49714971

49724972
Assert(argc==4);
49734973

@@ -5087,7 +5087,7 @@ process_pm_pmsignal(void)
50875087
*/
50885088
Assert(PgArchPID==0);
50895089
if (XLogArchivingAlways())
5090-
PgArchPID=StartChildProcess(ArchiverProcess);
5090+
PgArchPID=StartChildProcess(B_ARCHIVER);
50915091

50925092
/*
50935093
* If we aren't planning to enter hot standby mode later, treat
@@ -5313,7 +5313,7 @@ CountChildren(int target)
53135313
* to start subprocess.
53145314
*/
53155315
staticpid_t
5316-
StartChildProcess(AuxProcTypetype)
5316+
StartChildProcess(BackendTypetype)
53175317
{
53185318
pid_tpid;
53195319

@@ -5365,31 +5365,31 @@ StartChildProcess(AuxProcType type)
53655365
errno=save_errno;
53665366
switch (type)
53675367
{
5368-
caseStartupProcess:
5368+
caseB_STARTUP:
53695369
ereport(LOG,
53705370
(errmsg("could not fork startup process: %m")));
53715371
break;
5372-
caseArchiverProcess:
5372+
caseB_ARCHIVER:
53735373
ereport(LOG,
53745374
(errmsg("could not fork archiver process: %m")));
53755375
break;
5376-
caseBgWriterProcess:
5376+
caseB_BG_WRITER:
53775377
ereport(LOG,
53785378
(errmsg("could not fork background writer process: %m")));
53795379
break;
5380-
caseCheckpointerProcess:
5380+
caseB_CHECKPOINTER:
53815381
ereport(LOG,
53825382
(errmsg("could not fork checkpointer process: %m")));
53835383
break;
5384-
caseWalWriterProcess:
5384+
caseB_WAL_WRITER:
53855385
ereport(LOG,
53865386
(errmsg("could not fork WAL writer process: %m")));
53875387
break;
5388-
caseWalReceiverProcess:
5388+
caseB_WAL_RECEIVER:
53895389
ereport(LOG,
53905390
(errmsg("could not fork WAL receiver process: %m")));
53915391
break;
5392-
caseWalSummarizerProcess:
5392+
caseB_WAL_SUMMARIZER:
53935393
ereport(LOG,
53945394
(errmsg("could not fork WAL summarizer process: %m")));
53955395
break;
@@ -5403,7 +5403,7 @@ StartChildProcess(AuxProcType type)
54035403
* fork failure is fatal during startup, but there's no need to choke
54045404
* immediately if starting other child types fails.
54055405
*/
5406-
if (type==StartupProcess)
5406+
if (type==B_STARTUP)
54075407
ExitPostmaster(1);
54085408
return0;
54095409
}
@@ -5522,7 +5522,7 @@ MaybeStartWalReceiver(void)
55225522
pmState==PM_HOT_STANDBY)&&
55235523
Shutdown <=SmartShutdown)
55245524
{
5525-
WalReceiverPID=StartChildProcess(WalReceiverProcess);
5525+
WalReceiverPID=StartChildProcess(B_WAL_RECEIVER);
55265526
if (WalReceiverPID!=0)
55275527
WalReceiverRequested= false;
55285528
/* else leave the flag set, so we'll try again later */
@@ -5539,7 +5539,7 @@ MaybeStartWalSummarizer(void)
55395539
if (summarize_wal&&WalSummarizerPID==0&&
55405540
(pmState==PM_RUN||pmState==PM_HOT_STANDBY)&&
55415541
Shutdown <=SmartShutdown)
5542-
WalSummarizerPID=StartChildProcess(WalSummarizerProcess);
5542+
WalSummarizerPID=StartChildProcess(B_WAL_SUMMARIZER);
55435543
}
55445544

55455545

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp