Dependency to logging in jsonapi.c

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Dependency to logging in jsonapi.c
Дата
Msg-id YNwL7kXwn3Cckbd6@paquier.xyz
обсуждение исходный текст
Ответы Re: Dependency to logging in jsonapi.c  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi all,

jsonapi.c includes the following code bits to enforce the use of
logging:
#ifdef FRONTEND
#define check_stack_depth()
#define json_log_and_abort(...) \
   do { pg_log_fatal(__VA_ARGS__); exit(1); } while(0)
#else
#define json_log_and_abort(...) elog(ERROR, __VA_ARGS__)
#endif

This has been mentioned here:
https://www.postgresql.org/message-id/YNfXpFeBVfU2HsVe@paquier.xyz

This requires any tools in the frontend to use pg_logging_init(),
which is recommended, but not enforced.  Perhaps that's fine in
itself to require frontends to register to the central logging APIs,
but json_log_and_abort() gets only called when dealing with incorrect
error codes even if we rely on JsonParseErrorType in all the places
doing error handling with the JSON parsing.  And requiring a
dependency on logging just for unlikely-to-happen cases seems a bit
crazy to me.

Attached is a suggestion of patch to rework that a bit.  Some extra
elog()s could be added for the backend, as well as a new error code to
use as default of report_parse_error(), but that does not seem to gain
much.  And this item looks independent of switching this code to use
pqexpbuffer.h to be more portable with issues like OOM problems.

Thoughts?
--
Michael

Вложения

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

Предыдущее
От: Yugo NAGATA
Дата:
Сообщение: Re: Fix around conn_duration in pgbench
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: prion failed with ERROR: missing chunk number 0 for toast value 14334 in pg_toast_2619