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

Commit626eb02

Browse files
committed
Cleanup the bootstrap code a little, and rename "dummy procs" in the code
comments and variables to "auxiliary proc", per Heikki's request.
1 parentcc0cac4 commit626eb02

File tree

9 files changed

+151
-168
lines changed

9 files changed

+151
-168
lines changed

‎src/backend/bootstrap/bootparse.y

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.86 2007/01/09 02:14:11 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.87 2007/03/07 13:35:02 alvherre Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -235,10 +235,7 @@ Boot_InsertStmt:
235235
elog(ERROR,"incorrect number of columns in row (expected %d, got %d)",
236236
numattr, num_columns_read);
237237
if (boot_reldesc ==NULL)
238-
{
239-
elog(ERROR,"relation not open");
240-
err_out();
241-
}
238+
elog(FATAL,"relation not open");
242239
InsertOneTuple($2);
243240
do_end();
244241
}

‎src/backend/bootstrap/bootstrap.c

Lines changed: 67 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.232 2007/02/16 02:10:07 alvherre Exp $
11+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.233 2007/03/07 13:35:02 alvherre Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -20,8 +20,6 @@
2020
#include<getopt.h>
2121
#endif
2222

23-
#defineBOOTSTRAP_INCLUDE/* mask out stuff in tcop/tcopprot.h */
24-
2523
#include"access/genam.h"
2624
#include"access/heapam.h"
2725
#include"access/xact.h"
@@ -48,8 +46,10 @@ extern char *optarg;
4846

4947
#defineALLOC(t,c)((t *) calloc((unsigned)(c), sizeof(t)))
5048

49+
staticvoidCheckerModeMain(void);
50+
staticvoidBootstrapModeMain(void);
5151
staticvoidbootstrap_signals(void);
52-
staticvoidShutdownDummyProcess(intcode,Datumarg);
52+
staticvoidShutdownAuxiliaryProcess(intcode,Datumarg);
5353
statichashnode*AddStr(char*str,intstrlength,intmderef);
5454
staticForm_pg_attributeAllocateAttribute(void);
5555
staticintCompHash(char*str,intlen);
@@ -166,7 +166,6 @@ struct typmap
166166
staticstructtypmap**Typ=NULL;
167167
staticstructtypmap*Ap=NULL;
168168

169-
staticintWarnings=0;
170169
staticcharBlanks[MAXATTR];
171170

172171
Form_pg_attributeattrtypes[MAXATTR];/* points to attribute info */
@@ -193,23 +192,19 @@ static IndexList *ILHead = NULL;
193192

194193

