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

From Jim Jones
Subject Re: [PATCH] Add pretty-printed XML output option
Date
Msg-id 3a3d7963-7f30-9e0a-5e7c-11382fed425a@uni-muenster.de
Whole thread Raw
In response to Re: [PATCH] Add pretty-printed XML output option  (Peter Smith <smithpb2250@gmail.com>)
Responses Re: [PATCH] Add pretty-printed XML output option
List pgsql-hackers
On 09.02.23 02:01, Peter Smith wrote:
> OTOH, if you are having to check for NULL doc anyway, maybe it's just
> as easy only doing that up-front. Then you could quick-exit the
> function without calling xmlDocDumpFormatMemory etc. in the first
> place. For example:
>
> doc = xml_parse(arg, XMLOPTION_DOCUMENT, false, GetDatabaseEncoding(), NULL);
> if (!doc)
>     return 0;

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.

Is it what you suggest?

Thanks a lot for the thorough review!

Best, Jim




pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: [PoC] Improve dead tuple storage for lazy vacuum
Next
From: Tom Lane
Date:
Subject: Re: [PATCH] Add pretty-printed XML output option