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