195194
/*
196-
*The main entry point for running the backend in bootstrap mode
195+
*AuxiliaryProcessMain
197196
*
198-
* The bootstrap mode is used to initialize the template database.
199-
* The bootstrap backend doesn't speak SQL, but instead expects
200-
* commands in a special bootstrap language.
197+
* The main entry point for auxiliary processes, such as the bgwriter,
198+
* bootstrapper and the shared memory checker code.
201199
*
202-
* For historical reasons, BootstrapMain is also used as the control
203-
* routine for non-backend subprocesses launched by the postmaster,
204-
* such as startup and shutdown.
200+
* This code is here just because of historical reasons.
205201
*/
206-
int
207-
BootstrapMain(intargc,char*argv[])
202+
void
203+
AuxiliaryProcessMain(intargc,char*argv[])
208204
{
209205
char*progname=argv[0];
210-
inti;
211206
intflag;
212-
intxlogop=BS_XLOG_NOP;
207+
AuxProcTypeauxType=CheckerProcess;
213208
char*userDoption=NULL;
214209

215210
/*
@@ -278,7 +273,7 @@ BootstrapMain(int argc, char *argv[])
278273
strlcpy(OutputFileName,optarg,MAXPGPATH);
279274
break;
280275
case'x':
281-
xlogop=atoi(optarg);
276+
auxType=atoi(optarg);
282277
break;
283278
case'c':
284279
case'-':
@@ -328,12 +323,12 @@ BootstrapMain(int argc, char *argv[])
328323
{
329324
constchar*statmsg;
330325

331-
switch (xlogop)
326+
switch (auxType)
332327
{
333-
caseBS_XLOG_STARTUP:
328+
caseStartupProcess:
334329
statmsg="startup process";
335330
break;
336-
caseBS_XLOG_BGWRITER:
331+
caseBgWriterProcess:
337332
statmsg="writer process";
338333
break;
339334
default:
@@ -372,9 +367,9 @@ BootstrapMain(int argc, char *argv[])
372367
BaseInit();
373368

374369
/*
375-
* When we area dummy process, we aren't going to do the full
370+
* When we arean auxiliary process, we aren't going to do the full
376371
* InitPostgres pushups, but there are a couple of things that need to get
377-
* lit up even ina dummy process.
372+
* lit up even inan auxiliary process.
378373
*/
379374
if (IsUnderPostmaster)
380375
{
@@ -383,51 +378,62 @@ BootstrapMain(int argc, char *argv[])
383378
* this was already done by SubPostmasterMain().
384379
*/
385380
#ifndefEXEC_BACKEND
386-
InitDummyProcess();
381+
InitAuxiliaryProcess();
387382
#endif
388383

389384
/* finish setting up bufmgr.c */
390385
InitBufferPoolBackend();
391386

392387
/* register a shutdown callback for LWLock cleanup */
393-
on_shmem_exit(ShutdownDummyProcess,0);
388+
on_shmem_exit(ShutdownAuxiliaryProcess,0);
394389
}
395390

396391
/*
397392
* XLOG operations
398393
*/
399394
SetProcessingMode(NormalProcessing);
400395

401-
switch (xlogop)
396+
switch (auxType)
402397
{
403-
caseBS_XLOG_NOP:
398+
caseCheckerProcess:
404399
bootstrap_signals();
405-
break;
400+
CheckerModeMain();
401+
proc_exit(1);/* should never return */
406402

407-
caseBS_XLOG_BOOTSTRAP:
403+
caseBootstrapProcess:
408404
bootstrap_signals();
409405
BootStrapXLOG();
410406
StartupXLOG();
411-
break;
407+
BootstrapModeMain();
408+
proc_exit(1);/* should never return */
412409

413-
caseBS_XLOG_STARTUP:
410+
caseStartupProcess:
414411
bootstrap_signals();
415412
StartupXLOG();
416413
LoadFreeSpaceMap();
417414
BuildFlatFiles(false);
418415
proc_exit(0);/* startup done */
419416

420-
caseBS_XLOG_BGWRITER:
417+
caseBgWriterProcess:
421418
/* don't set signals, bgwriter has its own agenda */
422419
InitXLOGAccess();
423420
BackgroundWriterMain();
424421
proc_exit(1);/* should never return */
425-
422+
426423
default:
427-
elog(PANIC,"unrecognizedXLOG op: %d",xlogop);
424+
elog(PANIC,"unrecognizedprocess type: %d",auxType);
428425
proc_exit(1);
429426
}
427+
}
430428

429+
/*
430+
* In shared memory checker mode, all we really want to do is create shared
431+
* memory and semaphores (just to prove we can do it with the current GUC
432+
* settings).
433+
*/
434+
staticvoid
435+
CheckerModeMain(void)
436+
{
431437
/*
432438
* We must be getting invoked for bootstrap mode
433439
*/
@@ -439,15 +445,31 @@ BootstrapMain(int argc, char *argv[])
439445
* Do backend-like initialization for bootstrap mode
440446
*/
441447
InitProcess();
442-
(void)InitPostgres(NULL,InvalidOid,NULL,NULL);
448+
InitPostgres(NULL,InvalidOid,NULL,NULL);
449+
proc_exit(0);
450+
}
451+
452+
/*
453+
* The main entry point for running the backend in bootstrap mode
454+
*
455+
* The bootstrap mode is used to initialize the template database.
456+
* The bootstrap backend doesn't speak SQL, but instead expects
457+
* commands in a special bootstrap language.
458+
*/
459+
staticvoid
460+
BootstrapModeMain(void)
461+
{
462+
inti;
463+
464+
Assert(!IsUnderPostmaster);
465+
466+
SetProcessingMode(BootstrapProcessing);
443467

444468
/*
445-
* In NOP mode, all we really want to do is create shared memory and
446-
* semaphores (just to prove we can do it with the current GUC settings).
447-
* So, quit now.
469+
* Do backend-like initialization for bootstrap mode
448470
*/
449-
if (xlogop==BS_XLOG_NOP)
450-
proc_exit(0);
471+
InitProcess();
472+
InitPostgres(NULL,InvalidOid,NULL,NULL);
451473

452474
/* Initialize stuff for bootstrap-file processing */
453475
for (i=0;i<MAXATTR;i++)
@@ -468,14 +490,10 @@ BootstrapMain(int argc, char *argv[])
468490
/* Perform a checkpoint to ensure everything's down to disk */
469491
SetProcessingMode(NormalProcessing);
470492
CreateCheckPoint(true, true);
471-
SetProcessingMode(BootstrapProcessing);
472493

473494
/* Clean up and exit */
474-
StartTransactionCommand();
475495
cleanup();
476-
477-
/* not reached, here to make compiler happy */
478-
return0;
496+
proc_exit(0);
479497
}
480498

