summaryrefslogtreecommitdiff
path: root/src/bin/psql/mainloop.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-04-08 14:55:14 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2022-04-08 14:55:14 -0400
commit9a374b77fb53e4cfbca121e4fa278a7d71bde7c4 (patch)
tree6591af757bd9df12549279b4b87f01e0ce98bd79 /src/bin/psql/mainloop.c
parent5c431c7fb327e1abc70b7a197650f8d45fd5bede (diff)
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/psql/mainloop.c')
-rw-r--r--src/bin/psql/mainloop.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c
index e5c976fc4fc..b0c4177a20e 100644
--- a/src/bin/psql/mainloop.c
+++ b/src/bin/psql/mainloop.c
@@ -77,10 +77,7 @@ MainLoop(FILE *source)
if (PQExpBufferBroken(query_buf) ||
PQExpBufferBroken(previous_buf) ||
PQExpBufferBroken(history_buf))
- {
- pg_log_error("out of memory");
- exit(EXIT_FAILURE);
- }
+ pg_fatal("out of memory");
/* main loop to get queries and execute them */
while (successResult == EXIT_SUCCESS)
@@ -398,10 +395,7 @@ MainLoop(FILE *source)
prompt_status = prompt_tmp;
if (PQExpBufferBroken(query_buf))
- {
- pg_log_error("out of memory");
- exit(EXIT_FAILURE);
- }
+ pg_fatal("out of memory");
/*
* Increase statement line number counter for each linebreak added