Re: pg_log_fatal vs pg_log_error

Поиск
Список
Период
Сортировка
От Antonin Houska
Тема Re: pg_log_fatal vs pg_log_error
Дата
Msg-id 9743.1562749137@spoje.net
обсуждение исходный текст
Ответ на Re: pg_log_fatal vs pg_log_error  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Список pgsql-hackers
Peter Eisentraut <peter.eisentraut@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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Antonin Houska
Дата:
Сообщение: Re: [Proposal] Table-level Transparent Data Encryption (TDE) and Key Management Service (KMS)
Следующее
От: David Rowley
Дата:
Сообщение: Re: Custom table AMs need to include heapam.h because of BulkInsertState