Peter Eisentraut <peter.eisentr...@2ndquadrant.com> wrote: > On 2019-06-17 14:19, Antonin Houska wrote: > > Can anyone please give me a hint (and possibly add some comments to the > > code) > > when pg_log_fatal() should be used in frontend code and when it's > > appropriate > > to call pg_log_error()? The current use does not seem very consistent. > > For a program that runs in a loop, like for example psql or > pg_receivewal, use error if the program keeps running and fatal if not. > For one-shot programs like for example createdb, there is no difference, > so we have used error in those cases.
That makes sense, but shouldn't then pg_log_fatal() perform exit(EXIT_FAILURE) internally? Just like elog(FATAL) does on backend side. Actually there are indications that someone would appreciate such behaviour even in frontends. In pg_rewind.h I see: /* logging support */ #define pg_fatal(...) do { pg_log_fatal(__VA_ARGS__); exit(1); } while(0) or this in pg_upgrade/util.c: void pg_fatal(const char *fmt,...) { va_list args; va_start(args, fmt); pg_log_v(PG_FATAL, fmt, args); va_end(args); printf(_("Failure, exiting\n")); exit(1); } -- Antonin Houska Web: https://www.cybertec-postgresql.com