481499

@@ -538,30 +556,18 @@ bootstrap_signals(void)
538556
}
539557

540558
/*
541-
* Begin shutdown ofa dummy process. This is approximately the equivalent
542-
* of ShutdownPostgres() in postinit.c. We can't run transactions ina
543-
*dummy process, so most of the work of AbortTransaction() is not needed,
559+
* Begin shutdown ofan auxiliary process. This is approximately the equivalent
560+
* of ShutdownPostgres() in postinit.c. We can't run transactions inan
561+
*auxiliary process, so most of the work of AbortTransaction() is not needed,
544562
* but we do need to make sure we've released any LWLocks we are holding.
545563
* (This is only critical during an error exit.)
546564
*/
547565
staticvoid
548-
ShutdownDummyProcess(intcode,Datumarg)
566+
ShutdownAuxiliaryProcess(intcode,Datumarg)
549567
{
550568
LWLockReleaseAll();
551569
}
552570

553-
/* ----------------
554-
*error handling / abort routines
555-
* ----------------
556-
*/
557-
void
558-
err_out(void)
559-
{
560-
Warnings++;
561-
cleanup();
562-
}
563-
564-
565571
/* ----------------------------------------------------------------
566572
*MANUAL BACKEND INTERACTIVE INTERFACE COMMANDS
567573
* ----------------------------------------------------------------
@@ -815,15 +821,7 @@ InsertOneValue(char *value, int i)
815821

816822
elog(DEBUG4,"inserting column %d value \"%s\"",i,value);
817823

818-
if (Typ!=NULL)
819-
{
820-
typoid=boot_reldesc->rd_att->attrs[i]->atttypid;
821-
}
822-
else
823-
{
824-
/* XXX why is typoid determined differently in this case? */
825-
typoid=attrtypes[i]->atttypid;
826-
}
824+
typoid=boot_reldesc->rd_att->attrs[i]->atttypid;
827825

828826
boot_get_type_io_data(typoid,
829827
&typlen,&typbyval,&typalign,
@@ -856,19 +854,8 @@ InsertOneNull(int i)
856854
staticvoid
857855
cleanup(void)
858856
{
859-
staticintbeenhere=0;
860-
861-
if (!beenhere)
862-
beenhere=1;
863-
else
864-
{
865-
elog(FATAL,"cleanup called twice");
866-
proc_exit(1);
867-
}
868857
if (boot_reldesc!=NULL)
869858
closerel(NULL);
870-
CommitTransactionCommand();
871-
proc_exit(Warnings ?1 :0);
872859
}
873860

874861
/* ----------------
@@ -934,7 +921,6 @@ gettype(char *type)
934921
returngettype(type);
935922
}
936923
elog(ERROR,"unrecognized type \"%s\"",type);
937-
err_out();
938924
/* not reached, here to make compiler happy */
939925
return0;
940926
}

‎src/backend/main/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.107 2007/01/05 22:19:29 momjian Exp $
16+
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.108 2007/03/07 13:35:02 alvherre Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -177,7 +177,7 @@ main(int argc, char *argv[])
177177
#endif
178178

179179
if (argc>1&&strcmp(argv[1],"--boot")==0)
180-
exit(BootstrapMain(argc,argv));
180+
AuxiliaryProcessMain(argc,argv);/* does not return */
181181

182182
if (argc>1&&strcmp(argv[1],"--describe-config")==0)
183183
exit(GucInfoMain());

‎src/backend/postmaster/autovacuum.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.32 2007/02/15 23:23:23 alvherre Exp $
13+
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.33 2007/03/07 13:35:02 alvherre Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -246,7 +246,7 @@ AutoVacLauncherMain(int argc, char *argv[])
246246
#endif
247247

248248
/*
249-
* Set up signal handlers.Since this isa "dummy" process, it has
249+
* Set up signal handlers.Since this isan auxiliary process, it has
250250
* particular signal requirements -- no deadlock checker or sinval
251251
* catchup, for example.
252252
*
@@ -277,7 +277,7 @@ AutoVacLauncherMain(int argc, char *argv[])
277277
* had to do some stuff with LWLocks).
278278
*/
279279
#ifndefEXEC_BACKEND
280-
InitDummyProcess();
280+
InitAuxiliaryProcess();
281281
#endif
282282

283283
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp