diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-05-28 18:19:09 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-05-28 18:19:09 +0000 |
commit | 4df52b28f04669a23d7748af0a6d21b33fdda5df (patch) | |
tree | a71069ad1c7922304bfee395e5fe57a35ce135fa /src/backend/utils | |
parent | aae078198dd4b9cbb3590262dcb65d0b735c80d7 (diff) | |
download | postgresql-4df52b28f04669a23d7748af0a6d21b33fdda5df.tar.gz postgresql-4df52b28f04669a23d7748af0a6d21b33fdda5df.zip |
Fix things so that an error occuring during standalone-backend processing
in initdb will result in exit(1), allowing the initdb script to realize
that there's something wrong.
Diffstat (limited to 'src/backend/utils')
-rw-r--r-- | src/backend/utils/error/elog.c | 34 | ||||
-rw-r--r-- | src/backend/utils/init/globals.c | 4 | ||||
-rw-r--r-- | src/backend/utils/misc/guc.c | 8 |
3 files changed, 32 insertions, 14 deletions
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index fd6d35bb5ad..9d371a5a26d 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -37,7 +37,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.110 2003/05/28 17:25:02 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.111 2003/05/28 18:19:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -410,18 +410,28 @@ errfinish(int dummy, ...) /* * For a FATAL error, we let proc_exit clean up and exit. * - * If we have not yet entered the main backend loop (ie, we are in - * the postmaster or in backend startup), we also go directly to - * proc_exit. The same is true if anyone tries to report an error - * after proc_exit has begun to run. (It's proc_exit's - * responsibility to see that this doesn't turn into infinite - * recursion!) But in the latter case, we exit with nonzero exit - * code to indicate that something's pretty wrong. We also want - * to exit with nonzero exit code if not running under the - * postmaster (for example, if we are being run from the initdb - * script, we'd better return an error status). + * There are several other cases in which we treat ERROR as FATAL + * and go directly to proc_exit: + * + * 1. ExitOnAnyError mode switch is set (initdb uses this). + * + * 2. we have not yet entered the main backend loop (ie, we are in + * the postmaster or in backend startup); we have noplace to recover. + * + * 3. the error occurred after proc_exit has begun to run. (It's + * proc_exit's responsibility to see that this doesn't turn into + * infinite recursion!) + * + * In the last case, we exit with nonzero exit code to indicate that + * something's pretty wrong. We also want to exit with nonzero exit + * code if not running under the postmaster (for example, if we are + * being run from the initdb script, we'd better return an error + * status). */ - if (elevel == FATAL || !Warn_restart_ready || proc_exit_inprogress) + if (elevel == FATAL || + ExitOnAnyError || + !Warn_restart_ready || + proc_exit_inprogress) { /* * fflush here is just to improve the odds that we get to see diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c index a4b0889e4fa..0a53556ec3a 100644 --- a/src/backend/utils/init/globals.c +++ b/src/backend/utils/init/globals.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.70 2003/05/28 17:25:02 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.71 2003/05/28 18:19:09 tgl Exp $ * * NOTES * Globals used all over the place should be declared here and not @@ -61,6 +61,8 @@ Oid MyDatabaseId = InvalidOid; bool IsPostmasterEnvironment = false; bool IsUnderPostmaster = false; +bool ExitOnAnyError = false; + int DateStyle = USE_ISO_DATES; bool EuroDates = false; bool HasCTZSet = false; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 06eab76b989..4d700b4af6c 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -10,7 +10,7 @@ * Written by Peter Eisentraut <peter_e@gmx.net>. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.126 2003/05/27 17:55:50 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.127 2003/05/28 18:19:09 tgl Exp $ * *-------------------------------------------------------------------- */ @@ -400,6 +400,12 @@ static struct config_bool #endif { + /* currently undocumented, so don't show in SHOW ALL */ + {"exit_on_error", PGC_USERSET, GUC_NO_SHOW_ALL}, &ExitOnAnyError, + false, NULL, NULL + }, + + { {"log_statement", PGC_SUSET}, &log_statement, false, NULL, NULL }, |