diff options
Diffstat (limited to 'src/backend/bootstrap/bootstrap.c')
-rw-r--r-- | src/backend/bootstrap/bootstrap.c | 85 |
1 files changed, 58 insertions, 27 deletions
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index c20a63fc6dc..8871e14835a 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -7,7 +7,7 @@ * Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.68 1999/09/27 20:26:58 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.69 1999/10/06 21:58:02 vadim Exp $ * *------------------------------------------------------------------------- */ @@ -39,6 +39,14 @@ #define ALLOC(t, c) (t *)calloc((unsigned)(c), sizeof(t)) #define FIRST_TYPE_OID 16 /* OID of the first type */ +extern void BaseInit(void); +extern void StartupXLOG(void); +extern void ShutdownXLOG(void); +extern void BootStrapXLOG(void); + +extern char XLogDir[]; +extern char ControlFilePath[]; + extern int Int_yyparse(void); static hashnode *AddStr(char *str, int strlength, int mderef); static Form_pg_attribute AllocateAttribute(void); @@ -218,22 +226,13 @@ BootstrapMain(int argc, char *argv[]) */ { int i; - int portFd = -1; char *dbName; int flag; - int override = 1; /* use BootstrapProcessing or - * InitProcessing mode */ + bool xloginit = false; extern int optind; extern char *optarg; - /* ---------------- - * initialize signal handlers - * ---------------- - */ - pqsignal(SIGINT, (sig_func) die); - pqsignal(SIGHUP, (sig_func) die); - pqsignal(SIGTERM, (sig_func) die); /* -------------------- * initialize globals @@ -252,8 +251,9 @@ BootstrapMain(int argc, char *argv[]) Noversion = false; dbName = NULL; DataDir = getenv("PGDATA"); /* Null if no PGDATA variable */ + IsUnderPostmaster = false; - while ((flag = getopt(argc, argv, "D:dCOQP:F")) != EOF) + while ((flag = getopt(argc, argv, "D:dCQxpB:F")) != EOF) { switch (flag) { @@ -270,14 +270,17 @@ BootstrapMain(int argc, char *argv[]) case 'F': disableFsync = true; break; - case 'O': - override = true; - break; case 'Q': Quiet = true; break; - case 'P': /* specify port */ - portFd = atoi(optarg); + case 'x': + xloginit = true; + break; + case 'p': + IsUnderPostmaster = true; + break; + case 'B': + NBuffers = atoi(optarg); break; default: usage(); @@ -290,6 +293,8 @@ BootstrapMain(int argc, char *argv[]) else if (argc - optind == 1) dbName = argv[optind]; + SetProcessingMode(BootstrapProcessing); + if (!DataDir) { fprintf(stderr, "%s does not know where to find the database system " @@ -311,24 +316,50 @@ BootstrapMain(int argc, char *argv[]) } } - /* ---------------- - * initialize input fd - * ---------------- + BaseInit(); + + if (!IsUnderPostmaster) + { + pqsignal(SIGINT, (sig_func) die); + pqsignal(SIGHUP, (sig_func) die); + pqsignal(SIGTERM, (sig_func) die); + } + + /* + * Bootstrap under Postmaster means two things: + * (xloginit) ? StartupXLOG : ShutdownXLOG + * + * If !under Postmaster and xloginit then BootStrapXLOG. */ - if (IsUnderPostmaster && portFd < 0) + if (IsUnderPostmaster || xloginit) { - fputs("backend: failed, no -P option with -postmaster opt.\n", stderr); - proc_exit(1); + sprintf(XLogDir, "%s%cpg_xlog", DataDir, SEP_CHAR); + sprintf(ControlFilePath, "%s%cpg_control", DataDir, SEP_CHAR); } - /* ---------------- - * backend initialization - * ---------------- + if (IsUnderPostmaster && xloginit) + { + StartupXLOG(); + proc_exit(0); + } + + if (!IsUnderPostmaster && xloginit) + { + BootStrapXLOG(); + } + + /* + * backend initialization */ - SetProcessingMode((override) ? BootstrapProcessing : InitProcessing); InitPostgres(dbName); LockDisable(true); + if (IsUnderPostmaster && !xloginit) + { + ShutdownXLOG(); + proc_exit(0); + } + for (i = 0; i < MAXATTR; i++) { attrtypes[i] = (Form_pg_attribute) NULL; |