Re: [PATCH] Add pretty-printed XML output option

From: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
To: Peter Smith <smithpb2250(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Add pretty-printed XML output option
Date: 2023-02-09 07:16:50
Message-ID: 3a3d7963-7f30-9e0a-5e7c-11382fed425a@uni-muenster.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2023-02-09 07:23:04 Re: [PATCH] Add pretty-printed XML output option
Previous Message Masahiko Sawada 2023-02-09 07:08:03 Re: [PoC] Improve dead tuple storage for lazy vacuum