pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jim Jones <jim.jones@uni-muenster.de>
Cc: Peter Smith <smithpb2250@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: [PATCH] Add pretty-printed XML output option
Date: Thu, 09 Feb 2023 02:23:04 -0500
Message-ID: <3845900.1675927384@sss.pgh.pa.us> (raw )
In-Reply-To: <3a3d7963-7f30-9e0a-5e7c-11382fed425a@uni-muenster.de >
References: <2f5df461-dad8-6d7d-4568-08e10608a69b@uni-muenster.de >
<8453003d-e1b1-7306-5fc5-6d1503adac1b@uni-muenster.de >
<4359b355-5054-9758-ebab-a2c17a9b115e@uni-muenster.de >
<2677159.1675700584@sss.pgh.pa.us >
<226a2228-934b-22b8-45cd-dd144a3c443d@uni-muenster.de >
<d385a64e-872f-ed09-9dc1-73545635ebca@uni-muenster.de >
<CAHut+Pu7Mu1OtB2N_JYxX3Zb0XX5+1UsfpcZ9vPdhtJZkCp9Xg@mail.gmail.com >
<a42757df-4b65-aaaa-1eb4-daf9bcf17d6e@uni-muenster.de >
<CAHut+Pu1-wHbVubFjtotn4TBGMinOxv85R8cuqasnPKcWmWLVw@mail.gmail.com >
<3a3d7963-7f30-9e0a-5e7c-11382fed425a@uni-muenster.de >
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
view thread (70+ messages) latest in thread
Message-ID: <3845900.1675927384@sss.pgh.pa.us>
Permalink: ../3845900.1675927384@sss.pgh.pa.us/
Also on: postgresql.org/message-id/3845900.1675927384@sss.pgh.pa.us
copy link · copy postgr.es
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, jim.jones@uni-muenster.de, smithpb2250@gmail.com, pgsql-hackers@lists.postgresql.org
Subject: Re: [PATCH] Add pretty-printed XML output option
In-Reply-To: <3845900.1675927384@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox