Re: Support json_errdetail in FRONTEND builds

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Daniel Gustafsson <daniel(at)yesql(dot)se>, alvherre(at)alvh(dot)no-ip(dot)org
Subject: Re: Support json_errdetail in FRONTEND builds
Date: 2024-03-14 08:06:31
Message-ID: ZfKwB_MygzQsQRji@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Mar 13, 2024 at 11:20:16AM -0700, Jacob Champion wrote:
> Sounds good, split into v2-0002. (That gives me room to switch other
> call sites to the new API, too.) Thanks both!

That looks OK to me. I can see 7~8 remaining sites where StringInfo
data is freed, like in the syslogger, but we should not touch the
StringInfo.

>> case JSON_EXPECTED_STRING:
>> - return psprintf(_("Expected string, but found \"%s\"."),
>> - extract_token(lex));
>> + appendStringInfo(lex->errormsg,
>> + _("Expected string, but found \"%.*s\"."),
>> + toklen, lex->token_start);
>>
>> Maybe this could be wrapped in a macro to avoid copying around
>> token_start and toklen for all the error cases.
>
> I gave it a shot in 0001; see what you think.

That's cleaner, thanks.

Hmm, I think that it is cleaner to create the new API first, and then
rely on it, reversing the order of both patches (perhaps the extra
destroyStringInfo in freeJsonLexContext() should have been moved in
0001). See the attached with few tweaks to 0001, previously 0002 @-(at)(dot)
I'd still need to do a more serious lookup of 0002, previously 0001.
--
Michael

Attachment Content-Type Size
v3-0001-Add-a-helper-function-for-cleaning-up-StringInfos.patch text/x-diff 5.8 KB
v3-0002-common-jsonapi-support-json_errdetail-in-FRONTEND.patch text/x-diff 8.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2024-03-14 08:08:19 Re: Built-in CTYPE provider
Previous Message Michael Paquier 2024-03-14 07:42:10 Re: type cache cleanup improvements