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

Commit4df52b2

Browse files
committed
Fix things so that an error occuring during standalone-backend processing
in initdb will result in exit(1), allowing the initdb script to realizethat there's something wrong.
1 parentaae0781 commit4df52b2

File tree

6 files changed

+44
-23
lines changed

6 files changed

+44
-23
lines changed

‎src/backend/bootstrap/bootstrap.c

Lines changed: 4 additions & 4 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-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.159 2003/05/2816:03:55 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.160 2003/05/2818:19:09 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -838,21 +838,21 @@ BootstrapAlreadySeen(Oid id)
838838
* ----------------
839839
*/
840840
staticvoid
841-
cleanup()
841+
cleanup(void)
842842
{
843843
staticintbeenhere=0;
844844

845845
if (!beenhere)
846846
beenhere=1;
847847
else
848848
{
849-
elog(FATAL,"Memory manager fault: cleanup called twice.\n");
849+
elog(FATAL,"Memory manager fault: cleanup called twice");
850850
proc_exit(1);
851851
}
852852
if (boot_reldesc!=NULL)
853853
closerel(NULL);
854854
CommitTransactionCommand();
855-
proc_exit(Warnings);
855+
proc_exit(Warnings ?1 :0);
856856
}
857857

858858
/* ----------------

‎src/backend/utils/error/elog.c

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.110 2003/05/2817:25:02 tgl Exp $
40+
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.111 2003/05/2818:19:09 tgl Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -410,18 +410,28 @@ errfinish(int dummy, ...)
410410
/*
411411
* For a FATAL error, we let proc_exit clean up and exit.
412412
*
413-
* If we have not yet entered the main backend loop (ie, we are in
414-
* the postmaster or in backend startup), we also go directly to
415-
* proc_exit. The same is true if anyone tries to report an error
416-
* after proc_exit has begun to run. (It's proc_exit's
417-
* responsibility to see that this doesn't turn into infinite
418-
* recursion!)But in the latter case, we exit with nonzero exit
419-
* code to indicate that something's pretty wrong. We also want
420-
* to exit with nonzero exit code if not running under the
421-
* postmaster (for example, if we are being run from the initdb
422-
* script, we'd better return an error status).
413+
* There are several other cases in which we treat ERROR as FATAL
414+
* and go directly to proc_exit:
415+
*
416+
* 1. ExitOnAnyError mode switch is set (initdb uses this).
417+
*
418+
* 2. we have not yet entered the main backend loop (ie, we are in
419+
* the postmaster or in backend startup); we have noplace to recover.
420+
*
421+
* 3. the error occurred after proc_exit has begun to run. (It's
422+
* proc_exit's responsibility to see that this doesn't turn into
423+
* infinite recursion!)
424+
*
425+
* In the last case, we exit with nonzero exit code to indicate that
426+
* something's pretty wrong. We also want to exit with nonzero exit
427+
* code if not running under the postmaster (for example, if we are
428+
* being run from the initdb script, we'd better return an error
429+
* status).
423430
*/
424-
if (elevel==FATAL|| !Warn_restart_ready||proc_exit_inprogress)
431+
if (elevel==FATAL||
432+
ExitOnAnyError||
433+
!Warn_restart_ready||
434+
proc_exit_inprogress)
425435
{
426436
/*
427437
* fflush here is just to improve the odds that we get to see

‎src/backend/utils/init/globals.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.70 2003/05/2817:25:02 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.71 2003/05/2818:19:09 tgl Exp $
1212
*
1313
* NOTES
1414
* Globals used all over the place should be declared here and not
@@ -61,6 +61,8 @@ OidMyDatabaseId = InvalidOid;
6161
boolIsPostmasterEnvironment= false;
6262
boolIsUnderPostmaster= false;
6363

64+
boolExitOnAnyError= false;
65+
6466
intDateStyle=USE_ISO_DATES;
6567
boolEuroDates= false;
6668
boolHasCTZSet= false;

‎src/backend/utils/misc/guc.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.126 2003/05/27 17:55:50 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.127 2003/05/28 18:19:09 tgl Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -399,6 +399,12 @@ static struct config_bool
399399
},
400400
#endif
401401

402+
{
403+
/* currently undocumented, so don't show in SHOW ALL */
404+
{"exit_on_error",PGC_USERSET,GUC_NO_SHOW_ALL},&ExitOnAnyError,
405+
false,NULL,NULL
406+
},
407+
402408
{
403409
{"log_statement",PGC_SUSET},&log_statement,
404410
false,NULL,NULL

‎src/bin/initdb/initdb.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
2828
# Portions Copyright (c) 1994, Regents of the University of California
2929
#
30-
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.190 2003/05/2817:25:02 tgl Exp $
30+
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.191 2003/05/2818:19:09 tgl Exp $
3131
#
3232
#-------------------------------------------------------------------------
3333

@@ -612,7 +612,7 @@ echo "ok"
612612
# To break an SQL command across lines in this script, backslash-escape all
613613
# internal newlines in the command.
614614

615-
PGSQL_OPT="$PGSQL_OPT -O -c search_path=pg_catalog"
615+
PGSQL_OPT="$PGSQL_OPT -O -c search_path=pg_catalog -c exit_on_error=true"
616616

617617
$ECHO_N"initializing pg_shadow..."$ECHO_C
618618

‎src/include/miscadmin.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $Id: miscadmin.h,v 1.122 2003/05/2817:25:02 tgl Exp $
15+
* $Id: miscadmin.h,v 1.123 2003/05/2818:19:09 tgl Exp $
1616
*
1717
* NOTES
1818
* some of the information in this file should be moved to
@@ -104,8 +104,6 @@ extern void ProcessInterrupts(void);
104104
/*
105105
* from postmaster/postmaster.c
106106
*/
107-
externboolIsPostmasterEnvironment;
108-
externboolIsUnderPostmaster;
109107
externboolClientAuthInProgress;
110108
externconstboolExecBackend;
111109

@@ -115,6 +113,11 @@ extern void ClosePostmasterPorts(bool pgstat_too);
115113
/*
116114
* from utils/init/globals.c
117115
*/
116+
externboolIsPostmasterEnvironment;
117+
externboolIsUnderPostmaster;
118+
119+
externboolExitOnAnyError;
120+
118121
externboolNoversion;
119122
externchar*DataDir;
120123

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp