Michael Paquier <michael@paquier.xyz> writes:
> 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?
+1 in general, but I think I'd replace the one in report_parse_error
with "Assert(false)", rather than just dropping it.
It does not look to me like json_errdetail can sensibly be used in
frontend, since it returns palloc'd strings in some paths and
constants in others. There'd be no way to avoid a memory leak
in a frontend usage. So I think the dependency on psprintf there
is not really a problem, but maybe we should make the entire function
"#ifndef FRONTEND" to clarify the intended usage and avoid building
useless code into clients.
regards, tom lane