Re: Dependency to logging in jsonapi.c

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Jacob Champion <pchampion(at)vmware(dot)com>
Cc: "tgl(at)sss(dot)pgh(dot)pa(dot)us" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Dependency to logging in jsonapi.c
Date: 2021-06-30 22:42:31
Message-ID: YNzzV2FawcgXYuk1@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jun 30, 2021 at 03:47:19PM +0000, Jacob Champion wrote:
> On Wed, 2021-06-30 at 11:03 -0400, Tom Lane wrote:
>> 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.

That sounds sensible from here. One thing to be aware of is
json_parse_manifest() in pg_verifybackup that uses it, but we could
just replace the error by a plain "failed to parse manifest"".
Backup manifests are generated by the backend, so failures should not
happen there anyway.

> FWIW this is one of the fixes (patch 0002) in the JSON-for-libpq thread
> [1]. It ensures that all returned error strings are freeable by the
> caller. That in turn was the impetus for the asprintf port suggestion.

Yes.

> But until/unless that is changed, an #ifndef seems like a good way to
> prevent issues for the current code.

Sounds sensible to do that as well for 14 before the release. Any
thoughts about that?
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2021-06-30 22:47:41 Re: New committers: Daniel Gustafsson and John Naylor
Previous Message Jacob Champion 2021-06-30 22:41:01 Re: Preventing abort() and exit() calls in libpq