Re: [PATCH] Add pretty-printed XML output option

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Cc: Peter Smith <smithpb2250(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Add pretty-printed XML output option
Date: 2023-02-09 07:23:04
Message-ID: 3845900.1675927384@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> writes:
> I see your point. If I got it right, you're suggesting the following
> change in the PG_TRY();

>    PG_TRY();
>     {

>         int nbytes;

>         if(!doc)
>             xml_ereport(xmlerrcxt, ERROR, ERRCODE_INTERNAL_ERROR,
>                     "could not parse the given XML document");

>         xmlDocDumpFormatMemory(doc, &xmlbuf, &nbytes, 1);

>         if(!nbytes || xmlerrcxt->err_occurred)
>             xml_ereport(xmlerrcxt, ERROR, ERRCODE_INTERNAL_ERROR,
>                     "could not indent the given XML document");

>         initStringInfo(&buf);
>         appendStringInfoString(&buf, (const char *)xmlbuf);

>     }

> .. which will catch the doc == NULL before calling xmlDocDumpFormatMemory.

Um ... why are you using PG_TRY here at all? It seems like
you have full control of the actually likely error cases.
The only plausible error out of the StringInfo calls is OOM,
and you probably don't want to trap that at all.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2023-02-09 07:56:19 Re: Time delayed LR (WAS Re: logical replication restrictions)
Previous Message Jim Jones 2023-02-09 07:16:50 Re: [PATCH] Add pretty-printed XML output option