Re: [PATCH] Add pretty-printed XML output option - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [PATCH] Add pretty-printed XML output option
Date
Msg-id 3845900.1675927384@sss.pgh.pa.us
Whole thread Raw
In response to Re: [PATCH] Add pretty-printed XML output option  (Jim Jones <jim.jones@uni-muenster.de>)
Responses Re: [PATCH] Add pretty-printed XML output option
List pgsql-hackers
Jim Jones <jim.jones@uni-muenster.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



pgsql-hackers by date:

Previous
From: Jim Jones
Date:
Subject: Re: [PATCH] Add pretty-printed XML output option
Next
From: Amit Kapila
Date:
Subject: Re: Time delayed LR (WAS Re: logical replication restrictions)