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

Commit4793740

Browse files
committed
XLOG (also known as WAL -:)) Bootstrap/Startup/Shutdown.
First step in cleaning up backend initialization code.Fix for FATAL: now FATAL is ERROR + exit.
1 parent9dcd8c5 commit4793740

File tree

20 files changed

+1176
-1033
lines changed

20 files changed

+1176
-1033
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 449 additions & 377 deletions
Large diffs are not rendered by default.

‎src/backend/bootstrap/bootstrap.c

Lines changed: 58 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.68 1999/09/27 20:26:58 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.69 1999/10/06 21:58:02 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -39,6 +39,14 @@
3939
#defineALLOC(t,c)(t *)calloc((unsigned)(c), sizeof(t))
4040
#defineFIRST_TYPE_OID 16/* OID of the first type */
4141

42+
externvoidBaseInit(void);
43+
externvoidStartupXLOG(void);
44+
externvoidShutdownXLOG(void);
45+
externvoidBootStrapXLOG(void);
46+
47+
externcharXLogDir[];
48+
externcharControlFilePath[];
49+
4250
externintInt_yyparse(void);
4351
statichashnode*AddStr(char*str,intstrlength,intmderef);
4452
staticForm_pg_attributeAllocateAttribute(void);
@@ -218,22 +226,13 @@ BootstrapMain(int argc, char *argv[])
218226
*/
219227
{
220228
inti;
221-
intportFd=-1;
222229
char*dbName;
223230
intflag;
224-
intoverride=1;/* use BootstrapProcessing or
225-
* InitProcessing mode */
231+
boolxloginit= false;
226232

227233
externintoptind;
228234
externchar*optarg;
229235

230-
/* ----------------
231-
*initialize signal handlers
232-
* ----------------
233-
*/
234-
pqsignal(SIGINT, (sig_func)die);
235-
pqsignal(SIGHUP, (sig_func)die);
236-
pqsignal(SIGTERM, (sig_func)die);
237236

238237
/* --------------------
239238
*initialize globals
@@ -252,8 +251,9 @@ BootstrapMain(int argc, char *argv[])
252251
Noversion= false;
253252
dbName=NULL;
254253
DataDir=getenv("PGDATA");/* Null if no PGDATA variable */
254+
IsUnderPostmaster= false;
255255

256-
while ((flag=getopt(argc,argv,"D:dCOQP:F"))!=EOF)
256+
while ((flag=getopt(argc,argv,"D:dCQxpB:F"))!=EOF)
257257
{
258258
switch (flag)
259259
{
@@ -270,14 +270,17 @@ BootstrapMain(int argc, char *argv[])
270270
case'F':
271271
disableFsync= true;
272272
break;
273-
case'O':
274-
override= true;
275-
break;
276273
case'Q':
277274
Quiet= true;
278275
break;
279-
case'P':/* specify port */
280-
portFd=atoi(optarg);
276+
case'x':
277+
xloginit= true;
278+
break;
279+
case'p':
280+
IsUnderPostmaster= true;
281+
break;
282+
case'B':
283+
NBuffers=atoi(optarg);
281284
break;
282285
default:
283286
usage();
@@ -290,6 +293,8 @@ BootstrapMain(int argc, char *argv[])
290293
elseif (argc-optind==1)
291294
dbName=argv[optind];
292295

296+
SetProcessingMode(BootstrapProcessing);
297+
293298
if (!DataDir)
294299
{
295300
fprintf(stderr,"%s does not know where to find the database system "
@@ -311,24 +316,50 @@ BootstrapMain(int argc, char *argv[])
311316
}
312317
}
313318

314-
/* ----------------
315-
*initialize input fd
316-
* ----------------
319+
BaseInit();
320+
321+
if (!IsUnderPostmaster)
322+
{
323+
pqsignal(SIGINT, (sig_func)die);
324+
pqsignal(SIGHUP, (sig_func)die);
325+
pqsignal(SIGTERM, (sig_func)die);
326+
}
327+
328+
/*
329+
* Bootstrap under Postmaster means two things:
330+
* (xloginit) ? StartupXLOG : ShutdownXLOG
331+
*
332+
* If !under Postmaster and xloginit then BootStrapXLOG.
317333
*/
318-
if (IsUnderPostmaster&&portFd<0)
334+
if (IsUnderPostmaster||xloginit)
319335
{
320-
fputs("backend: failed, no -P option with -postmaster opt.\n",stderr);
321-
proc_exit(1);
336+
sprintf(XLogDir,"%s%cpg_xlog",DataDir,SEP_CHAR);
337+
sprintf(ControlFilePath,"%s%cpg_control",DataDir,SEP_CHAR);
322338
}
323339

324-
/* ----------------
325-
*backend initialization
326-
* ----------------
340+
if (IsUnderPostmaster&&xloginit)
341+
{
342+
StartupXLOG();
343+
proc_exit(0);
344+
}
345+
346+
if (!IsUnderPostmaster&&xloginit)
347+
{
348+
BootStrapXLOG();
349+
}
350+
351+
/*
352+
* backend initialization
327353
*/
328-
SetProcessingMode((override) ?BootstrapProcessing :InitProcessing);
329354
InitPostgres(dbName);
330355
LockDisable(true);
331356

357+
if (IsUnderPostmaster&& !xloginit)
358+
{
359+
ShutdownXLOG();
360+
proc_exit(0);
361+
}
362+
332363
for (i=0;i<MAXATTR;i++)
333364
{
334365
attrtypes[i]= (Form_pg_attribute)NULL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp