Re: [PATCH] Add pretty-printed XML output option
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jim Jones <jim.jones@uni-muenster.de>
Cc: Peter Smith <smithpb2250@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2023-02-09T07:23:04Z
Lists: 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
Commits
-
Fix memory leak in XMLSERIALIZE(... INDENT).
- f24605e2dc16 18.0 landed
- ee58de10084b 16.10 landed
- 20bae0690322 17.6 landed
-
doc: Move documentation of md5_password_warnings to a better place
- f3622b64762b 18.0 cited
-
Support [NO] INDENT option in XMLSERIALIZE().
- 483bdb2afec9 16.0 landed
-
Add an expected-file to match behavior of latest libxml2.
- 085423e3e326 9.6.0 cited