Re: Dependency to logging in jsonapi.c
Jacob Champion <pchampion@vmware.com>
From: Jacob Champion <pchampion@vmware.com>
To: "tgl@sss.pgh.pa.us" <tgl@sss.pgh.pa.us>, "michael@paquier.xyz" <michael@paquier.xyz>
Cc: "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2021-06-30T15:47:19Z
Lists: pgsql-hackers
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. 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. But until/unless that is changed, an #ifndef seems like a good way to prevent issues for the current code. --Jacob [1] https://www.postgresql.org/message-id/flat/a250d475ba1c0cc0efb7dfec8e538fcc77cdcb8e.camel@vmware.com
Commits
-
Simplify error handing of jsonapi.c for the frontend
- b44669b2ca6a 15.0 landed