diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-04-08 14:55:14 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-04-08 14:55:14 -0400 |
commit | 9a374b77fb53e4cfbca121e4fa278a7d71bde7c4 (patch) | |
tree | 6591af757bd9df12549279b4b87f01e0ce98bd79 /src/bin/pg_basebackup/streamutil.c | |
parent | 5c431c7fb327e1abc70b7a197650f8d45fd5bede (diff) | |
download | postgresql-9a374b77fb53e4cfbca121e4fa278a7d71bde7c4.tar.gz postgresql-9a374b77fb53e4cfbca121e4fa278a7d71bde7c4.zip |
Improve frontend error logging style.
Get rid of the separate "FATAL" log level, as it was applied
so inconsistently as to be meaningless. This mostly involves
s/pg_log_fatal/pg_log_error/g.
Create a macro pg_fatal() to handle the common use-case of
pg_log_error() immediately followed by exit(1). Various
modules had already invented either this or equivalent macros;
standardize on pg_fatal() and apply it where possible.
Invent the ability to add "detail" and "hint" messages to a
frontend message, much as we have long had in the backend.
Except where rewording was needed to convert existing coding
to detail/hint style, I have (mostly) resisted the temptation
to change existing message wording.
Patch by me. Design and patch reviewed at various stages by
Robert Haas, Kyotaro Horiguchi, Peter Eisentraut and
Daniel Gustafsson.
Discussion: https://postgr.es/m/1363732.1636496441@sss.pgh.pa.us
Diffstat (limited to 'src/bin/pg_basebackup/streamutil.c')
-rw-r--r-- | src/bin/pg_basebackup/streamutil.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.c index 4a6afd1a068..86c0493a949 100644 --- a/src/bin/pg_basebackup/streamutil.c +++ b/src/bin/pg_basebackup/streamutil.c @@ -88,10 +88,7 @@ GetConnection(void) { conn_opts = PQconninfoParse(connection_string, &err_msg); if (conn_opts == NULL) - { - pg_log_error("%s", err_msg); - exit(1); - } + pg_fatal("%s", err_msg); for (conn_opt = conn_opts; conn_opt->keyword != NULL; conn_opt++) { @@ -182,10 +179,7 @@ GetConnection(void) * and PQconnectdbParams returns NULL, we call exit(1) directly. */ if (!tmpconn) - { - pg_log_error("could not connect to server"); - exit(1); - } + pg_fatal("could not connect to server"); /* If we need a password and -w wasn't given, loop back and get one */ if (PQstatus(tmpconn) == CONNECTION_BAD && |